Browse Source

保存进度

Signed-off-by: allan716 <[email protected]>
allan716 3 years ago
parent
commit
7b771f4742

+ 6 - 6
internal/logic/movie_helper/moviehelper.go

@@ -8,9 +8,9 @@ import (
 	"github.com/allanpk716/ChineseSubFinder/internal/pkg/decode"
 	"github.com/allanpk716/ChineseSubFinder/internal/pkg/imdb_helper"
 	"github.com/allanpk716/ChineseSubFinder/internal/pkg/log_helper"
+	"github.com/allanpk716/ChineseSubFinder/internal/pkg/settings"
 	"github.com/allanpk716/ChineseSubFinder/internal/pkg/sub_helper"
 	"github.com/allanpk716/ChineseSubFinder/internal/pkg/sub_parser_hub"
-	"github.com/allanpk716/ChineseSubFinder/internal/types"
 	"github.com/allanpk716/ChineseSubFinder/internal/types/supplier"
 	"github.com/jinzhu/now"
 	"os"
@@ -111,17 +111,17 @@ func MovieHasChineseSub(videoFilePath string) (bool, []string, []string, error)
 }
 
 // SkipChineseMovie 跳过中文的电影
-func SkipChineseMovie(videoFullPath string, _reqParam ...types.ReqParam) (bool, error) {
+func SkipChineseMovie(videoFullPath string, _proxySettings ...settings.ProxySettings) (bool, error) {
 
-	var reqParam types.ReqParam
-	if len(_reqParam) > 0 {
-		reqParam = _reqParam[0]
+	var proxySettings settings.ProxySettings
+	if len(_proxySettings) > 0 {
+		proxySettings = _proxySettings[0]
 	}
 	imdbInfo, err := decode.GetImdbInfo4Movie(videoFullPath)
 	if err != nil {
 		return false, err
 	}
-	isChineseVideo, _, err := imdb_helper.IsChineseVideo(imdbInfo.ImdbId, reqParam)
+	isChineseVideo, _, err := imdb_helper.IsChineseVideo(imdbInfo.ImdbId, proxySettings)
 	if err != nil {
 		return false, err
 	}

+ 1 - 0
internal/logic/pre_download_process/pre_download_proces.go

@@ -75,6 +75,7 @@ func (p *PreDownloadProcess) Init() *PreDownloadProcess {
 	// ------------------------------------------------------------------------
 	// 构建每个字幕站点下载者的实例
 	p.subSupplierHub = subSupplier.NewSubSupplierHub(
+		*settings.GetSettings(),
 		zimuku.NewSupplier(*settings.GetSettings()),
 		xunlei.NewSupplier(*settings.GetSettings()),
 		shooter.NewSupplier(*settings.GetSettings()),

+ 6 - 6
internal/logic/series_helper/seriesHelper.go

@@ -11,9 +11,9 @@ import (
 	"github.com/allanpk716/ChineseSubFinder/internal/pkg/imdb_helper"
 	"github.com/allanpk716/ChineseSubFinder/internal/pkg/log_helper"
 	"github.com/allanpk716/ChineseSubFinder/internal/pkg/my_util"
+	"github.com/allanpk716/ChineseSubFinder/internal/pkg/settings"
 	"github.com/allanpk716/ChineseSubFinder/internal/pkg/sub_helper"
 	"github.com/allanpk716/ChineseSubFinder/internal/pkg/sub_parser_hub"
-	"github.com/allanpk716/ChineseSubFinder/internal/types"
 	"github.com/allanpk716/ChineseSubFinder/internal/types/emby"
 	"github.com/allanpk716/ChineseSubFinder/internal/types/series"
 	"github.com/allanpk716/ChineseSubFinder/internal/types/supplier"
@@ -123,17 +123,17 @@ func ReadSeriesInfoFromEmby(seriesDir string, imdbInfo *imdb.Title, seriesList [
 }
 
 // SkipChineseSeries 跳过中文连续剧
-func SkipChineseSeries(seriesRootPath string, _reqParam ...types.ReqParam) (bool, *imdb.Title, error) {
-	var reqParam types.ReqParam
-	if len(_reqParam) > 0 {
-		reqParam = _reqParam[0]
+func SkipChineseSeries(seriesRootPath string, _proxySettings ...settings.ProxySettings) (bool, *imdb.Title, error) {
+	var proxySettings settings.ProxySettings
+	if len(_proxySettings) > 0 {
+		proxySettings = _proxySettings[0]
 	}
 	imdbInfo, err := decode.GetImdbInfo4SeriesDir(seriesRootPath)
 	if err != nil {
 		return false, nil, err
 	}
 
-	isChineseVideo, t, err := imdb_helper.IsChineseVideo(imdbInfo.ImdbId, reqParam)
+	isChineseVideo, t, err := imdb_helper.IsChineseVideo(imdbInfo.ImdbId, proxySettings)
 	if err != nil {
 		return false, nil, err
 	}

+ 8 - 4
internal/logic/sub_supplier/subSupplierHub.go

@@ -7,6 +7,7 @@ import (
 	seriesHelper "github.com/allanpk716/ChineseSubFinder/internal/logic/series_helper"
 	"github.com/allanpk716/ChineseSubFinder/internal/pkg/log_helper"
 	"github.com/allanpk716/ChineseSubFinder/internal/pkg/my_util"
+	"github.com/allanpk716/ChineseSubFinder/internal/pkg/settings"
 	"github.com/allanpk716/ChineseSubFinder/internal/pkg/sub_helper"
 	"github.com/allanpk716/ChineseSubFinder/internal/types/emby"
 	"github.com/allanpk716/ChineseSubFinder/internal/types/series"
@@ -16,13 +17,16 @@ import (
 )
 
 type SubSupplierHub struct {
+	settings settings.Settings
+
 	Suppliers []ifaces.ISupplier
 
 	log *logrus.Logger
 }
 
-func NewSubSupplierHub(one ifaces.ISupplier, _inSupplier ...ifaces.ISupplier) *SubSupplierHub {
+func NewSubSupplierHub(_settings settings.Settings, one ifaces.ISupplier, _inSupplier ...ifaces.ISupplier) *SubSupplierHub {
 	s := SubSupplierHub{}
+	s.settings = _settings
 	s.log = log_helper.GetLogger()
 	s.Suppliers = make([]ifaces.ISupplier, 0)
 	s.Suppliers = append(s.Suppliers, one)
@@ -53,7 +57,7 @@ func (d SubSupplierHub) DownloadSub4Movie(videoFullPath string, index int, force
 	}
 
 	// 跳过中文的电影,不是一定要跳过的
-	skip, err := movieHelper.SkipChineseMovie(videoFullPath, d.Suppliers[0].GetReqParam())
+	skip, err := movieHelper.SkipChineseMovie(videoFullPath, *d.settings.AdvancedSettings.ProxySettings)
 	if err != nil {
 		d.log.Warnln("SkipChineseMovie", videoFullPath, err)
 	}
@@ -109,7 +113,7 @@ func (d SubSupplierHub) DownloadSub4Series(seriesDirPath string, index int, forc
 	}
 
 	// 跳过中文的连续剧,不是一定要跳过的
-	skip, imdbInfo, err := seriesHelper.SkipChineseSeries(seriesDirPath, d.Suppliers[0].GetReqParam())
+	skip, imdbInfo, err := seriesHelper.SkipChineseSeries(seriesDirPath, *d.settings.AdvancedSettings.ProxySettings)
 	if err != nil {
 		d.log.Warnln("SkipChineseSeries", seriesDirPath, err)
 	}
@@ -132,7 +136,7 @@ func (d SubSupplierHub) DownloadSub4Series(seriesDirPath string, index int, forc
 func (d SubSupplierHub) DownloadSub4SeriesFromEmby(seriesDirPath string, seriesList []emby.EmbyMixInfo, index int) (*series.SeriesInfo, map[string][]string, error) {
 
 	// 跳过中文的连续剧,不是一定要跳过的
-	skip, imdbInfo, err := seriesHelper.SkipChineseSeries(seriesDirPath, d.Suppliers[0].GetReqParam())
+	skip, imdbInfo, err := seriesHelper.SkipChineseSeries(seriesDirPath, *d.settings.AdvancedSettings.ProxySettings)
 	if err != nil {
 		d.log.Warnln("SkipChineseSeries", seriesDirPath, err)
 	}

+ 11 - 11
internal/pkg/imdb_helper/imdb.go

@@ -4,17 +4,17 @@ import (
 	"github.com/StalkR/imdb"
 	"github.com/allanpk716/ChineseSubFinder/internal/pkg/my_util"
 	"github.com/allanpk716/ChineseSubFinder/internal/pkg/notify_center"
-	"github.com/allanpk716/ChineseSubFinder/internal/types"
+	"github.com/allanpk716/ChineseSubFinder/internal/pkg/settings"
 	"strings"
 )
 
 // GetVideoInfoFromIMDB 从 IMDB ID 查询影片的信息
-func GetVideoInfoFromIMDB(imdbID string, _reqParam ...types.ReqParam) (*imdb.Title, error) {
-	var reqParam types.ReqParam
-	if len(_reqParam) > 0 {
-		reqParam = _reqParam[0]
+func GetVideoInfoFromIMDB(imdbID string, _proxySettings ...settings.ProxySettings) (*imdb.Title, error) {
+	var proxySettings settings.ProxySettings
+	if len(_proxySettings) > 0 {
+		proxySettings = _proxySettings[0]
 	}
-	t, err := imdb.NewTitle(my_util.NewHttpClient(reqParam).GetClient(), imdbID)
+	t, err := imdb.NewTitle(my_util.NewHttpClient(proxySettings).GetClient(), imdbID)
 	if err != nil {
 		notify_center.Notify.Add("imdb model - imdb.NewTitle :", err.Error())
 		return nil, err
@@ -24,17 +24,17 @@ func GetVideoInfoFromIMDB(imdbID string, _reqParam ...types.ReqParam) (*imdb.Tit
 }
 
 // IsChineseVideo 从 imdbID 去查询判断是否是中文视频
-func IsChineseVideo(imdbID string, _reqParam ...types.ReqParam) (bool, *imdb.Title, error) {
+func IsChineseVideo(imdbID string, _proxySettings ...settings.ProxySettings) (bool, *imdb.Title, error) {
 
 	const chName0 = "chinese"
 	const chName1 = "mandarin"
 
-	var reqParam types.ReqParam
-	if len(_reqParam) > 0 {
-		reqParam = _reqParam[0]
+	var proxySettings settings.ProxySettings
+	if len(_proxySettings) > 0 {
+		proxySettings = _proxySettings[0]
 	}
 
-	t, err := GetVideoInfoFromIMDB(imdbID, reqParam)
+	t, err := GetVideoInfoFromIMDB(imdbID, proxySettings)
 	if err != nil {
 		return false, nil, err
 	}