video_info 2.6.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (195) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/unit_test.yml +39 -0
  3. data/.gitignore +0 -1
  4. data/.rubocop.yml +242 -1
  5. data/CONTRIBUTING.md +11 -0
  6. data/Gemfile +1 -1
  7. data/Guardfile +2 -2
  8. data/README.md +29 -7
  9. data/lib/video_info.rb +25 -28
  10. data/lib/video_info/provider.rb +25 -12
  11. data/lib/video_info/providers/dailymotion.rb +19 -3
  12. data/lib/video_info/providers/vimeo.rb +3 -3
  13. data/lib/video_info/providers/vimeo_api.rb +20 -11
  14. data/lib/video_info/providers/vimeo_scraper.rb +93 -23
  15. data/lib/video_info/providers/wistia.rb +2 -1
  16. data/lib/video_info/providers/youtube.rb +16 -2
  17. data/lib/video_info/providers/youtube_api.rb +42 -8
  18. data/lib/video_info/providers/youtube_scraper.rb +64 -31
  19. data/lib/video_info/providers/youtubeplaylist.rb +5 -2
  20. data/lib/video_info/providers/youtubeplaylist_api.rb +22 -1
  21. data/lib/video_info/providers/youtubeplaylist_scraper.rb +16 -3
  22. data/lib/video_info/version.rb +1 -1
  23. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Dailymotion/_available_/with_invalid_video_url/_available_/1_2_2_1_1.yml +82 -0
  24. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Dailymotion/_available_/with_valid_video/_available_/1_2_1_1_1.yml +87 -0
  25. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Dailymotion/with_video_x7lni3/_author/1_3_7_1.yml +91 -0
  26. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Dailymotion/with_video_x7lni3/_author_thumbnail/1_3_9_1.yml +91 -0
  27. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Dailymotion/with_video_x7lni3/_author_url/1_3_8_1.yml +91 -0
  28. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Dailymotion/with_video_x7lni3/_date/should_show_correct_date.yml +91 -0
  29. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Dailymotion/with_video_x7lni3/_description/1_3_10_1.yml +91 -0
  30. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Dailymotion/with_video_x7lni3/_duration/1_3_12_1.yml +91 -0
  31. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Dailymotion/with_video_x7lni3/_keywords/1_3_11_1.yml +91 -0
  32. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Dailymotion/with_video_x7lni3/_thumbnail/1_3_21_1.yml +91 -0
  33. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Dailymotion/with_video_x7lni3/_thumbnail_large/1_3_18_1.yml +91 -0
  34. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Dailymotion/with_video_x7lni3/_thumbnail_medium/1_3_17_1.yml +91 -0
  35. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Dailymotion/with_video_x7lni3/_thumbnail_small/1_3_16_1.yml +91 -0
  36. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Dailymotion/with_video_x7lni3/_title/1_3_6_1.yml +91 -0
  37. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Dailymotion/with_video_x7lni3/_view_count/1_3_22_1.yml +91 -0
  38. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/_available_/with_password_required_video/_available_/1_2_3_1_1.yml +151 -0
  39. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/_available_/with_password_required_video/_available_/2_2_3_1_1.yml +68 -0
  40. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/_available_/with_this_video_does_not_exist_video/_available_/1_2_2_1_1.yml +127 -0
  41. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/_available_/with_this_video_does_not_exist_video/_available_/2_2_2_1_1.yml +70 -0
  42. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/_available_/with_valid_video/_available_/1_2_1_1_1.yml +158 -0
  43. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/_available_/with_valid_video/_available_/2_2_1_1_1.yml +68 -0
  44. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_unavailable_video/author/1_13_2_1.yml +130 -0
  45. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_unavailable_video/author_thumbnail/1_13_3_1.yml +130 -0
  46. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_unavailable_video/author_url/1_13_4_1.yml +132 -0
  47. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_unavailable_video/available_/1_13_1_1.yml +130 -0
  48. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_unavailable_video/date/1_13_7_1.yml +128 -0
  49. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_unavailable_video/description/1_13_6_1.yml +131 -0
  50. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_unavailable_video/duration/1_13_8_1.yml +130 -0
  51. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_unavailable_video/height/1_13_10_1.yml +131 -0
  52. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_unavailable_video/keywords/1_13_9_1.yml +128 -0
  53. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_unavailable_video/thumbnail_large/1_13_14_1.yml +129 -0
  54. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_unavailable_video/thumbnail_medium/1_13_13_1.yml +129 -0
  55. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_unavailable_video/thumbnail_small/1_13_12_1.yml +129 -0
  56. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_unavailable_video/title/1_13_5_1.yml +130 -0
  57. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_unavailable_video/view_count/1_13_15_1.yml +129 -0
  58. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_unavailable_video/width/1_13_11_1.yml +129 -0
  59. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_author/1_3_20_1.yml +158 -0
  60. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_author/2_3_20_1.yml +80 -0
  61. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_author_thumbnail/1_3_19_1.yml +158 -0
  62. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_author_thumbnail/2_3_19_1.yml +85 -0
  63. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_author_url/1_3_21_1.yml +159 -0
  64. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_author_url/2_3_21_1.yml +80 -0
  65. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_date/should_have_correct_upload_date.yml +240 -0
  66. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_description/1_3_7_1.yml +160 -0
  67. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_description/2_3_7_1.yml +80 -0
  68. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_duration/1_3_9_1.yml +158 -0
  69. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_duration/2_3_9_1.yml +85 -0
  70. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_height/1_3_11_1.yml +158 -0
  71. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_height/2_3_11_1.yml +80 -0
  72. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_keywords/should_return_a_string_list_of_keywords.yml +240 -0
  73. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_thumbnail/1_3_18_1.yml +236 -0
  74. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_thumbnail/2_3_18_1.yml +82 -0
  75. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_thumbnail_large/1_3_15_1.yml +236 -0
  76. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_thumbnail_large/2_3_15_1.yml +82 -0
  77. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_thumbnail_medium/1_3_14_1.yml +235 -0
  78. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_thumbnail_medium/2_3_14_1.yml +84 -0
  79. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_thumbnail_small/1_3_13_1.yml +236 -0
  80. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_thumbnail_small/2_3_13_1.yml +84 -0
  81. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_title/1_3_6_1.yml +159 -0
  82. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_title/2_3_6_1.yml +85 -0
  83. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_view_count/1_3_22_1.yml +158 -0
  84. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_view_count/2_3_22_1.yml +84 -0
  85. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_width/1_3_10_1.yml +156 -0
  86. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_width/2_3_10_1.yml +82 -0
  87. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_141349194/thumbnail/1_12_1_1.yml +234 -0
  88. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_141349194/thumbnail/2_12_1_1.yml +78 -0
  89. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_141349194/thumbnail_large/1_12_2_1.yml +233 -0
  90. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_141349194/thumbnail_large/2_12_2_1.yml +78 -0
  91. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_141349194/thumbnail_medium/1_12_3_1.yml +235 -0
  92. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_141349194/thumbnail_medium/2_12_3_1.yml +73 -0
  93. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_141349194/thumbnail_small/1_12_4_1.yml +234 -0
  94. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_141349194/thumbnail_small/2_12_4_1.yml +77 -0
  95. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Wistia/_available_/with_invalid_video/_available_/1_2_2_1_1.yml +75 -0
  96. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Wistia/_available_/with_valid_video/_available_/1_2_1_1_1.yml +79 -0
  97. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Wistia/with_video_pxonqr42is/_duration/1_4_7_1.yml +85 -0
  98. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Wistia/with_video_pxonqr42is/_height/1_4_9_1.yml +85 -0
  99. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Wistia/with_video_pxonqr42is/_thumbnail_large/1_4_12_1.yml +86 -0
  100. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Wistia/with_video_pxonqr42is/_thumbnail_medium/1_4_11_1.yml +86 -0
  101. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Wistia/with_video_pxonqr42is/_thumbnail_small/1_4_10_1.yml +85 -0
  102. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Wistia/with_video_pxonqr42is/_title/1_4_6_1.yml +86 -0
  103. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Wistia/with_video_pxonqr42is/_width/1_4_8_1.yml +86 -0
  104. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Wistia/with_video_rs1me54mpw/_duration/1_3_7_1.yml +85 -0
  105. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Wistia/with_video_rs1me54mpw/_height/1_3_9_1.yml +87 -0
  106. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Wistia/with_video_rs1me54mpw/_thumbnail/1_3_15_1.yml +87 -0
  107. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Wistia/with_video_rs1me54mpw/_thumbnail_large/1_3_12_1.yml +87 -0
  108. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Wistia/with_video_rs1me54mpw/_thumbnail_medium/1_3_11_1.yml +87 -0
  109. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Wistia/with_video_rs1me54mpw/_thumbnail_small/1_3_10_1.yml +85 -0
  110. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Wistia/with_video_rs1me54mpw/_title/1_3_6_1.yml +85 -0
  111. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Wistia/with_video_rs1me54mpw/_width/1_3_8_1.yml +87 -0
  112. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/_available_/with_unavailable_video/_available_/1_2_2_1_1.yml +59 -0
  113. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/_available_/with_unavailable_video/_available_/2_2_2_1_1.yml +114 -0
  114. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/_available_/with_unavailable_video/_date/1_2_2_11_1.yml +59 -0
  115. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/_available_/with_unavailable_video/_date/2_2_2_11_1.yml +114 -0
  116. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/_available_/with_unavailable_video/_description/1_2_2_8_1.yml +59 -0
  117. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/_available_/with_unavailable_video/_description/2_2_2_8_1.yml +114 -0
  118. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/_available_/with_unavailable_video/_duration/1_2_2_10_1.yml +59 -0
  119. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/_available_/with_unavailable_video/_duration/2_2_2_10_1.yml +114 -0
  120. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/_available_/with_unavailable_video/_keywords/1_2_2_9_1.yml +59 -0
  121. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/_available_/with_unavailable_video/_keywords/2_2_2_9_1.yml +114 -0
  122. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/_available_/with_unavailable_video/_title/1_2_2_7_1.yml +59 -0
  123. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/_available_/with_unavailable_video/_title/2_2_2_7_1.yml +114 -0
  124. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/_available_/with_unavailable_video/_view_count/1_2_2_18_1.yml +59 -0
  125. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/_available_/with_unavailable_video/_view_count/2_2_2_18_1.yml +114 -0
  126. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/_available_/with_valid_video/_available_/1_2_1_1_1.yml +59 -0
  127. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/_available_/with_valid_video/_available_/2_2_1_1_1.yml +187 -0
  128. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/_available_/with_video_removed_because_of_copyright_claim/_available_/1_2_3_1_1.yml +59 -0
  129. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/_available_/with_video_removed_because_of_copyright_claim/_available_/2_2_3_1_1.yml +114 -0
  130. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_a_video_without_description/_description/1_1_1_1.yml +59 -0
  131. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_full_screen_video_URLs/_date/should_return_date_video_was_posted.yml +249 -0
  132. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_full_screen_video_URLs/_description/1_17_7_1.yml +59 -0
  133. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_full_screen_video_URLs/_description/2_17_7_1.yml +187 -0
  134. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_full_screen_video_URLs/_duration/1_17_9_1.yml +59 -0
  135. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_full_screen_video_URLs/_duration/2_17_9_1.yml +187 -0
  136. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_full_screen_video_URLs/_keywords/1_17_8_1.yml +59 -0
  137. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_full_screen_video_URLs/_keywords/2_17_8_1.yml +187 -0
  138. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_full_screen_video_URLs/_title/1_17_6_1.yml +59 -0
  139. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_full_screen_video_URLs/_title/2_17_6_1.yml +187 -0
  140. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_full_screen_video_URLs/_view_count/1_17_17_1.yml +59 -0
  141. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_full_screen_video_URLs/_view_count/2_17_17_1.yml +187 -0
  142. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/_author/1_3_6_1.yml +115 -0
  143. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/_author/2_3_6_1.yml +187 -0
  144. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/_author_thumbnail/1_3_7_1.yml +115 -0
  145. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/_author_thumbnail/2_3_7_1.yml +335 -0
  146. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/_author_url/1_3_8_1.yml +59 -0
  147. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/_author_url/2_3_8_1.yml +335 -0
  148. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/_author_url/can_be_called_twice_and_receive_the_same_value.yml +391 -0
  149. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/_date/should_return_date_video_was_posted.yml +243 -0
  150. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/_description/1_3_10_1.yml +60 -0
  151. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/_description/2_3_10_1.yml +187 -0
  152. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/_duration/1_3_12_1.yml +59 -0
  153. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/_duration/2_3_12_1.yml +187 -0
  154. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/_keywords/1_3_11_1.yml +59 -0
  155. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/_keywords/2_3_11_1.yml +187 -0
  156. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/_title/1_3_9_1.yml +59 -0
  157. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/_title/2_3_9_1.yml +187 -0
  158. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/_view_count/1_3_21_1.yml +59 -0
  159. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/_view_count/2_3_21_1.yml +187 -0
  160. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/_available_/with_invalid_playlist/_available_/1_2_2_1_1.yml +120 -0
  161. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/_available_/with_list_url/_available_/1_2_3_1_1.yml +154 -0
  162. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/_available_/with_valid_playlist/_available_/1_2_1_1_1.yml +154 -0
  163. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/with_playlist_PL9hW1uS6HUftLdHI6RIsaf/_author/1_3_21_1.yml +165 -0
  164. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/with_playlist_PL9hW1uS6HUftLdHI6RIsaf/_author_thumbnail/1_3_22_1.yml +274 -0
  165. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/with_playlist_PL9hW1uS6HUftLdHI6RIsaf/_author_url/1_3_23_1.yml +274 -0
  166. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/with_playlist_PL9hW1uS6HUftLdHI6RIsaf/_description/1_3_7_1.yml +165 -0
  167. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/with_playlist_PL9hW1uS6HUftLdHI6RIsaf/_keywords/1_3_8_1.yml +165 -0
  168. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/with_playlist_PL9hW1uS6HUftLdHI6RIsaf/_thumbnail/1_3_18_1.yml +165 -0
  169. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/with_playlist_PL9hW1uS6HUftLdHI6RIsaf/_thumbnail_large/1_3_15_1.yml +165 -0
  170. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/with_playlist_PL9hW1uS6HUftLdHI6RIsaf/_thumbnail_large_2x/1_3_16_1.yml +165 -0
  171. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/with_playlist_PL9hW1uS6HUftLdHI6RIsaf/_thumbnail_maxres/1_3_17_1.yml +165 -0
  172. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/with_playlist_PL9hW1uS6HUftLdHI6RIsaf/_thumbnail_medium/1_3_14_1.yml +165 -0
  173. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/with_playlist_PL9hW1uS6HUftLdHI6RIsaf/_thumbnail_small/1_3_13_1.yml +165 -0
  174. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/with_playlist_PL9hW1uS6HUftLdHI6RIsaf/_title/1_3_6_1.yml +165 -0
  175. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/with_playlist_PL9hW1uS6HUftLdHI6RIsaf/_videos/returns_list_of_videos_in_playlist.yml +112 -0
  176. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/with_playlist_that_does_not_exist_in_embed_path/_videos/1_4_2_1.yml +114 -0
  177. data/spec/lib/video_info/provider_spec.rb +42 -22
  178. data/spec/lib/video_info/providers/dailymotion_spec.rb +75 -27
  179. data/spec/lib/video_info/providers/vimeo_spec.rb +270 -174
  180. data/spec/lib/video_info/providers/wistia_spec.rb +59 -20
  181. data/spec/lib/video_info/providers/youtube_playlist_spec.rb +97 -41
  182. data/spec/lib/video_info/providers/youtube_scraper_spec.rb +14 -0
  183. data/spec/lib/video_info/providers/youtube_spec.rb +441 -384
  184. data/spec/lib/video_info_spec.rb +27 -25
  185. data/spec/spec_helper.rb +6 -1
  186. data/tmp/rspec_guard_result +25 -0
  187. data/video_info.gemspec +11 -14
  188. metadata +358 -100
  189. data/.travis.yml +0 -13
  190. data/foo.txt +0 -33
  191. data/lib/video_info/providers/vkontakte.rb +0 -170
  192. data/spec/lib/video_info/providers/vimeo_api_spec.rb +0 -242
  193. data/spec/lib/video_info/providers/vkontakte_spec.rb +0 -173
  194. data/spec/lib/video_info/providers/youtube_api_spec.rb +0 -476
  195. data/spec/lib/video_info/providers/youtube_playlist_api_spec.rb +0 -187
@@ -1,10 +1,11 @@
1
1
  require 'open-uri'
2
- require 'multi_json'
3
- require 'addressable/uri'
2
+ require 'json'
3
+ require 'uri'
4
4
 
5
5
  class VideoInfo
6
6
  class Provider
7
- attr_accessor :url, :options, :iframe_attributes, :video_id, :data
7
+ attr_accessor :url, :options, :iframe_attributes, :video_id
8
+ attr_writer :data
8
9
 
9
10
  def initialize(url, options = {})
10
11
  @options = _clean_options(options)
@@ -12,7 +13,7 @@ class VideoInfo
12
13
  _set_video_id_from_url
13
14
  end
14
15
 
15
- def self.usable?(url)
16
+ def self.usable?(_url)
16
17
  raise NotImplementedError.new(
17
18
  'Provider class must implement .usable? public method'
18
19
  )
@@ -20,12 +21,12 @@ class VideoInfo
20
21
 
21
22
  def embed_code(options = {})
22
23
  iframe_attributes = options.fetch(:iframe_attributes, {})
23
- iframe_attrs = ["src=\"#{_embed_url(options)}\"", "frameborder=\"0\""]
24
+ iframe_attrs = ["src=\"#{_embed_url(options)}\"", 'frameborder="0"']
24
25
  iframe_attrs << _hash_to_attributes(
25
26
  _default_iframe_attributes.merge(iframe_attributes)
26
27
  )
27
28
 
28
- "<iframe #{iframe_attrs.reject(&:empty?).join(" ")}></iframe>"
29
+ "<iframe #{iframe_attrs.reject(&:empty?).join(' ')}></iframe>"
29
30
  end
30
31
 
31
32
  def data
@@ -36,13 +37,27 @@ class VideoInfo
36
37
  !%w[403 404 400].include?(_response_code)
37
38
  end
38
39
 
40
+ def thumbnail
41
+ if defined?(thumbnail_large)
42
+ thumbnail_large
43
+ end
44
+ end
45
+
46
+ def thumbnail_large_2x
47
+ nil
48
+ end
49
+
50
+ def thumbnail_maxres
51
+ nil
52
+ end
53
+
39
54
  private
40
55
 
41
56
  def _response_code
42
57
  uri = URI.parse(_api_url)
43
58
  http = Net::HTTP.new(uri.host, uri.port)
44
59
 
45
- if (uri.scheme == 'https')
60
+ if uri.scheme == 'https'
46
61
  _https_response_code(http)
47
62
  else
48
63
  _http_response_code(http)
@@ -95,8 +110,8 @@ class VideoInfo
95
110
  end
96
111
 
97
112
  def _set_data_from_api_impl(api_url)
98
- uri = open(api_url, options)
99
- MultiJson.load(uri.read)
113
+ uri = URI.open(api_url, options)
114
+ JSON.load(uri.read)
100
115
  end
101
116
 
102
117
  def _not_openuri_option_symbol?(key)
@@ -145,9 +160,7 @@ class VideoInfo
145
160
  end
146
161
 
147
162
  def _hash_to_params(hash)
148
- uri = Addressable::URI.new
149
- uri.query_values = hash
150
- uri.query
163
+ URI.encode_www_form(hash)
151
164
  end
152
165
  end
153
166
  end
@@ -17,6 +17,18 @@ class VideoInfo
17
17
  define_method(method) { nil }
18
18
  end
19
19
 
20
+ def author
21
+ data['owner.screenname']
22
+ end
23
+
24
+ def author_url
25
+ data['owner.url']
26
+ end
27
+
28
+ def author_thumbnail
29
+ data['owner.avatar_60_url']
30
+ end
31
+
20
32
  def keywords
21
33
  data['tags']
22
34
  end
@@ -56,11 +68,11 @@ class VideoInfo
56
68
  end
57
69
 
58
70
  def _url_regex
59
- /dai(?:\.ly|lymotion\.com\/(?:embed\/)?video)\/([a-zA-Z0-9]*)/
71
+ %r{dai(?:\.ly|lymotion\.com\/(?:embed\/)?video)\/([a-zA-Z0-9]*)}
60
72
  end
61
73
 
62
74
  def _api_base
63
- "api.dailymotion.com"
75
+ 'api.dailymotion.com'
64
76
  end
65
77
 
66
78
  def _api_path
@@ -68,7 +80,11 @@ class VideoInfo
68
80
  end
69
81
 
70
82
  def _api_url
71
- "https://#{_api_base}#{_api_path}?fields=id,title,description,duration,created_time,url,views_total,tags,thumbnail_url,thumbnail_720_url,thumbnail_240_url,thumbnail_60_url"
83
+ "https://#{_api_base}#{_api_path}?" \
84
+ 'fields=id,title,description,duration,created_time,' \
85
+ 'url,views_total,tags,thumbnail_url,thumbnail_720_url,' \
86
+ 'owner.url,owner.screenname,owner.avatar_60_url,' \
87
+ 'thumbnail_240_url,thumbnail_60_url'
72
88
  end
73
89
 
74
90
  def _default_iframe_attributes
@@ -15,7 +15,7 @@ class VideoInfo
15
15
  end
16
16
 
17
17
  def self.usable?(url)
18
- url =~ /(vimeo\.com\/(?!album|hubnut\/album).*)/
18
+ url =~ %r{(vimeo\.com\/(?!album|hubnut\/album).*)}
19
19
  end
20
20
 
21
21
  def provider
@@ -29,12 +29,12 @@ class VideoInfo
29
29
  private
30
30
 
31
31
  def _url_regex
32
- /.*\.com&&
32
+ %r{.*\.com&&
33
33
  |\/(?:(?:groups\/[^\/]+\/videos\/)
34
34
  |(?:ondemand|channels)(?:(?:\/less\/)
35
35
  |(?:user[0-9]+\/review\/)?([0-9]+).*
36
36
  |(?:\/\w*\/))|(?:video\/))?([0-9]+).*$
37
- /x
37
+ }x
38
38
  end
39
39
 
40
40
  def _default_iframe_attributes
@@ -26,33 +26,33 @@ class VideoInfo
26
26
  @author_thumbnail_id ||= _parse_picture_id(author_uri)
27
27
  end
28
28
 
29
+ def author_url
30
+ _video['user']['link']
31
+ end
32
+
29
33
  def author_thumbnail(width = 75)
30
- "https://i.vimeocdn.com/portrait/#{author_thumbnail_id}_#{width}x#{width}.jpg"
34
+ 'https://i.vimeocdn.com/portrait/' \
35
+ "#{author_thumbnail_id}_#{width}x#{width}.jpg"
31
36
  end
32
37
 
33
38
  def thumbnail_id
34
39
  @thumbnail_id ||= _parse_picture_id(_video['pictures']['uri'])
35
40
  end
36
41
 
37
- def thumbnail(width = 200, height = nil)
38
- base_uri = "https://i.vimeocdn.com/video/#{thumbnail_id}"
39
- height ? base_uri + "_#{width}x#{height}.jpg" : base_uri + "_#{width}.jpg"
40
- end
41
-
42
42
  def thumbnail_small
43
- thumbnail(100, 75)
43
+ generate_thumbnail(100, 75)
44
44
  end
45
45
 
46
46
  def thumbnail_medium
47
- thumbnail(200, 150)
47
+ generate_thumbnail(200, 150)
48
48
  end
49
49
 
50
50
  def thumbnail_large
51
- thumbnail(640)
51
+ generate_thumbnail(640)
52
52
  end
53
53
 
54
54
  def keywords
55
- keywords_array.join(', ')
55
+ keywords_array
56
56
  end
57
57
 
58
58
  def keywords_array
@@ -69,6 +69,15 @@ class VideoInfo
69
69
 
70
70
  private
71
71
 
72
+ def generate_thumbnail(width = 200, height = nil)
73
+ base_uri = "https://i.vimeocdn.com/video/#{thumbnail_id}"
74
+ if height
75
+ base_uri + "_#{width}x#{height}.jpg"
76
+ else
77
+ base_uri + "_#{width}.jpg"
78
+ end
79
+ end
80
+
72
81
  def _clean_options(options)
73
82
  headers = [super, _authorization_headers, _api_version_headers]
74
83
  headers.inject(&:merge)
@@ -103,7 +112,7 @@ class VideoInfo
103
112
  end
104
113
 
105
114
  def _parse_picture_id(uri)
106
- /\/pictures\/(\d+)/.match(uri)[1]
115
+ %r{\/pictures\/(\d+)}.match(uri)[1]
107
116
  end
108
117
  end
109
118
  end
@@ -1,26 +1,54 @@
1
1
  require 'oga'
2
2
  require 'open-uri'
3
3
  require 'json'
4
+ require 'openssl'
5
+ require 'cgi'
4
6
 
5
7
  class VideoInfo
6
8
  module Providers
7
9
  module VimeoScraper
8
10
  def author
9
- json_info['author']['name']
11
+ if available?
12
+ json_info['author']['name']
13
+ end
10
14
  end
11
15
 
12
16
  def author_thumbnail
13
- d = data.css('script')[5].text.split('window.vimeo.clip_page_config =')[1]
14
- JSON.parse(d.split(";\n")[0])['owner']['portrait']['src']
17
+ unless available?
18
+ return nil
19
+ end
20
+
21
+ split_point = 'window.vimeo.clip_page_config ='
22
+ script_tags = data.css('script')
23
+
24
+ script_index = script_tags.find_index do |x|
25
+ x.text.include?(split_point)
26
+ end
27
+
28
+ script_text = script_tags[script_index].text
29
+
30
+ split_script_text = script_text.split(split_point)[1]
31
+
32
+ parsed_data = JSON.parse(split_script_text.split(";\n")[0])
33
+
34
+ parsed_data['owner']['portrait']['src']
35
+ end
36
+
37
+ def author_url
38
+ if available?
39
+ json_info['author']['url']
40
+ end
15
41
  end
16
42
 
17
43
  def available?
18
44
  is_available = super
19
45
 
20
- if is_available
21
- page_header = data.css('#page_header')
46
+ if data.nil?
47
+ is_available = false
48
+ elsif is_available
49
+ password_elements = data.css('.exception_title--password')
22
50
 
23
- if page_header.text == "\n Private Video\n "
51
+ unless password_elements.empty?
24
52
  is_available = false
25
53
  end
26
54
  end
@@ -37,49 +65,79 @@ class VideoInfo
37
65
  end
38
66
 
39
67
  def date
40
- upload_date = json_info['uploadDate']
41
- ISO8601::DateTime.new(upload_date).to_time
68
+ if available?
69
+ upload_date = json_info['uploadDate']
70
+ ISO8601::DateTime.new(upload_date).to_time
71
+ end
42
72
  end
43
73
 
44
74
  def duration
45
- duration = json_info['duration']
46
- ISO8601::Duration.new(duration).to_seconds.to_i
75
+ if available?
76
+ duration = json_info['duration']
77
+ ISO8601::Duration.new(duration).to_seconds.to_i
78
+ end
47
79
  end
48
80
 
49
81
  def keywords
50
- keywords_str = ''
51
-
52
- json_info['keywords'].each { |keyword| keywords_str << keyword << ", " }
82
+ unless available?
83
+ return nil
84
+ end
53
85
 
54
- keywords_str.chop.chop # remove trailing ", "
86
+ if json_info['keywords']
87
+ json_info['keywords']
88
+ else
89
+ []
90
+ end
55
91
  end
56
92
 
57
93
  def height
58
- meta_node_value('og:video:height').to_i
94
+ if available?
95
+ json_info['height']
96
+ end
59
97
  end
60
98
 
61
99
  def width
62
- meta_node_value('og:video:width').to_i
100
+ if available?
101
+ json_info['width']
102
+ end
63
103
  end
64
104
 
65
105
  def thumbnail_small
66
- thumbnail_url.split('_')[0] + '_100x75.jpg'
106
+ if available?
107
+ thumbnail_url.split('_')[0] + '_100x75.jpg'
108
+ end
67
109
  end
68
110
 
69
111
  def thumbnail_medium
70
- thumbnail_url.split('_')[0] + '_200x150.jpg'
112
+ if available?
113
+ thumbnail_url.split('_')[0] + '_200x150.jpg'
114
+ end
71
115
  end
72
116
 
73
117
  def thumbnail_large
74
- thumbnail_url.split('_')[0] + '_640.jpg'
118
+ if available?
119
+ thumbnail_url.split('_')[0] + '_640.jpg'
120
+ end
75
121
  end
76
122
 
77
123
  def view_count
78
- json_info['interactionCount']
124
+ if available?
125
+ user_interaction_count(interaction_type: "http://schema.org/WatchAction")
126
+ end
79
127
  end
80
128
 
81
129
  private
82
130
 
131
+ def user_interaction_count(interaction_type:)
132
+ interaction_statistic.find do |stat|
133
+ stat["interactionType"] == interaction_type
134
+ end["userInteractionCount"]
135
+ end
136
+
137
+ def interaction_statistic
138
+ json_info["interactionStatistic"]
139
+ end
140
+
83
141
  def json_info
84
142
  @json_info ||= JSON.parse(data.css('script').detect do |n|
85
143
  type = n.attr('type')
@@ -93,7 +151,17 @@ class VideoInfo
93
151
  end
94
152
 
95
153
  def thumbnail_url
96
- @thumbnail_url ||= json_info['thumbnailUrl']
154
+ @thumbnail_url ||= remove_overlay(meta_node_value('og:image'))
155
+ end
156
+
157
+ def remove_overlay(url)
158
+ uri = URI.parse(url)
159
+
160
+ if uri.path == '/filter/overlay'
161
+ CGI::parse(uri.query)['src0'][0]
162
+ else
163
+ url
164
+ end
97
165
  end
98
166
 
99
167
  def meta_nodes
@@ -117,7 +185,10 @@ class VideoInfo
117
185
  end
118
186
 
119
187
  def _set_data_from_api_impl(api_url)
120
- Oga.parse_html(open(api_url.to_s, allow_redirections: :safe).read)
188
+ Oga.parse_html(URI.open(api_url.to_s).read)
189
+
190
+ rescue OpenURI::HTTPError
191
+ nil
121
192
  end
122
193
 
123
194
  def _api_url
@@ -132,4 +203,3 @@ class VideoInfo
132
203
  end
133
204
  end
134
205
  end
135
-
@@ -36,7 +36,8 @@ class VideoInfo
36
36
  private
37
37
 
38
38
  def _url_regex
39
- /(?:.*)(?:wistia.com|wi.st|wistia.net)\/(?:embed\/)?(?:medias\/)?(?:iframe\/)?(.+)/
39
+ %r{(?:.*)(?:wistia.com|wi.st|wistia.net)
40
+ \/(?:embed\/)?(?:medias\/)?(?:iframe\/)?(.+)}x
40
41
  end
41
42
 
42
43
  def _api_base
@@ -16,7 +16,8 @@ class VideoInfo
16
16
  end
17
17
 
18
18
  def self.usable?(url)
19
- url =~ /(youtube\.com\/(?!playlist|embed\/videoseries).*)|(youtu\.be)/
19
+ url =~ %r{(youtube\.com\/(?!playlist|embed\/videoseries).*)|
20
+ (youtu\.be)}x
20
21
  end
21
22
 
22
23
  def provider
@@ -43,10 +44,19 @@ class VideoInfo
43
44
  "https://i.ytimg.com/vi/#{video_id}/hqdefault.jpg"
44
45
  end
45
46
 
47
+ def thumbnail_large_2x
48
+ "https://i.ytimg.com/vi/#{video_id}/sddefault.jpg"
49
+ end
50
+
51
+ def thumbnail_maxres
52
+ "https://i.ytimg.com/vi/#{video_id}/maxresdefault.jpg"
53
+ end
54
+
46
55
  private
47
56
 
48
57
  def _url_regex
49
- /(?:youtube(?:-nocookie)?\.com\/(?:[^\/]+\/.+\/|(?:v|e(?:mbed)?)\/|.*[?&]v=)|youtu\.be\/)([^"&?\/ ]{11})/i
58
+ %r{(?:youtube(?:-nocookie)?\.com\/(?:[^\/]+\/.+\/|(?:v|e(?:mbed)?)\/|
59
+ .*[?&]v=)|youtu\.be\/)([^"&?\/ ]{11})}x
50
60
  end
51
61
 
52
62
  def _default_iframe_attributes
@@ -56,6 +66,10 @@ class VideoInfo
56
66
  def _default_url_attributes
57
67
  {}
58
68
  end
69
+
70
+ def resize_thumb(url, size)
71
+ url.gsub(/(https:\/\/yt3.ggpht.com\/.*\/.*=s)([0-9]*)(.*)/, "\\1#{size}\\3")
72
+ end
59
73
  end
60
74
  end
61
75
  end