Browse Source

一部电影和一集连续剧的下载,调整为一次去一个字幕提供站点下载,降低资源消耗

Signed-off-by: 716 <[email protected]>
716 3 years ago
parent
commit
4de5107cf6
2 changed files with 72 additions and 38 deletions
  1. 29 15
      internal/logic/movie_helper/moviehelper.go
  2. 43 23
      internal/logic/series_helper/seriesHelper.go

+ 29 - 15
internal/logic/movie_helper/moviehelper.go

@@ -27,24 +27,38 @@ func OneMovieDlSubInAllSite(Suppliers []ifaces.ISupplier, oneVideoFullPath strin
 	}()
 
 	var outSUbInfos = make([]supplier.SubInfo, 0)
-	// 同时进行查询
-	subInfosChannel := make(chan []supplier.SubInfo)
+	// TODO 资源占用较高,把这里的并发给取消
+	//// 同时进行查询
+	//subInfosChannel := make(chan []supplier.SubInfo)
+	//log_helper.GetLogger().Infoln(common.QueueName, i, "DlSub Start", oneVideoFullPath)
+	//for _, oneSupplier := range Suppliers {
+	//	nowSupplier := oneSupplier
+	//	go func() {
+	//		subInfos, err := OneMovieDlSubInOneSite(oneVideoFullPath, i, nowSupplier)
+	//		if err != nil {
+	//			log_helper.GetLogger().Errorln(common.QueueName, i, nowSupplier.GetSupplierName(), "oneMovieDlSubInOneSite", err)
+	//		}
+	//		subInfosChannel <- subInfos
+	//	}()
+	//}
+	//for index := 0; index < len(Suppliers); index++ {
+	//	v, ok := <-subInfosChannel
+	//	if ok == true && v != nil {
+	//		outSUbInfos = append(outSUbInfos, v...)
+	//	}
+	//}
+
 	log_helper.GetLogger().Infoln(common.QueueName, i, "DlSub Start", oneVideoFullPath)
 	for _, oneSupplier := range Suppliers {
-		nowSupplier := oneSupplier
-		go func() {
-			subInfos, err := OneMovieDlSubInOneSite(oneVideoFullPath, i, nowSupplier)
-			if err != nil {
-				log_helper.GetLogger().Errorln(common.QueueName, i, nowSupplier.GetSupplierName(), "oneMovieDlSubInOneSite", err)
-			}
-			subInfosChannel <- subInfos
-		}()
-	}
-	for index := 0; index < len(Suppliers); index++ {
-		v, ok := <-subInfosChannel
-		if ok == true && v != nil {
-			outSUbInfos = append(outSUbInfos, v...)
+
+		log_helper.GetLogger().Infoln(common.QueueName, i, oneSupplier.GetSupplierName(), oneVideoFullPath)
+
+		subInfos, err := OneMovieDlSubInOneSite(oneVideoFullPath, i, oneSupplier)
+		if err != nil {
+			log_helper.GetLogger().Errorln(common.QueueName, i, oneSupplier.GetSupplierName(), "oneMovieDlSubInOneSite", err)
+			continue
 		}
+		outSUbInfos = append(outSUbInfos, subInfos...)
 	}
 
 	for index, info := range outSUbInfos {

+ 43 - 23
internal/logic/series_helper/seriesHelper.go

@@ -159,32 +159,52 @@ func DownloadSubtitleInAllSiteByOneSeries(Suppliers []ifaces.ISupplier, seriesIn
 	for key := range seriesInfo.NeedDlEpsKeyList {
 		log_helper.GetLogger().Infoln(common.QueueName, i, seriesInfo.Name, "-", key)
 	}
+	// TODO 资源占用较高,把这里的并发给取消
 	// 同时进行查询
-	subInfosChannel := make(chan []supplier.SubInfo)
+	//subInfosChannel := make(chan []supplier.SubInfo)
+	//for _, oneSupplier := range Suppliers {
+	//	nowSupplier := oneSupplier
+	//	go func() {
+	//		var subInfos []supplier.SubInfo
+	//		defer func() {
+	//			subInfosChannel <- subInfos
+	//			log_helper.GetLogger().Infoln(common.QueueName, i, nowSupplier.GetSupplierName(), "End...")
+	//		}()
+	//
+	//		log_helper.GetLogger().Infoln(common.QueueName, i, nowSupplier.GetSupplierName(), "Start...")
+	//		// 一次性把这一部连续剧的所有字幕下载完
+	//		subInfos, err := nowSupplier.GetSubListFromFile4Series(seriesInfo)
+	//		if err != nil {
+	//			log_helper.GetLogger().Errorln(common.QueueName, i, nowSupplier.GetSupplierName(), "GetSubListFromFile4Series", err)
+	//		}
+	//		// 把后缀名给改好
+	//		sub_helper.ChangeVideoExt2SubExt(subInfos)
+	//	}()
+	//}
+	//for i := 0; i < len(Suppliers); i++ {
+	//	v, ok := <-subInfosChannel
+	//	if ok == true && v != nil {
+	//		outSUbInfos = append(outSUbInfos, v...)
+	//	}
+	//}
+
 	for _, oneSupplier := range Suppliers {
-		nowSupplier := oneSupplier
-		go func() {
-			var subInfos []supplier.SubInfo
-			defer func() {
-				subInfosChannel <- subInfos
-				log_helper.GetLogger().Infoln(common.QueueName, i, nowSupplier.GetSupplierName(), "End...")
-			}()
-
-			log_helper.GetLogger().Infoln(common.QueueName, i, nowSupplier.GetSupplierName(), "Start...")
-			// 一次性把这一部连续剧的所有字幕下载完
-			subInfos, err := nowSupplier.GetSubListFromFile4Series(seriesInfo)
-			if err != nil {
-				log_helper.GetLogger().Errorln(common.QueueName, i, nowSupplier.GetSupplierName(), "GetSubListFromFile4Series", err)
-			}
-			// 把后缀名给改好
-			sub_helper.ChangeVideoExt2SubExt(subInfos)
-		}()
-	}
-	for i := 0; i < len(Suppliers); i++ {
-		v, ok := <-subInfosChannel
-		if ok == true && v != nil {
-			outSUbInfos = append(outSUbInfos, v...)
+
+		var subInfos []supplier.SubInfo
+		log_helper.GetLogger().Infoln(common.QueueName, i, oneSupplier.GetSupplierName(), "Start...")
+		// 一次性把这一部连续剧的所有字幕下载完
+		subInfos, err := oneSupplier.GetSubListFromFile4Series(seriesInfo)
+		if err != nil {
+			log_helper.GetLogger().Errorln(common.QueueName, i, oneSupplier.GetSupplierName(), "GetSubListFromFile4Series", err)
+			log_helper.GetLogger().Infoln(common.QueueName, i, oneSupplier.GetSupplierName(), "End")
+			continue
 		}
+		// 把后缀名给改好
+		sub_helper.ChangeVideoExt2SubExt(subInfos)
+
+		outSUbInfos = append(outSUbInfos, subInfos...)
+
+		log_helper.GetLogger().Infoln(common.QueueName, i, oneSupplier.GetSupplierName(), "End")
 	}
 
 	return outSUbInfos