|
|
@@ -1,6 +1,8 @@
|
|
|
package common
|
|
|
|
|
|
-import "testing"
|
|
|
+import (
|
|
|
+ "testing"
|
|
|
+)
|
|
|
|
|
|
func TestGet_IMDB_Id(t *testing.T) {
|
|
|
type args struct {
|
|
|
@@ -12,18 +14,18 @@ func TestGet_IMDB_Id(t *testing.T) {
|
|
|
want string
|
|
|
wantErr bool
|
|
|
}{
|
|
|
- {name: "have", args: args{dirPth: "Y:\\电影\\Army of the Dead (2021)"}, want: "tt0993840", wantErr: false},
|
|
|
- {name: "want error", args: args{dirPth: "Y:\\电影\\"}, want: "", wantErr: true},
|
|
|
+ {name: "have", args: args{dirPth: "x:\\电影\\Army of the Dead (2021)"}, want: "tt0993840", wantErr: false},
|
|
|
+ {name: "want error", args: args{dirPth: "x:\\电影\\"}, want: "", wantErr: true},
|
|
|
}
|
|
|
for _, tt := range tests {
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
|
- got, err := Get_IMDB_Id(tt.args.dirPth)
|
|
|
+ got, err := GetImdbId(tt.args.dirPth)
|
|
|
if (err != nil) != tt.wantErr {
|
|
|
- t.Errorf("Get_IMDB_Id() error = %v, wantErr %v", err, tt.wantErr)
|
|
|
+ t.Errorf("GetImdbId() error = %v, wantErr %v", err, tt.wantErr)
|
|
|
return
|
|
|
}
|
|
|
if got != tt.want {
|
|
|
- t.Errorf("Get_IMDB_Id() got = %v, want %v", got, tt.want)
|
|
|
+ t.Errorf("GetImdbId() got = %v, want %v", got, tt.want)
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
@@ -31,8 +33,8 @@ func TestGet_IMDB_Id(t *testing.T) {
|
|
|
|
|
|
func Test_get_IMDB_movie_xml(t *testing.T) {
|
|
|
want := "tt0993840"
|
|
|
- dirPth := "Y:\\电影\\Army of the Dead (2021)\\movie.xml"
|
|
|
- got, err := get_IMDB_movie_xml(dirPth)
|
|
|
+ dirPth := "x:\\电影\\Army of the Dead (2021)\\movie.xml"
|
|
|
+ got, err := getImdbMovieXml(dirPth)
|
|
|
if err != nil {
|
|
|
t.Error(err)
|
|
|
}
|
|
|
@@ -43,12 +45,53 @@ func Test_get_IMDB_movie_xml(t *testing.T) {
|
|
|
|
|
|
func Test_get_IMDB_nfo(t *testing.T) {
|
|
|
want := "tt0993840"
|
|
|
- dirPth := "Y:\\电影\\Army of the Dead (2021)\\Army of the Dead (2021) WEBDL-1080p.nfo"
|
|
|
- got, err := get_IMDB_nfo(dirPth)
|
|
|
+ dirPth := "X:\\电影\\Army of the Dead (2021)\\Army of the Dead (2021) WEBDL-1080p.nfo"
|
|
|
+ got, err := getImdbNfo(dirPth)
|
|
|
if err != nil {
|
|
|
t.Error(err)
|
|
|
}
|
|
|
if got != want {
|
|
|
t.Errorf("Test_get_IMDB_movie_xml() got = %v, want %v", got, want)
|
|
|
}
|
|
|
+}
|
|
|
+
|
|
|
+func Test_VideoInfo(t *testing.T) {
|
|
|
+
|
|
|
+ movieFile1 := "X:\\电影\\Spiral From the Book of Saw (2021)\\Spiral From the Book of Saw (2021) WEBDL-1080p.mkv"
|
|
|
+ movieFile2 := "人之怒 WEBDL-1080p.mkv"
|
|
|
+ movieFile3 := "機動戦士Zガンダム WEBDL-1080p.mkv"
|
|
|
+ movieFile4 := "机动战士Z高达:星之继承者 (2005) 1080p TrueHD.mkv"
|
|
|
+ standard1 := "X:\\连续剧\\The Bad Batch\\Season 1\\The Bad Batch - S01E01 - Aftermath WEBDL-1080p.mkv"
|
|
|
+
|
|
|
+ m1, err := GetVideoInfo(movieFile1)
|
|
|
+ if err != nil {
|
|
|
+ t.Error(err)
|
|
|
+ }
|
|
|
+ println(m1.Title, m1.Year, m1.Quality, m1.Codec, m1.Hardcoded)
|
|
|
+
|
|
|
+ m2, err := GetVideoInfo(movieFile2)
|
|
|
+ if err != nil {
|
|
|
+ t.Error(err)
|
|
|
+ }
|
|
|
+ println(m2.Title, m2.Quality, m2.Codec, m2.Hardcoded)
|
|
|
+
|
|
|
+ m3, err := GetVideoInfo(movieFile3)
|
|
|
+ if err != nil {
|
|
|
+ t.Error(err)
|
|
|
+ }
|
|
|
+ println(m3.Title, m3.Quality, m3.Codec, m3.Hardcoded)
|
|
|
+
|
|
|
+ m4, err := GetVideoInfo(movieFile4)
|
|
|
+ if err != nil {
|
|
|
+ t.Error(err)
|
|
|
+ }
|
|
|
+ println(m4.Title, m4.Quality, m4.Codec, m4.Hardcoded)
|
|
|
+
|
|
|
+ s1, err := GetVideoInfo(standard1)
|
|
|
+ if err != nil {
|
|
|
+ t.Error(err)
|
|
|
+ }
|
|
|
+ println(s1.Title, s1.Season, s1.Episode, s1.Quality, s1.Codec, s1.Hardcoded)
|
|
|
+
|
|
|
+
|
|
|
}
|