Преглед изворни кода

新增一个接口,从video全路径得到 imdb info

Signed-off-by: allan716 <[email protected]>
allan716 пре 2 година
родитељ
комит
06670aab00
2 измењених фајлова са 28 додато и 0 уклоњено
  1. 1 0
      internal/backend/base_router.go
  2. 27 0
      internal/backend/controllers/v1/preview.go

+ 1 - 0
internal/backend/base_router.go

@@ -137,6 +137,7 @@ func InitRouter(
 		GroupV1.GET("/preview/playlist/:videofpathbase64", cbV1.HlsPlaylist)
 		GroupV1.GET("/preview/segments/:resolution/:segment/:videofpathbase64", cbV1.HlsSegment)
 		GroupV1.POST("/preview/search_other_web", cbV1.PreviewSearchOtherWeb)
+		GroupV1.POST("/preview/video_f_path_2_imdb_info", cbV1.PreviewVideoFPath2IMDBInfo)
 
 	}
 

+ 27 - 0
internal/backend/controllers/v1/preview.go

@@ -239,6 +239,33 @@ func (cb *ControllerBase) PreviewSearchOtherWeb(c *gin.Context) {
 	c.JSON(http.StatusOK, searchOtherWebReply)
 }
 
+func (cb *ControllerBase) PreviewVideoFPath2IMDBInfo(c *gin.Context) {
+	var err error
+	defer func() {
+		// 统一的异常处理
+		cb.ErrorProcess(c, "PreviewVideoFPath2IMDBInfo", err)
+	}()
+
+	searchOtherWeb := SearchOtherWebReq{}
+	err = c.ShouldBindJSON(&searchOtherWeb)
+	if err != nil {
+		return
+	}
+
+	if pkg.IsFile(searchOtherWeb.VideoFPath) == false {
+		c.JSON(http.StatusOK, backend2.ReplyCommon{Message: "video file not found"})
+		return
+	}
+
+	mixMediaInfo, err := mix_media_info.GetMixMediaInfo(cb.cronHelper.FileDownloader.MediaInfoDealers,
+		searchOtherWeb.VideoFPath, searchOtherWeb.IsMovie)
+	if err != nil {
+		return
+	}
+
+	c.JSON(http.StatusOK, &mixMediaInfo)
+}
+
 type SearchOtherWebReq struct {
 	VideoFPath string `json:"video_f_path"`
 	IsMovie    bool   `json:"is_movie"`