subtitle_best_api_test.go 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. package subtitle_best_api
  2. import (
  3. "testing"
  4. "github.com/allanpk716/ChineseSubFinder/pkg/settings"
  5. "github.com/allanpk716/ChineseSubFinder/pkg/global_value"
  6. "github.com/allanpk716/ChineseSubFinder/pkg/log_helper"
  7. "github.com/allanpk716/ChineseSubFinder/pkg/my_util"
  8. "github.com/allanpk716/ChineseSubFinder/pkg/random_auth_key"
  9. )
  10. func TestSubtitleBestApi_GetMediaInfo(t *testing.T) {
  11. my_util.ReadCustomAuthFile(log_helper.GetLogger4Tester())
  12. bapi := NewSubtitleBestApi(
  13. log_helper.GetLogger4Tester(),
  14. random_auth_key.AuthKey{
  15. BaseKey: global_value.BaseKey(),
  16. AESKey16: global_value.AESKey16(),
  17. AESIv16: global_value.AESIv16(),
  18. }, settings.GetSettings().AdvancedSettings.ProxySettings)
  19. downloadTaskReply, err := bapi.AskDownloadTask("123")
  20. if err != nil {
  21. t.Fatal(err)
  22. }
  23. println(downloadTaskReply.Status, downloadTaskReply.Message)
  24. feedReply, err := bapi.FeedBack(my_util.RandStringBytesMaskImprSrcSB(64), "1.0.0", "None", true, true)
  25. if err != nil {
  26. t.Fatal(err)
  27. }
  28. println("FeedBack:", feedReply.Status, feedReply.Message)
  29. mediaInfo, err := bapi.GetMediaInfo("tt7278862", "imdb", "series")
  30. if err != nil {
  31. t.Fatal(err)
  32. }
  33. println(mediaInfo.TitleCN)
  34. convertIDResult, err := bapi.ConvertId("438148", "tmdb", "movie")
  35. if err != nil {
  36. t.Fatal(err)
  37. }
  38. println("IMDBId", convertIDResult.IMDBId)
  39. askFindSubReply, err := bapi.AskFindSub("0053b934afa0285e4de140e148c1c3768de73cfaad4170825c698308f8485c19",
  40. "tt4236770", "73586", "4", "1", "haha123456", "")
  41. if err != nil {
  42. t.Fatal(err)
  43. }
  44. println("AskFindSub.Status:", askFindSubReply.Status)
  45. println("AskFindSub.Message:", askFindSubReply.Message)
  46. findSubReply, err := bapi.FindSub("0053b934afa0285e4de140e148c1c3768de73cfaad4170825c698308f8485c19",
  47. "tt4236770", "73586", "4", "1", "haha123456", "")
  48. if err != nil {
  49. t.Fatal(err)
  50. }
  51. println("FindSub.Status:", findSubReply.Status)
  52. println("FindSub.Message:", findSubReply.Message)
  53. askForDownloadReply, err := bapi.AskDownloadSub("cd5e4bca49eea1f54f3eda5a38452b1c234075017857d010c76948124316cf2b",
  54. "haha123456", "")
  55. if err != nil {
  56. t.Fatal(err)
  57. }
  58. println("AskDownloadSub.Status:", askForDownloadReply.Status)
  59. println("AskDownloadSub.Message:", askForDownloadReply.Message)
  60. downloadSubReply, err := bapi.DownloadSub("cd5e4bca49eea1f54f3eda5a38452b1c234075017857d010c76948124316cf2b",
  61. "haha123456", "", "C:\\Tmp\\downloadhub\\123.srt")
  62. if err != nil {
  63. t.Fatal(err)
  64. }
  65. println("DownloadSub.Status", downloadSubReply.Status)
  66. println("DownloadSub.Message", downloadSubReply.Message)
  67. }