Browse Source

调整细节

Signed-off-by: allan716 <[email protected]>
allan716 4 years ago
parent
commit
d96e74c33d
4 changed files with 21 additions and 25 deletions
  1. 6 0
      downloader.go
  2. 0 10
      main.go
  3. 0 15
      model/language.go
  4. 15 0
      model/sub_helper.go

+ 6 - 0
downloader.go

@@ -67,8 +67,11 @@ func (d Downloader) DownloadSub4Movie(dir string) error {
 		}
 		// 注意并发 pool 的释放
 		defer ants.Release()
+
+		log.Infoln("Download Movie Sub End...")
 	}()
 
+	log.Infoln("Download Movie Sub Started...")
 	nowVideoList, err := model.SearchMatchedVideoFile(dir)
 	if err != nil {
 		return err
@@ -127,7 +130,10 @@ func (d Downloader) DownloadSub4Series(dir string) error {
 		}
 		// 注意并发 pool 的释放
 		defer ants.Release()
+
+		log.Infoln("Download Series Sub End...")
 	}()
+	log.Infoln("Download Series Sub Started...")
 
 	// 并发控制
 	seriesDlFunc := func(i interface{}) {

+ 0 - 10
main.go

@@ -60,22 +60,18 @@ func main() {
 		}()
 
 		log.Infoln("Download One Started...")
-		log.Infoln("Download Movie Sub Started...")
 		// 开始下载
 		err := downloader.DownloadSub4Movie(config.MovieFolder)
 		if err != nil {
 			log.Errorln("DownloadSub4Movie", err)
 			return
 		}
-		log.Infoln("Download Movie Sub End...")
 
-		log.Infoln("Download Series Sub Started...")
 		err = downloader.DownloadSub4Series(config.SeriesFolder)
 		if err != nil {
 			log.Errorln("DownloadSub4Series", err)
 			return
 		}
-		log.Infoln("Download Series Sub End...")
 	})
 	if err != nil {
 		log.Errorln("cron entryID:", entryID, "Error:", err)
@@ -85,22 +81,16 @@ func main() {
 	log.Infoln("First Time Download Start")
 	// 立即触发第一次的更新
 	// 开始下载
-	log.Infoln("Download Movie Sub Started...")
 	err = downloader.DownloadSub4Movie(config.MovieFolder)
 	if err != nil {
 		log.Errorln("DownloadSub4Movie", err)
 		return
 	}
-	log.Infoln("Download Movie Sub End...")
-
-	log.Infoln("Download Series Sub Started...")
 	err = downloader.DownloadSub4Series(config.SeriesFolder)
 	if err != nil {
 		log.Errorln("DownloadSub4Series", err)
 		return
 	}
-	log.Infoln("Download Series Sub End...")
-
 	log.Infoln("First Time Download End")
 
 	c.Start()

+ 0 - 15
model/language.go

@@ -354,21 +354,6 @@ func ChangeFileCoding2UTF8(inBytes []byte) ([]byte, error) {
 	return ouBytes, nil
 }
 
-// FindChineseBestSubtitle 找到合适的中文字幕,优先简体双语,简体->繁体,以及 字幕类型的优先级选择
-func FindChineseBestSubtitle(subs []common.SubParserFileInfo) *common.SubParserFileInfo {
-	for _, info := range subs {
-		// 找到了中文字幕
-		if HasChineseLang(info.Lang) == true {
-			// 优先双语
-			if IsBilingualSubtitle(info.Lang) == true {
-				return &info
-			}
-			return &info
-		}
-	}
-	return nil
-}
-
 var (
 	chDict = sat.DefaultDict()
 )

+ 15 - 0
model/sub_helper.go

@@ -98,4 +98,19 @@ func ChangeVideoExt2SubExt(subInfos []common.SupplierSubInfo) {
 			subInfos[x].Name = tmpSubFileName + info.Ext
 		}
 	}
+}
+
+// FindChineseBestSubtitle 找到合适的中文字幕,优先简体双语,简体->繁体,以及 字幕类型的优先级选择
+func FindChineseBestSubtitle(subs []common.SubParserFileInfo) *common.SubParserFileInfo {
+	for _, info := range subs {
+		// 找到了中文字幕
+		if HasChineseLang(info.Lang) == true {
+			// 优先双语
+			if IsBilingualSubtitle(info.Lang) == true {
+				return &info
+			}
+			return &info
+		}
+	}
+	return nil
 }