瀏覽代碼

调整细节

Signed-off-by: allan716 <[email protected]>
allan716 3 年之前
父節點
當前提交
bf5cb8160a

+ 4 - 6
internal/logic/pre_download_process/pre_download_proces.go

@@ -125,22 +125,20 @@ func (p *PreDownloadProcess) Check() *PreDownloadProcess {
 	if settings.GetSettings().AdvancedSettings.ProxySettings.UseHttpProxy == false {
 
 		log_helper.GetLogger().Infoln("UseHttpProxy = false")
-		// 如果不使用代理,那么默认需要检测 baidu 的连通性
+		// 如果不使用代理,那么默认需要检测 baidu 的连通性,不通过也继续
 		proxyStatus, proxySpeed, err := url_connectedness_helper.UrlConnectednessTest(url_connectedness_helper.BaiduUrl, "")
 		if err != nil {
-			p.gError = errors.New("UrlConnectednessTest Target Site " + url_connectedness_helper.BaiduUrl + ", " + err.Error())
-			return p
+			log_helper.GetLogger().Errorln(errors.New("UrlConnectednessTest Target Site " + url_connectedness_helper.BaiduUrl + ", " + err.Error()))
 		} else {
 			log_helper.GetLogger().Infoln("UrlConnectednessTest Target Site", url_connectedness_helper.BaiduUrl, "Speed:", proxySpeed, "ms,", "Status:", proxyStatus)
 		}
 	} else {
 
 		log_helper.GetLogger().Infoln("UseHttpProxy:", settings.GetSettings().AdvancedSettings.ProxySettings.HttpProxyAddress)
-		// 如果使用了代理,那么默认需要检测 google 的连通性
+		// 如果使用了代理,那么默认需要检测 google 的连通性,不通过也继续
 		proxyStatus, proxySpeed, err := url_connectedness_helper.UrlConnectednessTest(url_connectedness_helper.GoogleUrl, settings.GetSettings().AdvancedSettings.ProxySettings.HttpProxyAddress)
 		if err != nil {
-			p.gError = errors.New("UrlConnectednessTest Target Site " + url_connectedness_helper.GoogleUrl + ", " + err.Error())
-			return p
+			log_helper.GetLogger().Errorln(errors.New("UrlConnectednessTest Target Site " + url_connectedness_helper.GoogleUrl + ", " + err.Error()))
 		} else {
 			log_helper.GetLogger().Infoln("UrlConnectednessTest Target Site", url_connectedness_helper.GoogleUrl, "Speed:", proxySpeed, "ms,", "Status:", proxyStatus)
 		}

+ 8 - 0
internal/logic/sub_supplier/shooter/shooter.go

@@ -4,6 +4,7 @@ import (
 	"crypto/md5"
 	"fmt"
 	"github.com/allanpk716/ChineseSubFinder/internal/common"
+	pkgcommon "github.com/allanpk716/ChineseSubFinder/internal/pkg/common"
 	"github.com/allanpk716/ChineseSubFinder/internal/pkg/log_helper"
 	"github.com/allanpk716/ChineseSubFinder/internal/pkg/my_util"
 	"github.com/allanpk716/ChineseSubFinder/internal/pkg/notify_center"
@@ -187,8 +188,15 @@ func (s Supplier) computeFileHash(filePath string) (string, error) {
 
 func (s Supplier) downloadSub4Series(seriesInfo *series.SeriesInfo) ([]supplier.SubInfo, error) {
 	var allSupplierSubInfo = make([]supplier.SubInfo, 0)
+
+	index := 0
 	// 这里拿到的 seriesInfo ,里面包含了,需要下载字幕的 Eps 信息
 	for _, episodeInfo := range seriesInfo.NeedDlEpsKeyList {
+
+		index++
+		pkgcommon.SetSubScanJobStatusScanSeriesSub(index, len(seriesInfo.NeedDlEpsKeyList),
+			fmt.Sprintf("%v - S%v-E%v", episodeInfo.Title, episodeInfo.Season, episodeInfo.Episode))
+
 		one, err := s.getSubListFromFile(episodeInfo.FileFullPath)
 		if err != nil {
 			s.log.Errorln(s.GetSupplierName(), "getSubListFromFile", episodeInfo.FileFullPath)

+ 5 - 0
internal/logic/sub_supplier/subhd/subhd.go

@@ -6,6 +6,7 @@ import (
 	"github.com/PuerkitoBio/goquery"
 	"github.com/Tnze/go.num/v2/zh"
 	"github.com/allanpk716/ChineseSubFinder/internal/common"
+	pkgcommon "github.com/allanpk716/ChineseSubFinder/internal/pkg/common"
 	"github.com/allanpk716/ChineseSubFinder/internal/pkg/decode"
 	"github.com/allanpk716/ChineseSubFinder/internal/pkg/global_value"
 	"github.com/allanpk716/ChineseSubFinder/internal/pkg/log_helper"
@@ -143,6 +144,10 @@ func (s Supplier) GetSubListFromFile4Series(seriesInfo *series.SeriesInfo) ([]su
 	subInfoNeedDownload := s.whichEpisodeNeedDownloadSub(seriesInfo, subList)
 	// 下载字幕
 	for i, item := range subInfoNeedDownload {
+
+		pkgcommon.SetSubScanJobStatusScanSeriesSub(i+1, len(seriesInfo.NeedDlEpsKeyList),
+			fmt.Sprintf("%v - S%v-E%v", item.Title, item.Season, item.Episode))
+
 		bok, hdContent, err := s.step2Ex(browser, item.Url)
 		if err != nil {
 			s.log.Errorln("subhd step2Ex", err)

+ 7 - 0
internal/logic/sub_supplier/xunlei/xunlei.go

@@ -4,6 +4,7 @@ import (
 	"crypto/sha1"
 	"fmt"
 	"github.com/allanpk716/ChineseSubFinder/internal/common"
+	pkgcommon "github.com/allanpk716/ChineseSubFinder/internal/pkg/common"
 	"github.com/allanpk716/ChineseSubFinder/internal/pkg/language"
 	"github.com/allanpk716/ChineseSubFinder/internal/pkg/log_helper"
 	"github.com/allanpk716/ChineseSubFinder/internal/pkg/my_util"
@@ -200,8 +201,14 @@ func (s Supplier) getCid(filePath string) (string, error) {
 
 func (s Supplier) downloadSub4Series(seriesInfo *series.SeriesInfo) ([]supplier.SubInfo, error) {
 	var allSupplierSubInfo = make([]supplier.SubInfo, 0)
+	index := 0
 	// 这里拿到的 seriesInfo ,里面包含了,需要下载字幕的 Eps 信息
 	for _, episodeInfo := range seriesInfo.NeedDlEpsKeyList {
+
+		index++
+		pkgcommon.SetSubScanJobStatusScanSeriesSub(index, len(seriesInfo.NeedDlEpsKeyList),
+			fmt.Sprintf("%v - S%v-E%v", episodeInfo.Title, episodeInfo.Season, episodeInfo.Episode))
+
 		one, err := s.getSubListFromFile(episodeInfo.FileFullPath)
 		if err != nil {
 			s.log.Errorln(s.GetSupplierName(), "getSubListFromFile", episodeInfo.Season, episodeInfo.Episode,

+ 5 - 0
internal/logic/sub_supplier/zimuku/zimuku.go

@@ -5,6 +5,7 @@ import (
 	"github.com/PuerkitoBio/goquery"
 	"github.com/Tnze/go.num/v2/zh"
 	"github.com/allanpk716/ChineseSubFinder/internal/common"
+	pkgcommon "github.com/allanpk716/ChineseSubFinder/internal/pkg/common"
 	"github.com/allanpk716/ChineseSubFinder/internal/pkg/decode"
 	"github.com/allanpk716/ChineseSubFinder/internal/pkg/language"
 	"github.com/allanpk716/ChineseSubFinder/internal/pkg/log_helper"
@@ -290,6 +291,10 @@ func (s Supplier) whichSubInfoNeedDownload(subInfos SubInfos, err error) []suppl
 
 	var outSubInfoList = make([]supplier.SubInfo, 0)
 	for i := range subInfos {
+
+		pkgcommon.SetSubScanJobStatusScanSeriesSub(i+1, len(subInfos),
+			fmt.Sprintf("%v - S%v-E%v", subInfos[i].Name, subInfos[i].Season, subInfos[i].Episode))
+
 		err = s.step2(&subInfos[i])
 		if err != nil {
 			s.log.Error(s.GetSupplierName(), "step 2", subInfos[i].Name, err)

+ 33 - 0
internal/pkg/common/global_value.go

@@ -71,6 +71,39 @@ func SetSubScanJobStatusScanSeriesMain(WorkingUnitIndex, UnitCount int, WorkingU
 	subDownloadJobInfo.UnitCount = UnitCount
 	subDownloadJobInfo.WorkingUnitName = WorkingUnitName
 
+	subDownloadJobInfo.WorkingVideoIndex = 0
+	subDownloadJobInfo.VideoCount = 0
+	subDownloadJobInfo.WorkingVideoName = ""
+
+	subDownloadJobInfoLock.Unlock()
+}
+
+// SetSubScanJobStatusScanSeriesSub 设置扫描字幕任务的状态为运行
+func SetSubScanJobStatusScanSeriesSub(WorkingVideoIndex, VideoCount int, WorkingVideoName string) {
+
+	subDownloadJobInfoLock.Lock()
+
+	if subDownloadJobInfo == nil {
+		subDownloadJobInfo = &ws.SubDownloadJobInfo{}
+	}
+	subDownloadJobInfo.Status = ws.ScanSeries
+	update := false
+	// 因为这里不同于movie的逻辑,movie 是在字幕下载者之前进行的统计更新
+	// 而对应 series 则是进入到具体的一个下载者中进行的任务进度更新,所以需要考虑并发情况,以最大值来更新
+	if subDownloadJobInfo.WorkingVideoIndex < WorkingVideoIndex {
+		subDownloadJobInfo.WorkingVideoIndex = WorkingVideoIndex
+		update = true
+	}
+
+	if subDownloadJobInfo.VideoCount < VideoCount {
+		subDownloadJobInfo.VideoCount = VideoCount
+		update = true
+	}
+
+	if update == true {
+		subDownloadJobInfo.WorkingVideoName = WorkingVideoName
+	}
+
 	subDownloadJobInfoLock.Unlock()
 }
 

+ 8 - 5
internal/types/backend/ws/sub_download_jobs_info.go

@@ -1,9 +1,12 @@
 package ws
 
 type SubDownloadJobInfo struct {
-	Status           string `json:"status"`             // "running", "waiting",不是运行中,就是等待中
-	StartedTime      string `json:"started_time"`       // 任务开始的时间
-	WorkingUnitIndex int    `json:"working_unit_index"` // 正在处理到第几部电影或者连续剧
-	UnitCount        int    `json:"unit_count"`         // 一共有多少部电影或者连续剧
-	WorkingUnitName  string `json:"working_unit_name"`  // 电影名称,或者连续剧的名称
+	Status            string `json:"status"`              // "running", "waiting",不是运行中,就是等待中
+	StartedTime       string `json:"started_time"`        // 任务开始的时间
+	WorkingUnitIndex  int    `json:"working_unit_index"`  // 正在处理到第几部电影或者连续剧
+	UnitCount         int    `json:"unit_count"`          // 一共有多少部电影或者连续剧
+	WorkingUnitName   string `json:"working_unit_name"`   // 电影名称,或者连续剧的名称
+	WorkingVideoIndex int    `json:"working_video_index"` // 正在处理到第几个视频
+	VideoCount        int    `json:"video_count"`         // 一共有几个视频
+	WorkingVideoName  string `json:"working_video_name"`  // 正在处理到第几个视频的名称
 }