path_things.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package base
  2. import (
  3. "github.com/allanpk716/ChineseSubFinder/internal/pkg/my_util"
  4. "github.com/allanpk716/ChineseSubFinder/internal/types/backend"
  5. "github.com/gin-gonic/gin"
  6. "net/http"
  7. )
  8. func (cb ControllerBase) CheckPathHandler(c *gin.Context) {
  9. var err error
  10. defer func() {
  11. // 统一的异常处理
  12. cb.ErrorProcess(c, "CheckPathHandler", err)
  13. }()
  14. reqCheckPath := backend.ReqCheckPath{}
  15. err = c.ShouldBindJSON(&reqCheckPath)
  16. if err != nil {
  17. return
  18. }
  19. if my_util.IsDir(reqCheckPath.Path) == true {
  20. c.JSON(http.StatusOK, backend.ReplyCheckPath{
  21. Valid: true,
  22. })
  23. } else {
  24. c.JSON(http.StatusOK, backend.ReplyCheckPath{
  25. Valid: false,
  26. })
  27. }
  28. }
  29. func (cb ControllerBase) CheckEmbyPathHandler(c *gin.Context) {
  30. var err error
  31. defer func() {
  32. // 统一的异常处理
  33. cb.ErrorProcess(c, "CheckEmbyPathHandler", err)
  34. }()
  35. reqCheckPath := backend.ReqCheckEmbyPath{}
  36. err = c.ShouldBindJSON(&reqCheckPath)
  37. if err != nil {
  38. return
  39. }
  40. // 需要使用 Emby 做列表转换,从发送过来的 emby_media_path 进行推算,拼接 cfs_media_path 地址,然后读取这个文件夹或者视频是否存在
  41. // 暂定还是以最近的 Emby 视频列表,再去匹配
  42. //if my_util.IsDir(reqCheckPath.Path) == true {
  43. // c.JSON(http.StatusOK, backend.ReplyCheckEmbyPath{
  44. // Valid: true,
  45. // })
  46. //} else {
  47. // c.JSON(http.StatusOK, backend.ReplyCheckEmbyPath{
  48. // Valid: false,
  49. // })
  50. //}
  51. }