Ver código fonte

修复,如果是正季下载的字幕也需要跟随有必要下载的季来判断,不然会一直触发替换字幕逻辑

Signed-off-by: 716 <[email protected]>
716 4 anos atrás
pai
commit
07da4b2470
2 arquivos alterados com 14 adições e 4 exclusões
  1. 5 0
      downloader.go
  2. 9 4
      model/sub_helper.go

+ 5 - 0
downloader.go

@@ -160,7 +160,12 @@ func (d Downloader) DownloadSub4Series(dir string) error {
 		// 这里会拿到一份季度字幕的列表比如,Key 是 S1E0 S2E0 S3E0,value 是新的存储位置
 		fullSeasonSubDict := d.saveFullSeasonSub(seriesInfo, organizeSubFiles)
 		// TODO 季度的字幕包,应该优先于零散的字幕吧,暂定就这样了,注意是全部都替换
+		// 需要与有下载需求的季交叉
 		for _, episodeInfo := range seriesInfo.EpList {
+			_, ok := seriesInfo.NeedDlSeasonDict[episodeInfo.Season]
+			if ok == false {
+				continue
+			}
 			// 匹配对应的 Eps 去处理
 			seasonEpsKey := model.GetEpisodeKeyName(episodeInfo.Season, episodeInfo.Episode)
 			d.oneVideoSelectBestSub(episodeInfo.FileFullPath, fullSeasonSubDict[seasonEpsKey])

+ 9 - 4
model/sub_helper.go

@@ -19,6 +19,10 @@ func OrganizeDlSubFiles(tmpFolderName string, subInfos []common.SupplierSubInfo)
 	if err != nil {
 		return nil, err
 	}
+
+	// 把后缀名给改好
+	ChangeVideoExt2SubExt(subInfos)
+
 	// 第三方的解压库,首先不支持 io.Reader 的操作,也就是得缓存到本地硬盘再读取解压
 	// 且使用 walk 会无法解压 rar,得指定具体的实例,太麻烦了,直接用通用的接口得了,就是得都缓存下来再判断
 	// 基于以上两点,写了一堆啰嗦的逻辑···
@@ -87,10 +91,11 @@ func OrganizeDlSubFiles(tmpFolderName string, subInfos []common.SupplierSubInfo)
 func ChangeVideoExt2SubExt(subInfos []common.SupplierSubInfo) {
 	for x, info := range subInfos {
 		tmpSubFileName := info.Name
-		if IsWantedVideoExtDef(tmpSubFileName) == false && IsWantedArchiveExtName(tmpSubFileName) == false {
-			if strings.Contains(tmpSubFileName, info.Ext) == false {
-				subInfos[x].Name = tmpSubFileName + info.Ext
-			}
+		// 如果后缀名是下载字幕目标的后缀名  或者 是压缩包格式的,则跳过
+		if strings.Contains(tmpSubFileName, info.Ext) == true || IsWantedArchiveExtName(tmpSubFileName) == true {
+
+		} else {
+			subInfos[x].Name = tmpSubFileName + info.Ext
 		}
 	}
 }