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.
- checksums.yaml +5 -5
- data/.github/workflows/unit_test.yml +39 -0
- data/.gitignore +0 -1
- data/.rubocop.yml +242 -1
- data/CONTRIBUTING.md +11 -0
- data/Gemfile +1 -1
- data/Guardfile +2 -2
- data/README.md +29 -7
- data/lib/video_info.rb +25 -28
- data/lib/video_info/provider.rb +25 -12
- data/lib/video_info/providers/dailymotion.rb +19 -3
- data/lib/video_info/providers/vimeo.rb +3 -3
- data/lib/video_info/providers/vimeo_api.rb +20 -11
- data/lib/video_info/providers/vimeo_scraper.rb +93 -23
- data/lib/video_info/providers/wistia.rb +2 -1
- data/lib/video_info/providers/youtube.rb +16 -2
- data/lib/video_info/providers/youtube_api.rb +42 -8
- data/lib/video_info/providers/youtube_scraper.rb +64 -31
- data/lib/video_info/providers/youtubeplaylist.rb +5 -2
- data/lib/video_info/providers/youtubeplaylist_api.rb +22 -1
- data/lib/video_info/providers/youtubeplaylist_scraper.rb +16 -3
- data/lib/video_info/version.rb +1 -1
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Dailymotion/_available_/with_invalid_video_url/_available_/1_2_2_1_1.yml +82 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Dailymotion/_available_/with_valid_video/_available_/1_2_1_1_1.yml +87 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Dailymotion/with_video_x7lni3/_author/1_3_7_1.yml +91 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Dailymotion/with_video_x7lni3/_author_thumbnail/1_3_9_1.yml +91 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Dailymotion/with_video_x7lni3/_author_url/1_3_8_1.yml +91 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Dailymotion/with_video_x7lni3/_date/should_show_correct_date.yml +91 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Dailymotion/with_video_x7lni3/_description/1_3_10_1.yml +91 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Dailymotion/with_video_x7lni3/_duration/1_3_12_1.yml +91 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Dailymotion/with_video_x7lni3/_keywords/1_3_11_1.yml +91 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Dailymotion/with_video_x7lni3/_thumbnail/1_3_21_1.yml +91 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Dailymotion/with_video_x7lni3/_thumbnail_large/1_3_18_1.yml +91 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Dailymotion/with_video_x7lni3/_thumbnail_medium/1_3_17_1.yml +91 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Dailymotion/with_video_x7lni3/_thumbnail_small/1_3_16_1.yml +91 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Dailymotion/with_video_x7lni3/_title/1_3_6_1.yml +91 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Dailymotion/with_video_x7lni3/_view_count/1_3_22_1.yml +91 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/_available_/with_password_required_video/_available_/1_2_3_1_1.yml +151 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/_available_/with_password_required_video/_available_/2_2_3_1_1.yml +68 -0
- 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
- 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
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/_available_/with_valid_video/_available_/1_2_1_1_1.yml +158 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/_available_/with_valid_video/_available_/2_2_1_1_1.yml +68 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_unavailable_video/author/1_13_2_1.yml +130 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_unavailable_video/author_thumbnail/1_13_3_1.yml +130 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_unavailable_video/author_url/1_13_4_1.yml +132 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_unavailable_video/available_/1_13_1_1.yml +130 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_unavailable_video/date/1_13_7_1.yml +128 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_unavailable_video/description/1_13_6_1.yml +131 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_unavailable_video/duration/1_13_8_1.yml +130 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_unavailable_video/height/1_13_10_1.yml +131 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_unavailable_video/keywords/1_13_9_1.yml +128 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_unavailable_video/thumbnail_large/1_13_14_1.yml +129 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_unavailable_video/thumbnail_medium/1_13_13_1.yml +129 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_unavailable_video/thumbnail_small/1_13_12_1.yml +129 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_unavailable_video/title/1_13_5_1.yml +130 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_unavailable_video/view_count/1_13_15_1.yml +129 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_unavailable_video/width/1_13_11_1.yml +129 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_author/1_3_20_1.yml +158 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_author/2_3_20_1.yml +80 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_author_thumbnail/1_3_19_1.yml +158 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_author_thumbnail/2_3_19_1.yml +85 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_author_url/1_3_21_1.yml +159 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_author_url/2_3_21_1.yml +80 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_date/should_have_correct_upload_date.yml +240 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_description/1_3_7_1.yml +160 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_description/2_3_7_1.yml +80 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_duration/1_3_9_1.yml +158 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_duration/2_3_9_1.yml +85 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_height/1_3_11_1.yml +158 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_height/2_3_11_1.yml +80 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_keywords/should_return_a_string_list_of_keywords.yml +240 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_thumbnail/1_3_18_1.yml +236 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_thumbnail/2_3_18_1.yml +82 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_thumbnail_large/1_3_15_1.yml +236 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_thumbnail_large/2_3_15_1.yml +82 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_thumbnail_medium/1_3_14_1.yml +235 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_thumbnail_medium/2_3_14_1.yml +84 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_thumbnail_small/1_3_13_1.yml +236 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_thumbnail_small/2_3_13_1.yml +84 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_title/1_3_6_1.yml +159 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_title/2_3_6_1.yml +85 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_view_count/1_3_22_1.yml +158 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_view_count/2_3_22_1.yml +84 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_width/1_3_10_1.yml +156 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_width/2_3_10_1.yml +82 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_141349194/thumbnail/1_12_1_1.yml +234 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_141349194/thumbnail/2_12_1_1.yml +78 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_141349194/thumbnail_large/1_12_2_1.yml +233 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_141349194/thumbnail_large/2_12_2_1.yml +78 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_141349194/thumbnail_medium/1_12_3_1.yml +235 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_141349194/thumbnail_medium/2_12_3_1.yml +73 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_141349194/thumbnail_small/1_12_4_1.yml +234 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_141349194/thumbnail_small/2_12_4_1.yml +77 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Wistia/_available_/with_invalid_video/_available_/1_2_2_1_1.yml +75 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Wistia/_available_/with_valid_video/_available_/1_2_1_1_1.yml +79 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Wistia/with_video_pxonqr42is/_duration/1_4_7_1.yml +85 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Wistia/with_video_pxonqr42is/_height/1_4_9_1.yml +85 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Wistia/with_video_pxonqr42is/_thumbnail_large/1_4_12_1.yml +86 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Wistia/with_video_pxonqr42is/_thumbnail_medium/1_4_11_1.yml +86 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Wistia/with_video_pxonqr42is/_thumbnail_small/1_4_10_1.yml +85 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Wistia/with_video_pxonqr42is/_title/1_4_6_1.yml +86 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Wistia/with_video_pxonqr42is/_width/1_4_8_1.yml +86 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Wistia/with_video_rs1me54mpw/_duration/1_3_7_1.yml +85 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Wistia/with_video_rs1me54mpw/_height/1_3_9_1.yml +87 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Wistia/with_video_rs1me54mpw/_thumbnail/1_3_15_1.yml +87 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Wistia/with_video_rs1me54mpw/_thumbnail_large/1_3_12_1.yml +87 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Wistia/with_video_rs1me54mpw/_thumbnail_medium/1_3_11_1.yml +87 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Wistia/with_video_rs1me54mpw/_thumbnail_small/1_3_10_1.yml +85 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Wistia/with_video_rs1me54mpw/_title/1_3_6_1.yml +85 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Wistia/with_video_rs1me54mpw/_width/1_3_8_1.yml +87 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/_available_/with_unavailable_video/_available_/1_2_2_1_1.yml +59 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/_available_/with_unavailable_video/_available_/2_2_2_1_1.yml +114 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/_available_/with_unavailable_video/_date/1_2_2_11_1.yml +59 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/_available_/with_unavailable_video/_date/2_2_2_11_1.yml +114 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/_available_/with_unavailable_video/_description/1_2_2_8_1.yml +59 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/_available_/with_unavailable_video/_description/2_2_2_8_1.yml +114 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/_available_/with_unavailable_video/_duration/1_2_2_10_1.yml +59 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/_available_/with_unavailable_video/_duration/2_2_2_10_1.yml +114 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/_available_/with_unavailable_video/_keywords/1_2_2_9_1.yml +59 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/_available_/with_unavailable_video/_keywords/2_2_2_9_1.yml +114 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/_available_/with_unavailable_video/_title/1_2_2_7_1.yml +59 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/_available_/with_unavailable_video/_title/2_2_2_7_1.yml +114 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/_available_/with_unavailable_video/_view_count/1_2_2_18_1.yml +59 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/_available_/with_unavailable_video/_view_count/2_2_2_18_1.yml +114 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/_available_/with_valid_video/_available_/1_2_1_1_1.yml +59 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/_available_/with_valid_video/_available_/2_2_1_1_1.yml +187 -0
- 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
- 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
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_a_video_without_description/_description/1_1_1_1.yml +59 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_full_screen_video_URLs/_date/should_return_date_video_was_posted.yml +249 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_full_screen_video_URLs/_description/1_17_7_1.yml +59 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_full_screen_video_URLs/_description/2_17_7_1.yml +187 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_full_screen_video_URLs/_duration/1_17_9_1.yml +59 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_full_screen_video_URLs/_duration/2_17_9_1.yml +187 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_full_screen_video_URLs/_keywords/1_17_8_1.yml +59 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_full_screen_video_URLs/_keywords/2_17_8_1.yml +187 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_full_screen_video_URLs/_title/1_17_6_1.yml +59 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_full_screen_video_URLs/_title/2_17_6_1.yml +187 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_full_screen_video_URLs/_view_count/1_17_17_1.yml +59 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_full_screen_video_URLs/_view_count/2_17_17_1.yml +187 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/_author/1_3_6_1.yml +115 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/_author/2_3_6_1.yml +187 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/_author_thumbnail/1_3_7_1.yml +115 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/_author_thumbnail/2_3_7_1.yml +335 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/_author_url/1_3_8_1.yml +59 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/_author_url/2_3_8_1.yml +335 -0
- 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
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/_date/should_return_date_video_was_posted.yml +243 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/_description/1_3_10_1.yml +60 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/_description/2_3_10_1.yml +187 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/_duration/1_3_12_1.yml +59 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/_duration/2_3_12_1.yml +187 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/_keywords/1_3_11_1.yml +59 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/_keywords/2_3_11_1.yml +187 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/_title/1_3_9_1.yml +59 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/_title/2_3_9_1.yml +187 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/_view_count/1_3_21_1.yml +59 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/_view_count/2_3_21_1.yml +187 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/_available_/with_invalid_playlist/_available_/1_2_2_1_1.yml +120 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/_available_/with_list_url/_available_/1_2_3_1_1.yml +154 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/_available_/with_valid_playlist/_available_/1_2_1_1_1.yml +154 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/with_playlist_PL9hW1uS6HUftLdHI6RIsaf/_author/1_3_21_1.yml +165 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/with_playlist_PL9hW1uS6HUftLdHI6RIsaf/_author_thumbnail/1_3_22_1.yml +274 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/with_playlist_PL9hW1uS6HUftLdHI6RIsaf/_author_url/1_3_23_1.yml +274 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/with_playlist_PL9hW1uS6HUftLdHI6RIsaf/_description/1_3_7_1.yml +165 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/with_playlist_PL9hW1uS6HUftLdHI6RIsaf/_keywords/1_3_8_1.yml +165 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/with_playlist_PL9hW1uS6HUftLdHI6RIsaf/_thumbnail/1_3_18_1.yml +165 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/with_playlist_PL9hW1uS6HUftLdHI6RIsaf/_thumbnail_large/1_3_15_1.yml +165 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/with_playlist_PL9hW1uS6HUftLdHI6RIsaf/_thumbnail_large_2x/1_3_16_1.yml +165 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/with_playlist_PL9hW1uS6HUftLdHI6RIsaf/_thumbnail_maxres/1_3_17_1.yml +165 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/with_playlist_PL9hW1uS6HUftLdHI6RIsaf/_thumbnail_medium/1_3_14_1.yml +165 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/with_playlist_PL9hW1uS6HUftLdHI6RIsaf/_thumbnail_small/1_3_13_1.yml +165 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/with_playlist_PL9hW1uS6HUftLdHI6RIsaf/_title/1_3_6_1.yml +165 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/with_playlist_PL9hW1uS6HUftLdHI6RIsaf/_videos/returns_list_of_videos_in_playlist.yml +112 -0
- 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
- data/spec/lib/video_info/provider_spec.rb +42 -22
- data/spec/lib/video_info/providers/dailymotion_spec.rb +75 -27
- data/spec/lib/video_info/providers/vimeo_spec.rb +270 -174
- data/spec/lib/video_info/providers/wistia_spec.rb +59 -20
- data/spec/lib/video_info/providers/youtube_playlist_spec.rb +97 -41
- data/spec/lib/video_info/providers/youtube_scraper_spec.rb +14 -0
- data/spec/lib/video_info/providers/youtube_spec.rb +441 -384
- data/spec/lib/video_info_spec.rb +27 -25
- data/spec/spec_helper.rb +6 -1
- data/tmp/rspec_guard_result +25 -0
- data/video_info.gemspec +11 -14
- metadata +358 -100
- data/.travis.yml +0 -13
- data/foo.txt +0 -33
- data/lib/video_info/providers/vkontakte.rb +0 -170
- data/spec/lib/video_info/providers/vimeo_api_spec.rb +0 -242
- data/spec/lib/video_info/providers/vkontakte_spec.rb +0 -173
- data/spec/lib/video_info/providers/youtube_api_spec.rb +0 -476
- data/spec/lib/video_info/providers/youtube_playlist_api_spec.rb +0 -187
data/lib/video_info/provider.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
require 'open-uri'
|
2
|
-
require '
|
3
|
-
require '
|
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
|
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?(
|
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)}\"",
|
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(
|
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
|
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
|
-
|
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
|
-
|
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
|
-
|
71
|
+
%r{dai(?:\.ly|lymotion\.com\/(?:embed\/)?video)\/([a-zA-Z0-9]*)}
|
60
72
|
end
|
61
73
|
|
62
74
|
def _api_base
|
63
|
-
|
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}?
|
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 =~
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
43
|
+
generate_thumbnail(100, 75)
|
44
44
|
end
|
45
45
|
|
46
46
|
def thumbnail_medium
|
47
|
-
|
47
|
+
generate_thumbnail(200, 150)
|
48
48
|
end
|
49
49
|
|
50
50
|
def thumbnail_large
|
51
|
-
|
51
|
+
generate_thumbnail(640)
|
52
52
|
end
|
53
53
|
|
54
54
|
def keywords
|
55
|
-
keywords_array
|
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
|
-
|
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
|
-
|
11
|
+
if available?
|
12
|
+
json_info['author']['name']
|
13
|
+
end
|
10
14
|
end
|
11
15
|
|
12
16
|
def author_thumbnail
|
13
|
-
|
14
|
-
|
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
|
21
|
-
|
46
|
+
if data.nil?
|
47
|
+
is_available = false
|
48
|
+
elsif is_available
|
49
|
+
password_elements = data.css('.exception_title--password')
|
22
50
|
|
23
|
-
|
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
|
-
|
41
|
-
|
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
|
-
|
46
|
-
|
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
|
-
|
51
|
-
|
52
|
-
|
82
|
+
unless available?
|
83
|
+
return nil
|
84
|
+
end
|
53
85
|
|
54
|
-
|
86
|
+
if json_info['keywords']
|
87
|
+
json_info['keywords']
|
88
|
+
else
|
89
|
+
[]
|
90
|
+
end
|
55
91
|
end
|
56
92
|
|
57
93
|
def height
|
58
|
-
|
94
|
+
if available?
|
95
|
+
json_info['height']
|
96
|
+
end
|
59
97
|
end
|
60
98
|
|
61
99
|
def width
|
62
|
-
|
100
|
+
if available?
|
101
|
+
json_info['width']
|
102
|
+
end
|
63
103
|
end
|
64
104
|
|
65
105
|
def thumbnail_small
|
66
|
-
|
106
|
+
if available?
|
107
|
+
thumbnail_url.split('_')[0] + '_100x75.jpg'
|
108
|
+
end
|
67
109
|
end
|
68
110
|
|
69
111
|
def thumbnail_medium
|
70
|
-
|
112
|
+
if available?
|
113
|
+
thumbnail_url.split('_')[0] + '_200x150.jpg'
|
114
|
+
end
|
71
115
|
end
|
72
116
|
|
73
117
|
def thumbnail_large
|
74
|
-
|
118
|
+
if available?
|
119
|
+
thumbnail_url.split('_')[0] + '_640.jpg'
|
120
|
+
end
|
75
121
|
end
|
76
122
|
|
77
123
|
def view_count
|
78
|
-
|
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 ||=
|
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
|
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
|
-
|
@@ -16,7 +16,8 @@ class VideoInfo
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def self.usable?(url)
|
19
|
-
url =~
|
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
|
-
|
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
|