Browse Source

正在添加连续剧的搜索功能

Signed-off-by: 716 <[email protected]>
716 4 years ago
parent
commit
0f4fa63596

+ 2 - 2
downloader.go

@@ -75,7 +75,7 @@ func (d Downloader) GetDefSupportExtList() []string {
 	return d.defExtList
 }
 
-func (d Downloader) DownloadSub(dir string) error {
+func (d Downloader) DownloadSub4Movie(dir string) error {
 	defer func() {
 		// 抉择完毕,需要清理缓存目录
 		err := model.ClearTmpFolder()
@@ -109,7 +109,7 @@ func (d Downloader) DownloadSub(dir string) error {
 		// 字幕都下载缓存好了,需要抉择存哪一个,优先选择中文双语的,然后到中文
 		organizeSubFiles, err := subSupplierHub.DownloadSub(oneVideoFullPath, i, d.reqParam.FoundExistSubFileThanSkip)
 		if err != nil {
-			d.log.Errorln("subSupplierHub.DownloadSub", oneVideoFullPath ,err)
+			d.log.Errorln("subSupplierHub.DownloadSub4Movie", oneVideoFullPath ,err)
 			continue
 		}
 		// 得到目标视频文件的根目录

+ 1 - 1
downloader_test.go

@@ -35,7 +35,7 @@ func TestDownloader_DownloadSub(t *testing.T) {
 	dl := NewDownloader(common.ReqParam{
 		SaveMultiSub: true,
 	})
-	err = dl.DownloadSub(dirRoot)
+	err = dl.DownloadSub4Movie(dirRoot)
 	if err != nil {
 		t.Fatal(err)
 	}

+ 7 - 4
interface/iSupplier.go

@@ -3,12 +3,15 @@ package _interface
 import "github.com/allanpk716/ChineseSubFinder/common"
 
 type ISupplier interface {
-	// TODO 这里需要考虑是什么类型的视频文件,可能是 电影、连续剧、动画,这三类应该有细节上的差异
-	// 比如,连续剧,有按季下载整个季字幕包,也可能是每一季的每一集下载一个
-	// 电影则可以直接用 IMDB 直接下载或者削刮后的文件名去下载
-	// 动画,嗯···还没啥经验,额外粗略看来,很多坑
+
 	GetSupplierName() string
 
+	GetSubListFromFile4Movie(filePath string) ([]common.SupplierSubInfo, error)
+
+	GetSubListFromFile4Series(filePath string) ([]common.SupplierSubInfo, error)
+	
+	GetSubListFromFile4Anime(filePath string) ([]common.SupplierSubInfo, error)
+
 	GetSubListFromFile(filePath string) ([]common.SupplierSubInfo, error)
 
 	GetSubListFromKeyword(keyword string) ([]common.SupplierSubInfo, error)

+ 4 - 4
main.go

@@ -58,9 +58,9 @@ func main() {
 	// 定时器
 	entryID, err := c.AddFunc("@every " + config.EveryTime, func() {
 		// 开始下载
-		err := downloader.DownloadSub(config.MovieFolder)
+		err := downloader.DownloadSub4Movie(config.MovieFolder)
 		if err != nil {
-			log.Errorln("DownloadSub", err)
+			log.Errorln("DownloadSub4Movie", err)
 			return
 		}
 	})
@@ -71,9 +71,9 @@ func main() {
 	log.Infoln("First Time Download Start")
 	// 立即触发第一次的更新
 	// 开始下载
-	err = downloader.DownloadSub(config.MovieFolder)
+	err = downloader.DownloadSub4Movie(config.MovieFolder)
 	if err != nil {
-		log.Errorln("DownloadSub", err)
+		log.Errorln("DownloadSub4Movie", err)
 		return
 	}
 	log.Infoln("First Time Download End")

+ 12 - 0
sub_supplier/shooter/shooter.go

@@ -36,6 +36,18 @@ func (s Supplier) GetSupplierName() string {
 	return common.SubSiteShooter
 }
 
+func (s Supplier) GetSubListFromFile4Movie(filePath string) ([]common.SupplierSubInfo, error){
+	return s.GetSubListFromFile(filePath)
+}
+
+func (s Supplier) GetSubListFromFile4Series(filePath string) ([]common.SupplierSubInfo, error) {
+	return s.GetSubListFromFile(filePath)
+}
+
+func (s Supplier) GetSubListFromFile4Anime(filePath string) ([]common.SupplierSubInfo, error){
+	return s.GetSubListFromFile(filePath)
+}
+
 func (s Supplier) GetSubListFromFile(filePath string) ([]common.SupplierSubInfo, error) {
 
 	// 可以提供的字幕查询 eng或者chn

+ 2 - 2
sub_supplier/shooter/shooter_test.go

@@ -6,11 +6,11 @@ import (
 )
 
 func TestNewSupplier(t *testing.T) {
-	movie1 := "X:\\电影\\The Devil All the Time (2020)\\The Devil All the Time (2020) WEBDL-1080p.mkv"
+	//movie1 := "X:\\电影\\The Devil All the Time (2020)\\The Devil All the Time (2020) WEBDL-1080p.mkv"
 	//movie1 := "X:\\电影\\龙猫 (1988)\\龙猫 (1988) 1080p DTS.mkv"
 	//movie1 := "X:\\电影\\消失爱人 (2016)\\消失爱人 (2016) 720p AAC.rmvb"
 	//movie1 := "X:\\电影\\机动战士Z高达:星之继承者 (2005)\\机动战士Z高达:星之继承者 (2005) 1080p TrueHD.mkv"
-	//movie1 := "X:\\连续剧\\The Bad Batch\\Season 1\\The Bad Batch - S01E01 - Aftermath WEBDL-1080p.mkv"
+	movie1 := "X:\\连续剧\\The Bad Batch\\Season 1\\The Bad Batch - S01E01 - Aftermath WEBDL-1080p.mkv"
 	shooter := NewSupplier(common.ReqParam{Topic: 3})
 	outList, err := shooter.GetSubListFromFile(movie1)
 	if err != nil {

+ 13 - 1
sub_supplier/subhd/subhd.go

@@ -26,7 +26,7 @@ type Supplier struct {
 	reqParam    common.ReqParam
 	log         *logrus.Logger
 	topic       int
-	rodlauncher *launcher.Launcher
+	rodLauncher *launcher.Launcher
 }
 
 func NewSupplier(_reqParam ...common.ReqParam) *Supplier {
@@ -47,6 +47,18 @@ func (s Supplier) GetSupplierName() string {
 	return common.SubSiteSubHd
 }
 
+func (s Supplier) GetSubListFromFile4Movie(filePath string) ([]common.SupplierSubInfo, error){
+	return s.GetSubListFromFile(filePath)
+}
+
+func (s Supplier) GetSubListFromFile4Series(filePath string) ([]common.SupplierSubInfo, error) {
+
+}
+
+func (s Supplier) GetSubListFromFile4Anime(filePath string) ([]common.SupplierSubInfo, error){
+
+}
+
 func (s Supplier) GetSubListFromFile(filePath string) ([]common.SupplierSubInfo, error) {
 	/*
 		虽然是传入视频文件路径,但是其实需要读取对应的视频文件目录下的

+ 12 - 0
sub_supplier/xunlei/xunlei.go

@@ -35,6 +35,18 @@ func (s Supplier) GetSupplierName() string {
 	return common.SubSiteXunLei
 }
 
+func (s Supplier) GetSubListFromFile4Movie(filePath string) ([]common.SupplierSubInfo, error){
+	return s.GetSubListFromFile(filePath)
+}
+
+func (s Supplier) GetSubListFromFile4Series(filePath string) ([]common.SupplierSubInfo, error) {
+	return s.GetSubListFromFile(filePath)
+}
+
+func (s Supplier) GetSubListFromFile4Anime(filePath string) ([]common.SupplierSubInfo, error){
+	return s.GetSubListFromFile(filePath)
+}
+
 func (s Supplier) GetSubListFromFile(filePath string) ([]common.SupplierSubInfo, error) {
 
 	cid, err := s.getCid(filePath)

+ 12 - 0
sub_supplier/zimuku/zimuku.go

@@ -36,6 +36,18 @@ func (s Supplier) GetSupplierName() string {
 	return common.SubSiteZiMuKu
 }
 
+func (s Supplier) GetSubListFromFile4Movie(filePath string) ([]common.SupplierSubInfo, error){
+	return s.GetSubListFromFile(filePath)
+}
+
+func (s Supplier) GetSubListFromFile4Series(filePath string) ([]common.SupplierSubInfo, error) {
+
+}
+
+func (s Supplier) GetSubListFromFile4Anime(filePath string) ([]common.SupplierSubInfo, error){
+
+}
+
 func (s Supplier) GetSubListFromFile(filePath string) ([]common.SupplierSubInfo, error) {
 
 	/*