|
@@ -6,6 +6,8 @@ import (
|
|
|
"net/http"
|
|
|
"time"
|
|
|
|
|
|
+ "github.com/allanpk716/ChineseSubFinder/pkg/path_helper"
|
|
|
+
|
|
|
backend2 "github.com/allanpk716/ChineseSubFinder/pkg/types/backend"
|
|
|
"github.com/allanpk716/ChineseSubFinder/pkg/types/common"
|
|
|
TTaskqueue "github.com/allanpk716/ChineseSubFinder/pkg/types/task_queue"
|
|
@@ -190,6 +192,9 @@ func (cb *ControllerBase) VideoListHandler(c *gin.Context) {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+//--------------------------------------------
|
|
|
+
|
|
|
+// RefreshMainList 重构后的视频列表,比如 x:\电影\壮志凌云\壮志凌云.mp4 或者是连续剧的 x:\连续剧\绝命毒师 根目录
|
|
|
func (cb *ControllerBase) RefreshMainList(c *gin.Context) {
|
|
|
|
|
|
var err error
|
|
@@ -248,3 +253,87 @@ func (cb *ControllerBase) RefreshMainList(c *gin.Context) {
|
|
|
Status: "running"})
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+// VideoMainList 获取电影和连续剧的基础结构
|
|
|
+func (cb *ControllerBase) VideoMainList(c *gin.Context) {
|
|
|
+
|
|
|
+ var err error
|
|
|
+ defer func() {
|
|
|
+ // 统一的异常处理
|
|
|
+ cb.ErrorProcess(c, "MoviePoster", err)
|
|
|
+ }()
|
|
|
+ outMovieInfos, outSeasonInfo, err := cb.cronHelper.Downloader.GetMovieInfoAndSeasonInfoV2()
|
|
|
+ if err != nil {
|
|
|
+ cb.log.Errorln("GetMovieInfoAndSeasonInfoV2", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ c.JSON(http.StatusOK, backend2.ReplyMainList{
|
|
|
+ MovieInfos: outMovieInfos,
|
|
|
+ SeasonInfos: outSeasonInfo,
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// MoviePoster 获取电影海报
|
|
|
+func (cb *ControllerBase) MoviePoster(c *gin.Context) {
|
|
|
+
|
|
|
+ var err error
|
|
|
+ defer func() {
|
|
|
+ // 统一的异常处理
|
|
|
+ cb.ErrorProcess(c, "MoviePoster", err)
|
|
|
+ }()
|
|
|
+
|
|
|
+ movieInfo := backend2.MovieInfoV2{}
|
|
|
+ err = c.ShouldBindJSON(&movieInfo)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ // 然后还需要将这个全路径信息转换为 静态文件服务器对应的路径返回给前端
|
|
|
+ desUrl, found := cb.GetPathUrlMap()[movieInfo.MainRootDirFPath]
|
|
|
+ if found == false {
|
|
|
+ // 没有找到对应的 URL
|
|
|
+ errMessage := fmt.Sprintf("MoviePoster.GetPathUrlMap can not find url for path %s", movieInfo.MainRootDirFPath)
|
|
|
+ cb.log.Warningln(errMessage)
|
|
|
+ err = errors.New(errMessage)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ posterFPath := cb.videoListHelper.GetMoviePoster(movieInfo.VideoFPath)
|
|
|
+ posterUrl := path_helper.ChangePhysicalPathToSharePath(posterFPath, movieInfo.MainRootDirFPath, desUrl)
|
|
|
+
|
|
|
+ c.JSON(http.StatusOK, backend2.PosterInfo{
|
|
|
+ Url: posterUrl,
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// SeriesPoster 从一个连续剧的根目录中,获取连续剧的海报
|
|
|
+func (cb *ControllerBase) SeriesPoster(c *gin.Context) {
|
|
|
+
|
|
|
+ var err error
|
|
|
+ defer func() {
|
|
|
+ // 统一的异常处理
|
|
|
+ cb.ErrorProcess(c, "SeriesPoster", err)
|
|
|
+ }()
|
|
|
+
|
|
|
+ seriesInfo := backend2.SeasonInfoV2{}
|
|
|
+ err = c.ShouldBindJSON(&seriesInfo)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ // 然后还需要将这个全路径信息转换为 静态文件服务器对应的路径返回给前端
|
|
|
+ desUrl, found := cb.GetPathUrlMap()[seriesInfo.MainRootDirFPath]
|
|
|
+ if found == false {
|
|
|
+ // 没有找到对应的 URL
|
|
|
+ errMessage := fmt.Sprintf("SeriesPoster.GetPathUrlMap can not find url for path %s", seriesInfo.MainRootDirFPath)
|
|
|
+ cb.log.Warningln(errMessage)
|
|
|
+ err = errors.New(errMessage)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ posterFPath := cb.videoListHelper.GetSeriesPoster(seriesInfo.RootDirPath)
|
|
|
+ posterUrl := path_helper.ChangePhysicalPathToSharePath(posterFPath, seriesInfo.MainRootDirFPath, desUrl)
|
|
|
+
|
|
|
+ c.JSON(http.StatusOK, backend2.PosterInfo{
|
|
|
+ Url: posterUrl,
|
|
|
+ })
|
|
|
+}
|