Browse Source

TMDB API Test

Signed-off-by: allan716 <[email protected]>
allan716 3 years ago
parent
commit
cc0aa6f95c
4 changed files with 52 additions and 0 deletions
  1. 41 0
      TestCode/test_imdb_tmdb.go
  2. 7 0
      TestCode/test_imdb_tmdb_test.go
  3. 1 0
      go.mod
  4. 3 0
      go.sum

+ 41 - 0
TestCode/test_imdb_tmdb.go

@@ -0,0 +1,41 @@
+package TestCode
+
+import (
+	"fmt"
+	"github.com/allanpk716/ChineseSubFinder/internal/pkg/my_util"
+	"github.com/allanpk716/ChineseSubFinder/internal/pkg/settings"
+	tmdb "github.com/cyruzin/golang-tmdb"
+)
+
+func imdb2tmdb() {
+	tmdbClient, err := tmdb.Init("xxx")
+
+	if err != nil {
+		fmt.Println(err)
+	}
+
+	options := make(map[string]string)
+	options["external_source"] = "imdb_id"
+	//options["language"] = "en-US"
+	options["language"] = "zh-CN"
+
+	const keanuReevesID = "tt6264654"
+
+	proxySettings := settings.NewProxySettings(true, "http",
+		"19037",
+		"192.168.50.252", "5269",
+		"", "",
+	)
+
+	restyClient, err := my_util.NewHttpClient(proxySettings)
+
+	tmdbClient.SetClientConfig(*restyClient.GetClient())
+
+	result, err := tmdbClient.GetFindByID(keanuReevesID, options)
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+
+	println(result.MovieResults[0].Title)
+}

+ 7 - 0
TestCode/test_imdb_tmdb_test.go

@@ -0,0 +1,7 @@
+package TestCode
+
+import "testing"
+
+func Test_imdb2tmdb(t *testing.T) {
+	imdb2tmdb()
+}

+ 1 - 0
go.mod

@@ -84,6 +84,7 @@ require (
 	github.com/bodgit/plumbing v1.1.0 // indirect
 	github.com/bodgit/windows v1.0.0 // indirect
 	github.com/connesc/cipherio v0.2.1 // indirect
+	github.com/cyruzin/golang-tmdb v1.4.3 // indirect
 	github.com/dsnet/compress v0.0.1 // indirect
 	github.com/gin-contrib/sse v0.1.0 // indirect
 	github.com/go-git/gcfg v1.5.0 // indirect

+ 3 - 0
go.sum

@@ -123,6 +123,8 @@ github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfc
 github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
 github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
 github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
+github.com/cyruzin/golang-tmdb v1.4.3 h1:68vNEG4djN5eTeQQCajPDi0VpR+WwFGaham/Or0ef84=
+github.com/cyruzin/golang-tmdb v1.4.3/go.mod h1:HSTffPiDK+Q8gzRlZ22oCu6Otj/7TwUlTqEzFqJoG00=
 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
 github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
 github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@@ -939,6 +941,7 @@ gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
 gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
 gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
 gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
+gopkg.in/yaml.v3 v3.0.0-20200605160147-a5ece683394c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
 gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
 gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
 gorm.io/driver/sqlite v1.2.6 h1:SStaH/b+280M7C8vXeZLz/zo9cLQmIGwwj3cSj7p6l4=