Browse Source

新增一个函数,允许指定几集用于连续剧的调试(也可能后续会用到常规功能上)下载

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

+ 32 - 2
internal/logic/series_helper/seriesHelper.go

@@ -1,6 +1,7 @@
 package series_helper
 
 import (
+	"fmt"
 	"github.com/StalkR/imdb"
 	"github.com/allanpk716/ChineseSubFinder/internal/common"
 	"github.com/allanpk716/ChineseSubFinder/internal/ifaces"
@@ -144,8 +145,8 @@ func SkipChineseSeries(seriesRootPath string, _reqParam ...types.ReqParam) (bool
 	}
 }
 
-// OneSeriesDlSubInAllSite 一部连续剧在所有的网站下载相应的字幕
-func OneSeriesDlSubInAllSite(Suppliers []ifaces.ISupplier, seriesInfo *series.SeriesInfo, i int) []supplier.SubInfo {
+// DownloadSubtitleInAllSiteByOneSeries 一部连续剧,在所有的网站,下载相应的字幕
+func DownloadSubtitleInAllSiteByOneSeries(Suppliers []ifaces.ISupplier, seriesInfo *series.SeriesInfo, i int) []supplier.SubInfo {
 
 	defer func() {
 		log_helper.GetLogger().Infoln(i, "DlSub End", seriesInfo.DirPath)
@@ -190,6 +191,35 @@ func OneSeriesDlSubInAllSite(Suppliers []ifaces.ISupplier, seriesInfo *series.Se
 	return outSUbInfos
 }
 
+// SetTheSpecifiedEps2Download 设置指定的 Eps 去下载,可以方便调试或者是后续新功能,能够手动指定 Eps 下载字幕
+func SetTheSpecifiedEps2Download(seriesInfo *series.SeriesInfo, epsMap map[int]int) {
+
+	seriesInfo.NeedDlSeasonDict = make(map[int]int, 0)
+	seriesInfo.SeasonDict = make(map[int]int, 0)
+
+	nowNeedDlEpsKeyList := make(map[string]series.EpisodeInfo, 0)
+	for needDownloadSeason, needDownloadEp := range epsMap {
+
+		// 选择某一集去下载
+		seriesInfo.NeedDlSeasonDict[needDownloadSeason] = needDownloadSeason
+		seriesInfo.SeasonDict[needDownloadSeason] = needDownloadSeason
+		tmp := series.EpisodeInfo{}
+		for _, value := range seriesInfo.NeedDlEpsKeyList {
+			if value.Season == needDownloadSeason && value.Episode == needDownloadEp {
+				tmp = value
+				// 缓存下来
+				nowNeedDlEpsKeyList[fmt.Sprintf("S%dE%d", needDownloadSeason, needDownloadEp)] = tmp
+				break
+			}
+		}
+	}
+	// 一次性写进去
+	seriesInfo.NeedDlEpsKeyList = make(map[string]series.EpisodeInfo, 0)
+	for s, info := range nowNeedDlEpsKeyList {
+		seriesInfo.NeedDlEpsKeyList[s] = info
+	}
+}
+
 // GetSeriesList 获取这个目录下的所有文件夹名称,默认为一个连续剧的目录的List
 func GetSeriesList(dir string) ([]string, error) {
 

+ 1 - 1
internal/logic/sub_supplier/subSupplierHub.go

@@ -143,7 +143,7 @@ func (d SubSupplierHub) DownloadSub4SeriesFromEmby(seriesDirPath string, seriesL
 
 func (d SubSupplierHub) dlSubFromSeriesInfo(seriesDirPath string, index int, seriesInfo *series.SeriesInfo, err error) (map[string][]string, error) {
 	// 下载好的字幕
-	subInfos := seriesHelper.OneSeriesDlSubInAllSite(d.Suppliers, seriesInfo, index)
+	subInfos := seriesHelper.DownloadSubtitleInAllSiteByOneSeries(d.Suppliers, seriesInfo, index)
 	// 整理字幕,比如解压什么的
 	// 每一集 SxEx - 对应解压整理后的字幕列表
 	organizeSubFiles, err := sub_helper.OrganizeDlSubFiles(filepath.Base(seriesDirPath), subInfos)

+ 8 - 1
internal/logic/sub_supplier/xunlei/xunlei.go

@@ -177,7 +177,14 @@ func (s Supplier) downloadSub4Series(seriesInfo *series.SeriesInfo) ([]supplier.
 	for _, episodeInfo := range seriesInfo.NeedDlEpsKeyList {
 		one, err := s.getSubListFromFile(episodeInfo.FileFullPath)
 		if err != nil {
-			s.log.Errorln(s.GetSupplierName(), "getSubListFromFile", episodeInfo.FileFullPath)
+			s.log.Errorln(s.GetSupplierName(), "getSubListFromFile", episodeInfo.Season, episodeInfo.Episode,
+				episodeInfo.FileFullPath)
+			continue
+		}
+		if one == nil {
+			// 没有搜索到字幕
+			s.log.Infoln(s.GetSupplierName(), "Not Find Sub can be download",
+				episodeInfo.Title, episodeInfo.Season, episodeInfo.Episode)
 			continue
 		}
 		// 需要赋值给字幕结构

+ 2 - 1
internal/logic/sub_supplier/xunlei/xunlei_test.go

@@ -12,7 +12,8 @@ func TestGetList(t *testing.T) {
 	//movie1 := "X:\\电影\\Spiral From the Book of Saw (2021)\\Spiral From the Book of Saw (2021) WEBDL-1080p.mkv"
 	//movie1 := "X:\\电影\\机动战士Z高达:星之继承者 (2005)\\机动战士Z高达:星之继承者 (2005) 1080p TrueHD.mkv"
 	//movie1 := "X:\\连续剧\\The Bad Batch\\Season 1\\The Bad Batch - S01E01 - Aftermath WEBDL-1080p.mkv"
-	movie1 := "X:\\连续剧\\黄石 (2018)\\Season 4\\Yellowstone (2018) - S04E05 - Under a Blanket of Red WEBDL-2160p.mkv"
+	//movie1 := "X:\\连续剧\\黄石 (2018)\\Season 4\\Yellowstone (2018) - S04E05 - Under a Blanket of Red WEBDL-2160p.mkv"
+	movie1 := "X:\\动漫\\碧蓝之海 (2018)\\Season 1\\碧蓝之海 - S01E01 - [UHA-WINGS][Grand Blue][01][BDRIP 1920x1080 x264 FLACx2].mkv"
 	xunlie := NewSupplier(types.ReqParam{Topic: 3})
 	outList, err := xunlie.getSubListFromFile(movie1)
 	if err != nil {

+ 2 - 1
internal/logic/sub_supplier/zimuku/zimuku.go

@@ -238,7 +238,8 @@ func (s Supplier) whichEpisodeNeedDownloadSub(seriesInfo *series.SeriesInfo, All
 			value[0].Episode = epsInfo.Episode
 			subInfoNeedDownload = append(subInfoNeedDownload, value[0])
 		} else {
-			s.log.Infoln("ZiMuKu Not Find Sub can be download", epsInfo.Title, epsInfo.Season, epsInfo.Episode)
+			s.log.Infoln(s.GetSupplierName(), "Not Find Sub can be download",
+				epsInfo.Title, epsInfo.Season, epsInfo.Episode)
 		}
 	}
 	// 全季的字幕列表,也拼进去,后面进行下载

+ 5 - 16
internal/logic/sub_supplier/zimuku/zimuku_test.go

@@ -52,22 +52,11 @@ func TestSupplier_GetSubListFromFile4Series(t *testing.T) {
 		t.Fatal(err)
 	}
 
-	// 选择某一集去下载
-	//const needDownloadSeason = 4
-	//const needDownloadEp = 5
-	//seriesInfo.NeedDlSeasonDict = make(map[int]int, 0)
-	//seriesInfo.SeasonDict = make(map[int]int, 0)
-	//seriesInfo.NeedDlSeasonDict[needDownloadSeason] = needDownloadSeason
-	//seriesInfo.SeasonDict[needDownloadSeason] = needDownloadSeason
-	//tmp := series.EpisodeInfo{}
-	//for _, value := range seriesInfo.NeedDlEpsKeyList {
-	//	if value.Season == needDownloadSeason && value.Episode == needDownloadEp {
-	//		tmp = value
-	//		break
-	//	}
-	//}
-	//seriesInfo.NeedDlEpsKeyList = make(map[string]series.EpisodeInfo, 0)
-	//seriesInfo.NeedDlEpsKeyList[fmt.Sprintf("S%dE%d", needDownloadSeason, needDownloadEp)] = tmp
+	// 可以指定几集去调试
+	epsMap := make(map[int]int, 0)
+	epsMap[4] = 5
+	epsMap[1] = 4
+	series_helper2.SetTheSpecifiedEps2Download(seriesInfo, epsMap)
 
 	s := NewSupplier()
 	outList, err := s.GetSubListFromFile4Series(seriesInfo)