scheduled_live_extract_spec.cr 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. require "../../parsers_helper.cr"
  2. Spectator.describe "parse_video_info" do
  3. it "parses scheduled livestreams data" do
  4. # Enable mock
  5. _player = load_mock("video/scheduled_live_PBD-Podcast.player")
  6. _next = load_mock("video/scheduled_live_PBD-Podcast.next")
  7. raw_data = _player.merge!(_next)
  8. info = parse_video_info("N-yVic7BbY0", raw_data)
  9. # Some basic verifications
  10. expect(typeof(info)).to eq(Hash(String, JSON::Any))
  11. expect(info["videoType"].as_s).to eq("Scheduled")
  12. # Basic video infos
  13. expect(info["title"].as_s).to eq("Home Team | PBD Podcast | Ep. 241")
  14. expect(info["views"].as_i).to eq(6)
  15. expect(info["likes"].as_i).to eq(7)
  16. expect(info["lengthSeconds"].as_i).to eq(0_i64)
  17. expect(info["published"].as_s).to eq("2023-02-28T14:00:00Z") # Unix 1677592800
  18. # Extra video infos
  19. expect(info["allowedRegions"].as_a).to_not be_empty
  20. expect(info["allowedRegions"].as_a.size).to eq(249)
  21. expect(info["allowedRegions"].as_a).to contain(
  22. "AD", "AR", "BA", "BT", "CZ", "FO", "GL", "IO", "KE", "KH", "LS",
  23. "LT", "MP", "NO", "PR", "RO", "SE", "SK", "SS", "SX", "SZ", "ZW"
  24. )
  25. expect(info["keywords"].as_a).to_not be_empty
  26. expect(info["keywords"].as_a.size).to eq(25)
  27. expect(info["keywords"].as_a).to contain_exactly(
  28. "Patrick Bet-David",
  29. "Valeutainment",
  30. "The BetDavid Podcast",
  31. "The BetDavid Show",
  32. "Betdavid",
  33. "PBD",
  34. "BetDavid show",
  35. "Betdavid podcast",
  36. "podcast betdavid",
  37. "podcast patrick",
  38. "patrick bet david podcast",
  39. "Valuetainment podcast",
  40. "Entrepreneurs",
  41. "Entrepreneurship",
  42. "Entrepreneur Motivation",
  43. "Entrepreneur Advice",
  44. "Startup Entrepreneurs",
  45. "valuetainment",
  46. "patrick bet david",
  47. "PBD podcast",
  48. "Betdavid show",
  49. "Betdavid Podcast",
  50. "Podcast Betdavid",
  51. "Show Betdavid",
  52. "PBDPodcast"
  53. ).in_any_order
  54. expect(info["allowRatings"].as_bool).to be_true
  55. expect(info["isFamilyFriendly"].as_bool).to be_true
  56. expect(info["isListed"].as_bool).to be_true
  57. expect(info["isUpcoming"].as_bool).to be_true
  58. # Related videos
  59. expect(info["relatedVideos"].as_a.size).to eq(20)
  60. expect(info["relatedVideos"][0]["id"]).to eq("j7jPzzjbVuk")
  61. expect(info["relatedVideos"][0]["author"]).to eq("Democracy Now!")
  62. expect(info["relatedVideos"][0]["ucid"]).to eq("UCzuqE7-t13O4NIDYJfakrhw")
  63. expect(info["relatedVideos"][0]["view_count"]).to eq("7576")
  64. expect(info["relatedVideos"][0]["short_view_count"]).to eq("7.5K")
  65. expect(info["relatedVideos"][0]["author_verified"]).to eq("true")
  66. # Description
  67. description_start_text = "PBD Podcast Episode 241. The home team is ready and at it again with the latest news, interesting topics and trending conversations on topics that matter. Try our sponsor Aura for 14 days free - https://aura.com/pbd"
  68. expect(info["description"].as_s).to start_with(description_start_text)
  69. expect(info["shortDescription"].as_s).to start_with(description_start_text)
  70. # TODO: Update mocks right before the start of PDB podcast, either on friday or saturday (time unknown)
  71. # expect(info["descriptionHtml"].as_s).to start_with(
  72. # "PBD Podcast Episode 241. The home team is ready and at it again with the latest news, interesting topics and trending conversations on topics that matter. Try our sponsor Aura for 14 days free - <a href=\"https://aura.com/pbd\">aura.com/pbd</a>"
  73. # )
  74. # Video metadata
  75. expect(info["genre"].as_s).to eq("Entertainment")
  76. expect(info["genreUcid"].as_s?).to be_nil
  77. expect(info["license"].as_s).to be_empty
  78. # Author infos
  79. expect(info["author"].as_s).to eq("PBD Podcast")
  80. expect(info["ucid"].as_s).to eq("UCGX7nGXpz-CmO_Arg-cgJ7A")
  81. expect(info["authorThumbnail"].as_s).to eq(
  82. "https://yt3.ggpht.com/61ArDiQshJrvSXcGLhpFfIO3hlMabe2fksitcf6oGob0Mdr5gztdkXxRljICUodL4iuTSrtxW4A=s48-c-k-c0x00ffffff-no-rj"
  83. )
  84. expect(info["authorVerified"].as_bool).to be_false
  85. expect(info["subCountText"].as_s).to eq("594K")
  86. end
  87. end