Browse Source

保存进度,有待实现 emby path check

Signed-off-by: allan716 <[email protected]>
allan716 3 years ago
parent
commit
e306d293cf

+ 25 - 0
internal/backend/controllers/base/path_things.go

@@ -30,3 +30,28 @@ func (cb ControllerBase) CheckPathHandler(c *gin.Context) {
 		})
 	}
 }
+
+func (cb ControllerBase) CheckEmbyPathHandler(c *gin.Context) {
+	var err error
+	defer func() {
+		// 统一的异常处理
+		cb.ErrorProcess(c, "CheckEmbyPathHandler", err)
+	}()
+
+	reqCheckPath := backend.ReqCheckEmbyPath{}
+	err = c.ShouldBindJSON(&reqCheckPath)
+	if err != nil {
+		return
+	}
+	// 需要使用 Emby 做列表转换,从发送过来的 emby_media_path 进行推算,拼接 cfs_media_path 地址,然后读取这个文件夹或者视频是否存在
+	// 暂定还是以最近的 Emby 视频列表,再去匹配
+	//if my_util.IsDir(reqCheckPath.Path) == true {
+	//	c.JSON(http.StatusOK, backend.ReplyCheckEmbyPath{
+	//		Valid: true,
+	//	})
+	//} else {
+	//	c.JSON(http.StatusOK, backend.ReplyCheckEmbyPath{
+	//		Valid: false,
+	//	})
+	//}
+}

+ 2 - 0
internal/backend/routers/base_router.go

@@ -24,6 +24,8 @@ func InitRouter(router *gin.Engine, cronHelper *cron_helper.CronHelper) {
 
 	router.POST("/check-path", cbBase.CheckPathHandler)
 
+	router.POST("/check-emby-path", cbBase.CheckEmbyPathHandler)
+
 	router.POST("/check-proxy", cbBase.CheckProxyHandler)
 
 	router.GET("/def-settings", cbBase.DefSettingsHandler)

+ 10 - 0
internal/logic/emby_helper/embyhelper.go

@@ -504,6 +504,16 @@ func (em *EmbyHelper) GetInternalEngSubAndExChineseEnglishSub(videoId string) (b
 	return true, inSubList, exSubList, nil
 }
 
+func (em *EmbyHelper) CheckPath(CFSMediaPath, EmbyMediaPath string) ([]string, error) {
+
+	// 获取最近的影片列表
+	items, err := em.embyApi.GetRecentlyItems()
+	if err != nil {
+		return nil, err
+	}
+
+}
+
 type InputData struct {
 	Id string
 	Wg *sync.WaitGroup

+ 5 - 0
internal/types/backend/reply_check_emby_path.go

@@ -0,0 +1,5 @@
+package backend
+
+type ReplyCheckEmbyPath struct {
+	MediaList []string `json:"media_list"`
+}

+ 8 - 0
internal/types/backend/req_check_emby_path.go

@@ -0,0 +1,8 @@
+package backend
+
+type ReqCheckEmbyPath struct {
+	AddressUrl    string `json:"address_url"  binding:"required"`
+	APIKey        string `json:"api_key"  binding:"required"`
+	CFSMediaPath  string `json:"cfs_media_path"  binding:"required"`
+	EmbyMediaPath string `json:"emby_media_path"  binding:"required"`
+}