Browse Source

提高搜索的效率

Signed-off-by: 716 <[email protected]>
716 4 years ago
parent
commit
5fa919071c
4 changed files with 10 additions and 6 deletions
  1. 1 0
      common/seriesInfo.go
  2. 2 1
      downloader_test.go
  3. 6 4
      series_helper/seriesHelper.go
  4. 1 1
      sub_supplier/subhd/subhd.go

+ 1 - 0
common/seriesInfo.go

@@ -13,6 +13,7 @@ type SeriesInfo struct {
 	EpList           []EpisodeInfo
 	DirPath          string
 	SeasonDict       map[int]int
+	NeedDlSeasonDict map[int]int
 	NeedDlEpsKeyList map[string]EpisodeInfo		// SxEx
 }
 

+ 2 - 1
downloader_test.go

@@ -28,9 +28,10 @@ func TestDownloader_DownloadSub4Movie(t *testing.T) {
 func TestDownloader_DownloadSub4Series(t *testing.T) {
 	var err error
 	//dirRoot := "X:\\连续剧\\隐秘的角落 (2020)"
-	dirRoot := "X:\\连续剧\\The Bad Batch"
+	//dirRoot := "X:\\连续剧\\The Bad Batch"
 	//dirRoot := "X:\\连续剧\\Why Women Kill"
 	//dirRoot := "X:\\连续剧\\Mare of Easttown"
+	dirRoot := "X:\\连续剧\\瑞克和莫蒂 (2013)"
 	//dirRoot := "X:\\连续剧"
 
 	dl := NewDownloader(common.ReqParam{

+ 6 - 4
series_helper/seriesHelper.go

@@ -115,7 +115,7 @@ func ReadSeriesInfoFromDir(seriesDir string) (*common.SeriesInfo, error) {
 		seriesInfo.SeasonDict[episodeInfo.Season] = episodeInfo.Season
 	}
 
-	seriesInfo.NeedDlEpsKeyList = whichEpsNeedDownloadSub(&seriesInfo)
+	seriesInfo.NeedDlEpsKeyList, seriesInfo.NeedDlSeasonDict = whichSeasonEpsNeedDownloadSub(&seriesInfo)
 
 	return &seriesInfo, nil
 }
@@ -201,9 +201,10 @@ func GetSeriesList(dir string) ([]string, error) {
 	return seriesDirList, err
 }
 
-// whichEpsNeedDownloadSub 有那些 Eps 需要下载的,按 SxEx 反回 epsKey
-func whichEpsNeedDownloadSub(seriesInfo *common.SeriesInfo) map[string]common.EpisodeInfo {
+// whichSeasonEpsNeedDownloadSub 有那些 Eps 需要下载的,按 SxEx 反回 epsKey
+func whichSeasonEpsNeedDownloadSub(seriesInfo *common.SeriesInfo) (map[string]common.EpisodeInfo, map[int]int) {
 	var needDlSubEpsList = make(map[string]common.EpisodeInfo, 0)
+	var needDlSeasonList = make(map[int]int, 0)
 	currentTime := time.Now()
 	// 3个月
 	dayRange, _ := time.ParseDuration(common.DownloadSubDuring3Months)
@@ -214,6 +215,7 @@ func whichEpsNeedDownloadSub(seriesInfo *common.SeriesInfo) map[string]common.Ep
 			// 添加
 			epsKey := model.GetEpisodeKeyName(epsInfo.Season, epsInfo.Episode)
 			needDlSubEpsList[epsKey] = epsInfo
+			needDlSeasonList[epsInfo.Season] = epsInfo.Season
 		} else {
 			if len(epsInfo.SubAlreadyDownloadedList) > 0 {
 				model.GetLogger().Infoln("Skip because find sub file and over 3 months,", epsInfo.Title, epsInfo.Season, epsInfo.Episode)
@@ -222,5 +224,5 @@ func whichEpsNeedDownloadSub(seriesInfo *common.SeriesInfo) map[string]common.Ep
 			}
 		}
 	}
-	return needDlSubEpsList
+	return needDlSubEpsList, needDlSeasonList
 }

+ 1 - 1
sub_supplier/subhd/subhd.go

@@ -60,7 +60,7 @@ func (s Supplier) GetSubListFromFile4Series(seriesInfo *common.SeriesInfo) ([]co
 
 	var subInfos = make([]common.SupplierSubInfo, 0)
 	var subList = make([]HdListItem, 0)
-	for value := range seriesInfo.SeasonDict {
+	for value := range seriesInfo.NeedDlSeasonDict {
 		// 第一级界面,找到影片的详情界面
 		keyword := seriesInfo.Name + " 第" + zh.Uint64(value).String() + "季"
 		detailPageUrl, err := s.step0(keyword)