Browse Source

修复 GetSeriesDirRootFPath 适用范围的bug

Signed-off-by: allan716 <[email protected]>
allan716 3 years ago
parent
commit
ef4e711414
2 changed files with 18 additions and 16 deletions
  1. 14 13
      internal/backend/controllers/v1/video_list.go
  2. 4 3
      internal/pkg/downloader/downloader.go

+ 14 - 13
internal/backend/controllers/v1/video_list.go

@@ -109,21 +109,22 @@ func (cb *ControllerBase) VideoListAddHandler(c *gin.Context) {
 		videoListAdd.MediaServerInsideVideoID,
 	)
 
-	torrentInfo, err := decode.GetVideoInfoFromFileName(videoListAdd.PhysicalVideoFileFullPath)
-	if err != nil {
-		return
-	}
-
-	seriesInfoDirPath := decode.GetSeriesDirRootFPath(videoListAdd.PhysicalVideoFileFullPath)
-	if seriesInfoDirPath == "" {
-		err = errors.New(fmt.Sprintf("decode.GetSeriesDirRootFPath == Empty, %s", videoListAdd.PhysicalVideoFileFullPath))
-		return
+	if videoType == common.Series {
+		// 如果是连续剧,需要额外的读取这一个剧集的信息
+		torrentInfo, err := decode.GetVideoInfoFromFileName(videoListAdd.PhysicalVideoFileFullPath)
+		if err != nil {
+			return
+		}
+		seriesInfoDirPath := decode.GetSeriesDirRootFPath(videoListAdd.PhysicalVideoFileFullPath)
+		if seriesInfoDirPath == "" {
+			err = errors.New(fmt.Sprintf("decode.GetSeriesDirRootFPath == Empty, %s", videoListAdd.PhysicalVideoFileFullPath))
+			return
+		}
+		oneJob.Season = torrentInfo.Season
+		oneJob.Episode = torrentInfo.Episode
+		oneJob.SeriesRootDirPath = seriesInfoDirPath
 	}
 
-	oneJob.Season = torrentInfo.Season
-	oneJob.Episode = torrentInfo.Episode
-	oneJob.SeriesRootDirPath = seriesInfoDirPath
-
 	bok, err := cb.cronHelper.DownloadQueue.Add(*oneJob)
 	if err != nil {
 		return

+ 4 - 3
internal/pkg/downloader/downloader.go

@@ -3,6 +3,9 @@ package downloader
 import (
 	"errors"
 	"fmt"
+	"path/filepath"
+	"sync"
+
 	"github.com/allanpk716/ChineseSubFinder/internal/dao"
 	"github.com/allanpk716/ChineseSubFinder/internal/ifaces"
 	embyHelper "github.com/allanpk716/ChineseSubFinder/internal/logic/emby_helper"
@@ -26,8 +29,6 @@ import (
 	taskQueue2 "github.com/allanpk716/ChineseSubFinder/internal/types/task_queue"
 	"github.com/sirupsen/logrus"
 	"golang.org/x/net/context"
-	"path/filepath"
-	"sync"
 )
 
 // Downloader 实例化一次用一次,不要反复的使用,很多临时标志位需要清理。
@@ -377,7 +378,7 @@ func (d *Downloader) seriesDlFunc(ctx context.Context, job taskQueue2.OneJob, do
 	epsMap := make(map[int][]int, 0)
 	epsMap[job.Season] = []int{job.Episode}
 
-	if job.SeriesRootDirPath == "" {
+	if job.VideoType == common.Series && job.SeriesRootDirPath == "" {
 		// 连续剧的时候需要额外提交信息
 		torrentInfo, err := decode.GetVideoInfoFromFileName(job.VideoFPath)
 		if err != nil {