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
@@ -1,8 +1,7 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
|
-
describe VideoInfo::Providers::Wistia do
|
5
|
-
|
4
|
+
describe VideoInfo::Providers::Wistia, :vcr do
|
6
5
|
describe '.usable?' do
|
7
6
|
subject { VideoInfo::Providers::Wistia.usable?(url) }
|
8
7
|
|
@@ -18,8 +17,9 @@ describe VideoInfo::Providers::Wistia do
|
|
18
17
|
end
|
19
18
|
|
20
19
|
describe '#available?' do
|
21
|
-
context 'with valid video'
|
22
|
-
|
20
|
+
context 'with valid video' do
|
21
|
+
video_url = 'http://fast.wistia.net/embed/iframe/rs1me54mpw'
|
22
|
+
subject { VideoInfo.new(video_url.freeze) }
|
23
23
|
|
24
24
|
describe '#available?' do
|
25
25
|
subject { super().available? }
|
@@ -27,7 +27,7 @@ describe VideoInfo::Providers::Wistia do
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
-
context 'with invalid video'
|
30
|
+
context 'with invalid video' do
|
31
31
|
subject { VideoInfo.new('http://fast.wistia.net/embed/iframe/no_video') }
|
32
32
|
|
33
33
|
describe '#available?' do
|
@@ -35,10 +35,9 @@ describe VideoInfo::Providers::Wistia do
|
|
35
35
|
it { is_expected.to be_falsey }
|
36
36
|
end
|
37
37
|
end
|
38
|
-
|
39
38
|
end
|
40
39
|
|
41
|
-
context 'with video rs1me54mpw'
|
40
|
+
context 'with video rs1me54mpw' do
|
42
41
|
subject { VideoInfo.new('http://fast.wistia.net/embed/iframe/rs1me54mpw') }
|
43
42
|
|
44
43
|
describe '#provider' do
|
@@ -63,7 +62,9 @@ describe VideoInfo::Providers::Wistia do
|
|
63
62
|
|
64
63
|
describe '#embed_code' do
|
65
64
|
subject { super().embed_code }
|
66
|
-
|
65
|
+
embed_code = '<iframe src="//fast.wistia.net/embed/iframe/rs1me54mpw" '\
|
66
|
+
'frameborder="0"></iframe>'
|
67
|
+
it { is_expected.to eq embed_code }
|
67
68
|
end
|
68
69
|
|
69
70
|
describe '#title' do
|
@@ -88,21 +89,48 @@ describe VideoInfo::Providers::Wistia do
|
|
88
89
|
|
89
90
|
describe '#thumbnail_small' do
|
90
91
|
subject { super().thumbnail_small }
|
91
|
-
|
92
|
+
thumbnail_url = 'https://embed-ssl.wistia.com/deliveries/' \
|
93
|
+
'dc005e6a7583a25c4b7c284c08afc42fb67fdb95.jpg' \
|
94
|
+
'?image_crop_resized=960x540'
|
95
|
+
it { is_expected.to eq thumbnail_url }
|
92
96
|
end
|
93
97
|
|
94
98
|
describe '#thumbnail_medium' do
|
95
99
|
subject { super().thumbnail_small }
|
96
|
-
|
100
|
+
thumbnail_url = 'https://embed-ssl.wistia.com/deliveries/' \
|
101
|
+
'dc005e6a7583a25c4b7c284c08afc42fb67fdb95.jpg?' \
|
102
|
+
'image_crop_resized=960x540'
|
103
|
+
it { is_expected.to eq thumbnail_url }
|
97
104
|
end
|
98
|
-
|
105
|
+
|
99
106
|
describe '#thumbnail_large' do
|
100
107
|
subject { super().thumbnail_small }
|
101
|
-
|
108
|
+
thumbnail_url = 'https://embed-ssl.wistia.com/deliveries/' \
|
109
|
+
'dc005e6a7583a25c4b7c284c08afc42fb67fdb95.jpg' \
|
110
|
+
'?image_crop_resized=960x540'
|
111
|
+
it { is_expected.to eq thumbnail_url }
|
112
|
+
end
|
113
|
+
|
114
|
+
describe '#thumbnail_large_2x' do
|
115
|
+
subject { super().thumbnail_large_2x }
|
116
|
+
it { is_expected.to be_nil }
|
117
|
+
end
|
118
|
+
|
119
|
+
describe '#thumbnail_maxres' do
|
120
|
+
subject { super().thumbnail_maxres }
|
121
|
+
it { is_expected.to be_nil }
|
122
|
+
end
|
123
|
+
|
124
|
+
describe '#thumbnail' do
|
125
|
+
subject { super().thumbnail }
|
126
|
+
thumbnail_url = 'https://embed-ssl.wistia.com/deliveries/' \
|
127
|
+
'dc005e6a7583a25c4b7c284c08afc42fb67fdb95.jpg' \
|
128
|
+
'?image_crop_resized=960x540'
|
129
|
+
it { is_expected.to eq thumbnail_url }
|
102
130
|
end
|
103
131
|
end
|
104
132
|
|
105
|
-
context 'with video pxonqr42is'
|
133
|
+
context 'with video pxonqr42is' do
|
106
134
|
subject { VideoInfo.new('http://fast.wistia.com/embed/medias/pxonqr42is') }
|
107
135
|
|
108
136
|
describe '#provider' do
|
@@ -127,7 +155,9 @@ describe VideoInfo::Providers::Wistia do
|
|
127
155
|
|
128
156
|
describe '#embed_code' do
|
129
157
|
subject { super().embed_code }
|
130
|
-
|
158
|
+
embed_code = '<iframe src="//fast.wistia.net/embed/iframe/pxonqr42is" ' \
|
159
|
+
'frameborder="0"></iframe>'
|
160
|
+
it { is_expected.to eq embed_code }
|
131
161
|
end
|
132
162
|
|
133
163
|
describe '#title' do
|
@@ -137,7 +167,7 @@ describe VideoInfo::Providers::Wistia do
|
|
137
167
|
|
138
168
|
describe '#duration' do
|
139
169
|
subject { super().duration }
|
140
|
-
it { is_expected.to eq 250.
|
170
|
+
it { is_expected.to eq 250.428 }
|
141
171
|
end
|
142
172
|
|
143
173
|
describe '#width' do
|
@@ -147,22 +177,31 @@ describe VideoInfo::Providers::Wistia do
|
|
147
177
|
|
148
178
|
describe '#height' do
|
149
179
|
subject { super().height }
|
150
|
-
it { is_expected.to eq
|
180
|
+
it { is_expected.to eq 540 }
|
151
181
|
end
|
152
|
-
|
182
|
+
|
153
183
|
describe '#thumbnail_small' do
|
154
184
|
subject { super().thumbnail_small }
|
155
|
-
|
185
|
+
thumbnail_url = 'https://embed-ssl.wistia.com/deliveries/' \
|
186
|
+
'0fccbdc60ade35723f79f1c002bc61b135b610fa.jpg' \
|
187
|
+
'?image_crop_resized=960x540'
|
188
|
+
it { is_expected.to eq thumbnail_url }
|
156
189
|
end
|
157
190
|
|
158
191
|
describe '#thumbnail_medium' do
|
159
192
|
subject { super().thumbnail_small }
|
160
|
-
|
193
|
+
thumbnail_url = 'https://embed-ssl.wistia.com/deliveries/' \
|
194
|
+
'0fccbdc60ade35723f79f1c002bc61b135b610fa.jpg' \
|
195
|
+
'?image_crop_resized=960x540'
|
196
|
+
it { is_expected.to eq thumbnail_url }
|
161
197
|
end
|
162
198
|
|
163
199
|
describe '#thumbnail_large' do
|
164
200
|
subject { super().thumbnail_small }
|
165
|
-
|
201
|
+
thumbnail_url = 'https://embed-ssl.wistia.com/deliveries/' \
|
202
|
+
'0fccbdc60ade35723f79f1c002bc61b135b610fa.jpg' \
|
203
|
+
'?image_crop_resized=960x540'
|
204
|
+
it { is_expected.to eq thumbnail_url }
|
166
205
|
end
|
167
206
|
end
|
168
207
|
end
|
@@ -1,37 +1,39 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe VideoInfo::Providers::YoutubePlaylist do
|
4
|
-
before(:
|
5
|
-
|
3
|
+
describe VideoInfo::Providers::YoutubePlaylist, :vcr do
|
4
|
+
before(:each) do
|
5
|
+
api_key = ENV["YOUTUBE_API_KEY"] || "youtube_api_key_123"
|
6
|
+
VideoInfo.provider_api_keys = { youtube: api_key }
|
6
7
|
end
|
7
8
|
|
8
|
-
describe
|
9
|
+
describe '.usable?' do
|
9
10
|
subject { VideoInfo::Providers::YoutubePlaylist.usable?(url) }
|
10
11
|
|
11
|
-
context
|
12
|
+
context 'with youtube.com/playlist?p= url' do
|
12
13
|
let(:url) { 'http://www.youtube.com/playlist?p=PLA575C81A1FBC04CF' }
|
13
14
|
it { is_expected.to be_truthy }
|
14
15
|
end
|
15
16
|
|
16
|
-
context
|
17
|
+
context 'with youtube.com/playlist?list= url' do
|
17
18
|
let(:url) { 'http://www.youtube.com/playlist?list=PLA575C81A1FBC04CF' }
|
18
19
|
it { is_expected.to be_truthy }
|
19
20
|
end
|
20
21
|
|
21
|
-
context
|
22
|
+
context 'with youtube.com url' do
|
22
23
|
let(:url) { 'http://www.youtube.com/watch?v=Xp6CXF' }
|
23
24
|
it { is_expected.to be_falsey }
|
24
25
|
end
|
25
26
|
|
26
|
-
context
|
27
|
+
context 'with other url' do
|
27
28
|
let(:url) { 'http://example.com/video1' }
|
28
29
|
it { is_expected.to be_falsey }
|
29
30
|
end
|
30
31
|
end
|
31
32
|
|
32
|
-
describe
|
33
|
-
context
|
34
|
-
|
33
|
+
describe '#available?' do
|
34
|
+
context 'with valid playlist' do
|
35
|
+
playlist_url = 'http://www.youtube.com/playlist?p=PLA575C81A1FBC04CF'
|
36
|
+
subject { VideoInfo.new(playlist_url.freeze) }
|
35
37
|
|
36
38
|
describe '#available?' do
|
37
39
|
subject { super().available? }
|
@@ -39,8 +41,10 @@ describe VideoInfo::Providers::YoutubePlaylist do
|
|
39
41
|
end
|
40
42
|
end
|
41
43
|
|
42
|
-
context
|
43
|
-
|
44
|
+
context 'with invalid playlist' do
|
45
|
+
invalid_playlist_url = 'http://www.youtube.com/playlist?' \
|
46
|
+
'p=PLA575C81A1FBC04CF_invalid'
|
47
|
+
subject { VideoInfo.new(invalid_playlist_url) }
|
44
48
|
|
45
49
|
describe '#available?' do
|
46
50
|
subject { super().available? }
|
@@ -48,8 +52,9 @@ describe VideoInfo::Providers::YoutubePlaylist do
|
|
48
52
|
end
|
49
53
|
end
|
50
54
|
|
51
|
-
context
|
52
|
-
|
55
|
+
context 'with &list= url' do
|
56
|
+
playlist_url = 'http://www.youtube.com/playlist?list=PLA575C81A1FBC04CF'
|
57
|
+
subject { VideoInfo.new(playlist_url) }
|
53
58
|
|
54
59
|
describe '#available?' do
|
55
60
|
subject { super().available? }
|
@@ -58,18 +63,17 @@ describe VideoInfo::Providers::YoutubePlaylist do
|
|
58
63
|
end
|
59
64
|
end
|
60
65
|
|
61
|
-
context
|
62
|
-
let(:
|
66
|
+
context 'with playlist PL9hW1uS6HUftLdHI6RIsaf' do
|
67
|
+
let(:video_ids) do
|
63
68
|
[
|
64
|
-
|
65
|
-
VideoInfo.new('http://www.youtube.com/watch?v=_Bt3-WsHfB0'),
|
66
|
-
VideoInfo.new('http://www.youtube.com/watch?v=9g2U12SsRns'),
|
67
|
-
VideoInfo.new('http://www.youtube.com/watch?v=8b0aEoxqqC0'),
|
68
|
-
VideoInfo.new('http://www.youtube.com/watch?v=6c3mHikRz0I'),
|
69
|
-
VideoInfo.new('http://www.youtube.com/watch?v=OQVHWsTHcoc')
|
69
|
+
"9g2U12SsRns", "AsqTAkLKb4M", "K681ILSXyUY", "OQVHWsTHcoc", "QtwplSG6VvM", "WK8qRNSmhEU", "XIoGq39abMk", "eKkv1C_O-QI", "lau14lhZpoU", "HvplY9BPKG8", "mTdNi9Mqiu8", "qAVwpBZ1HYA"
|
70
70
|
]
|
71
|
-
|
72
|
-
|
71
|
+
end
|
72
|
+
|
73
|
+
playlist_url = 'http://www.youtube.com/playlist?' \
|
74
|
+
'p=PL9hW1uS6HUftLdHI6RIsaf-iXTm09qnEr'
|
75
|
+
|
76
|
+
subject { VideoInfo.new(playlist_url) }
|
73
77
|
|
74
78
|
describe '#provider' do
|
75
79
|
subject { super().provider }
|
@@ -83,17 +87,23 @@ describe VideoInfo::Providers::YoutubePlaylist do
|
|
83
87
|
|
84
88
|
describe '#url' do
|
85
89
|
subject { super().url }
|
86
|
-
it { is_expected.to eq
|
90
|
+
it { is_expected.to eq playlist_url }
|
87
91
|
end
|
88
92
|
|
89
93
|
describe '#embed_url' do
|
90
94
|
subject { super().embed_url }
|
91
|
-
|
95
|
+
embed_url = '//www.youtube.com/embed/videoseries' \
|
96
|
+
'?list=PL9hW1uS6HUftLdHI6RIsaf-iXTm09qnEr'
|
97
|
+
it { is_expected.to eq embed_url }
|
92
98
|
end
|
93
99
|
|
94
100
|
describe '#embed_code' do
|
95
101
|
subject { super().embed_code }
|
96
|
-
|
102
|
+
embed_code = '<iframe src="//www.youtube.com/embed/videoseries' \
|
103
|
+
'?list=PL9hW1uS6HUftLdHI6RIsaf-iXTm09qnEr" ' \
|
104
|
+
'frameborder="0" allowfullscreen="allowfullscreen">' \
|
105
|
+
'</iframe>'
|
106
|
+
it { is_expected.to eq embed_code }
|
97
107
|
end
|
98
108
|
|
99
109
|
describe '#title' do
|
@@ -103,7 +113,9 @@ describe VideoInfo::Providers::YoutubePlaylist do
|
|
103
113
|
|
104
114
|
describe '#description' do
|
105
115
|
subject { super().description }
|
106
|
-
|
116
|
+
description_text = 'Learn more about copyright basics, flagging, ' \
|
117
|
+
'and the YouTube community.'
|
118
|
+
it { is_expected.to eq description_text }
|
107
119
|
end
|
108
120
|
|
109
121
|
describe '#keywords' do
|
@@ -133,32 +145,76 @@ describe VideoInfo::Providers::YoutubePlaylist do
|
|
133
145
|
|
134
146
|
describe '#thumbnail_small' do
|
135
147
|
subject { super().thumbnail_small }
|
136
|
-
|
148
|
+
thumbnail_url = 'https://i.ytimg.com/vi/9g2U12SsRns/default.jpg'
|
149
|
+
it { is_expected.to eq thumbnail_url }
|
137
150
|
end
|
138
151
|
|
139
152
|
describe '#thumbnail_medium' do
|
140
153
|
subject { super().thumbnail_medium }
|
141
|
-
|
154
|
+
thumbnail_url = 'https://i.ytimg.com/vi/9g2U12SsRns/mqdefault.jpg'
|
155
|
+
it { is_expected.to eq thumbnail_url }
|
142
156
|
end
|
143
157
|
|
144
158
|
describe '#thumbnail_large' do
|
145
159
|
subject { super().thumbnail_large }
|
146
|
-
|
160
|
+
thumbnail_url = 'https://i.ytimg.com/vi/9g2U12SsRns/hqdefault.jpg'
|
161
|
+
it { is_expected.to eq thumbnail_url }
|
162
|
+
end
|
163
|
+
|
164
|
+
describe '#thumbnail_large_2x' do
|
165
|
+
subject { super().thumbnail_large_2x }
|
166
|
+
thumbnail_url = 'https://i.ytimg.com/vi/9g2U12SsRns/sddefault.jpg'
|
167
|
+
it { is_expected.to eq thumbnail_url }
|
168
|
+
end
|
169
|
+
|
170
|
+
describe '#thumbnail_maxres' do
|
171
|
+
subject { super().thumbnail_maxres }
|
172
|
+
thumbnail_url = 'https://i.ytimg.com/vi/9g2U12SsRns/maxresdefault.jpg'
|
173
|
+
it { is_expected.to eq thumbnail_url }
|
174
|
+
end
|
175
|
+
|
176
|
+
describe '#thumbnail' do
|
177
|
+
subject { super().thumbnail }
|
178
|
+
thumbnail_url = 'https://i.ytimg.com/vi/9g2U12SsRns/default.jpg'
|
179
|
+
it { is_expected.to eq thumbnail_url }
|
147
180
|
end
|
148
181
|
|
149
182
|
describe '#videos' do
|
150
|
-
subject { super().videos }
|
151
|
-
it
|
183
|
+
subject { super().videos.map(&:video_id) }
|
184
|
+
it 'returns list of videos in playlist' do
|
185
|
+
is_expected.to match_array(video_ids)
|
186
|
+
end
|
152
187
|
end
|
153
188
|
|
154
189
|
describe '#view_count' do
|
155
190
|
subject { super().view_count }
|
156
191
|
it { is_expected.to be_nil }
|
157
192
|
end
|
193
|
+
|
194
|
+
describe '#author' do
|
195
|
+
subject { super().author }
|
196
|
+
it { is_expected.to eq 'TeamYouTube [Help]' }
|
197
|
+
end
|
198
|
+
|
199
|
+
describe '#author_thumbnail' do
|
200
|
+
subject { super().author_thumbnail }
|
201
|
+
author_thumbnail = 'https://yt3.ggpht.com/a/' \
|
202
|
+
'AATXAJwyEv0uEyk3JLskjLiUCqSVzsGmpWw2icLfBOBzWg' \
|
203
|
+
'=s88-c-k-c0x00ffffff-no-rj'
|
204
|
+
it { is_expected.to eq author_thumbnail }
|
205
|
+
end
|
206
|
+
|
207
|
+
describe '#author_url' do
|
208
|
+
subject { super().author_url }
|
209
|
+
author_url = 'https://www.youtube.com/channel/UCMDQxm7cUx3yXkfeHa5zJIQ'
|
210
|
+
it { is_expected.to eq author_url }
|
211
|
+
end
|
158
212
|
end
|
159
213
|
|
160
|
-
context
|
161
|
-
|
214
|
+
context 'with playlist that does not exist in embed path' do
|
215
|
+
playlist_url = 'http://www.youtube.com/embed/videoseries?' \
|
216
|
+
'list=PL0E8117603D70E10A'
|
217
|
+
subject { VideoInfo.new(playlist_url) }
|
162
218
|
|
163
219
|
describe '#playlist_id' do
|
164
220
|
subject { super().playlist_id }
|
@@ -167,18 +223,18 @@ describe VideoInfo::Providers::YoutubePlaylist do
|
|
167
223
|
|
168
224
|
describe '#videos' do
|
169
225
|
subject { super().videos }
|
170
|
-
it {
|
226
|
+
it { is_expected.to eq [] }
|
171
227
|
end
|
172
228
|
end
|
173
229
|
|
174
|
-
context
|
175
|
-
|
230
|
+
context 'with playlist valid playlist in embed path' do
|
231
|
+
playlist_url = 'http://www.youtube.com/embed/videoseries' \
|
232
|
+
'?list=PL9hW1uS6HUftLdHI6RIsaf-iXTm09qnEr'
|
233
|
+
subject { VideoInfo.new(playlist_url) }
|
176
234
|
|
177
235
|
describe '#playlist_id' do
|
178
236
|
subject { super().playlist_id }
|
179
237
|
it { is_expected.to eq 'PL9hW1uS6HUftLdHI6RIsaf-iXTm09qnEr' }
|
180
238
|
end
|
181
239
|
end
|
182
|
-
|
183
|
-
|
184
240
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe VideoInfo::Providers::Youtube do
|
4
|
+
before { VideoInfo.provider_api_keys = {} }
|
5
|
+
|
6
|
+
context 'with a video without description', :vcr do
|
7
|
+
subject { VideoInfo.new('http://www.youtube.com/watch?v=WVsj2pS-zFY') }
|
8
|
+
|
9
|
+
describe '#description' do
|
10
|
+
subject { super().description }
|
11
|
+
it { is_expected.to eq " " }
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -1,67 +1,160 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require 'webmock/rspec'
|
3
2
|
|
4
|
-
|
5
|
-
describe
|
6
|
-
|
7
|
-
|
8
|
-
context "with youtube.com url" do
|
9
|
-
let(:url) { 'http://www.youtube.com/watch?v=Xp6CXF' }
|
10
|
-
it { is_expected.to be_truthy }
|
3
|
+
[nil, ENV["YOUTUBE_API_KEY"] || "youtube_api_key_123"].each do |api_key|
|
4
|
+
describe VideoInfo::Providers::Youtube, :vcr do
|
5
|
+
before(:all) do
|
6
|
+
VideoInfo.provider_api_keys = { youtube: api_key }
|
11
7
|
end
|
12
8
|
|
13
|
-
|
14
|
-
|
15
|
-
it { is_expected.to be_truthy }
|
16
|
-
end
|
9
|
+
describe '.usable?' do
|
10
|
+
subject { VideoInfo::Providers::Youtube.usable?(url) }
|
17
11
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
12
|
+
context 'with youtube.com url' do
|
13
|
+
let(:url) { 'http://www.youtube.com/watch?v=Xp6CXF' }
|
14
|
+
it { is_expected.to be_truthy }
|
15
|
+
end
|
22
16
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
end
|
17
|
+
context 'with youtu.be url' do
|
18
|
+
let(:url) { 'http://youtu.be/JM9NgvjjVng' }
|
19
|
+
it { is_expected.to be_truthy }
|
20
|
+
end
|
28
21
|
|
29
|
-
|
30
|
-
|
31
|
-
|
22
|
+
context 'with other url' do
|
23
|
+
let(:url) { 'http://google.com/video1' }
|
24
|
+
it { is_expected.to be_falsey }
|
25
|
+
end
|
32
26
|
|
33
|
-
|
34
|
-
|
35
|
-
it { is_expected.to
|
27
|
+
context 'with playlist url' do
|
28
|
+
let(:url) { 'http://www.youtube.com/playlist?p=PLA575C81A1FBC04CF' }
|
29
|
+
it { is_expected.to be_falsey }
|
36
30
|
end
|
37
31
|
end
|
38
32
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
before do
|
43
|
-
VideoInfo.provider_api_keys[:youtube] = 'invalid_key'
|
44
|
-
end
|
33
|
+
describe '#available?' do
|
34
|
+
context 'with valid video' do
|
35
|
+
subject { VideoInfo.new('http://www.youtube.com/watch?v=mZqGqE0D0n4'.freeze) }
|
45
36
|
|
46
|
-
|
47
|
-
|
37
|
+
describe '#available?' do
|
38
|
+
subject { super().available? }
|
39
|
+
it { is_expected.to be_truthy }
|
40
|
+
end
|
48
41
|
end
|
49
42
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
43
|
+
context 'with unavailable video' do
|
44
|
+
subject { VideoInfo.new('http://www.youtube.com/watch?v=SUkXvWn1m7Q') }
|
45
|
+
|
46
|
+
describe '#available?' do
|
47
|
+
subject { super().available? }
|
48
|
+
it { is_expected.to be_falsey }
|
49
|
+
end
|
50
|
+
|
51
|
+
describe '#provider' do
|
52
|
+
subject { super().provider }
|
53
|
+
it { is_expected.to eq 'YouTube' }
|
54
|
+
end
|
55
|
+
|
56
|
+
describe '#video_id' do
|
57
|
+
subject { super().video_id }
|
58
|
+
it { is_expected.to eq 'SUkXvWn1m7Q' }
|
59
|
+
end
|
60
|
+
|
61
|
+
describe '#url' do
|
62
|
+
subject { super().url }
|
63
|
+
it { is_expected.to eq 'http://www.youtube.com/watch?v=SUkXvWn1m7Q' }
|
64
|
+
end
|
65
|
+
|
66
|
+
describe '#embed_url' do
|
67
|
+
subject { super().embed_url }
|
68
|
+
it { is_expected.to eq '//www.youtube.com/embed/SUkXvWn1m7Q' }
|
69
|
+
end
|
70
|
+
|
71
|
+
describe '#embed_code' do
|
72
|
+
subject { super().embed_code }
|
73
|
+
embed_code = '<iframe src="//www.youtube.com/embed/SUkXvWn1m7Q" ' \
|
74
|
+
'frameborder="0" allowfullscreen="allowfullscreen">' \
|
75
|
+
'</iframe>'
|
76
|
+
it { is_expected.to eq embed_code }
|
77
|
+
end
|
78
|
+
|
79
|
+
describe '#title' do
|
80
|
+
subject { super().title }
|
81
|
+
it { is_expected.to eq nil }
|
82
|
+
end
|
83
|
+
|
84
|
+
describe '#description' do
|
85
|
+
subject { super().description }
|
86
|
+
it { is_expected.to eq nil }
|
87
|
+
end
|
88
|
+
|
89
|
+
describe '#keywords' do
|
90
|
+
subject { super().keywords }
|
91
|
+
it { is_expected.to be_nil }
|
92
|
+
end
|
93
|
+
|
94
|
+
describe '#duration' do
|
95
|
+
subject { super().duration }
|
96
|
+
it { is_expected.to eq 0 }
|
97
|
+
end
|
98
|
+
|
99
|
+
describe '#date' do
|
100
|
+
subject { super().date }
|
101
|
+
it { is_expected.to eq nil }
|
102
|
+
end
|
103
|
+
|
104
|
+
describe '#thumbnail_small' do
|
105
|
+
subject { super().thumbnail_small }
|
106
|
+
thumbnail_url = 'https://i.ytimg.com/vi/SUkXvWn1m7Q/default.jpg'
|
107
|
+
it { is_expected.to eq thumbnail_url }
|
108
|
+
end
|
109
|
+
|
110
|
+
describe '#thumbnail_medium' do
|
111
|
+
subject { super().thumbnail_medium }
|
112
|
+
thumbnail_url = 'https://i.ytimg.com/vi/SUkXvWn1m7Q/mqdefault.jpg'
|
113
|
+
it { is_expected.to eq thumbnail_url }
|
114
|
+
end
|
115
|
+
|
116
|
+
describe '#thumbnail_large' do
|
117
|
+
subject { super().thumbnail_large }
|
118
|
+
thumbnail_url = 'https://i.ytimg.com/vi/SUkXvWn1m7Q/hqdefault.jpg'
|
119
|
+
it { is_expected.to eq thumbnail_url }
|
120
|
+
end
|
121
|
+
|
122
|
+
describe '#thumbnail_large_2x' do
|
123
|
+
subject { super().thumbnail_large_2x }
|
124
|
+
thumbnail_url = 'https://i.ytimg.com/vi/SUkXvWn1m7Q/sddefault.jpg'
|
125
|
+
it { is_expected.to eq thumbnail_url }
|
126
|
+
end
|
127
|
+
|
128
|
+
describe '#thumbnail_maxres' do
|
129
|
+
subject { super().thumbnail_maxres }
|
130
|
+
thumbnail_url = 'https://i.ytimg.com/vi/SUkXvWn1m7Q/maxresdefault.jpg'
|
131
|
+
it { is_expected.to eq thumbnail_url }
|
132
|
+
end
|
133
|
+
|
134
|
+
describe '#thumbnail' do
|
135
|
+
subject { super().thumbnail }
|
136
|
+
thumbnail_url = 'https://i.ytimg.com/vi/SUkXvWn1m7Q/hqdefault.jpg'
|
137
|
+
it { is_expected.to eq thumbnail_url }
|
138
|
+
end
|
139
|
+
|
140
|
+
describe '#view_count' do
|
141
|
+
subject { super().view_count }
|
142
|
+
it { is_expected.to be == 0 }
|
54
143
|
end
|
55
144
|
end
|
56
|
-
end
|
57
145
|
|
58
|
-
|
59
|
-
|
146
|
+
context 'with video removed because of copyright claim' do
|
147
|
+
subject { VideoInfo.new('http://www.youtube.com/watch?v=ffClNhwx0KU') }
|
60
148
|
|
61
|
-
|
62
|
-
|
63
|
-
|
149
|
+
describe '#available?' do
|
150
|
+
subject { super().available? }
|
151
|
+
it { is_expected.to be_falsey }
|
152
|
+
end
|
64
153
|
end
|
154
|
+
end
|
155
|
+
|
156
|
+
context 'with video mZqGqE0D0n4' do
|
157
|
+
subject { VideoInfo.new('http://www.youtube.com/watch?v=mZqGqE0D0n4') }
|
65
158
|
|
66
159
|
describe '#provider' do
|
67
160
|
subject { super().provider }
|
@@ -70,472 +163,436 @@ describe VideoInfo::Providers::Youtube do
|
|
70
163
|
|
71
164
|
describe '#video_id' do
|
72
165
|
subject { super().video_id }
|
73
|
-
it { is_expected.to eq '
|
166
|
+
it { is_expected.to eq 'mZqGqE0D0n4' }
|
74
167
|
end
|
75
168
|
|
76
169
|
describe '#url' do
|
77
170
|
subject { super().url }
|
78
|
-
it { is_expected.to eq 'http://www.youtube.com/watch?v=
|
171
|
+
it { is_expected.to eq 'http://www.youtube.com/watch?v=mZqGqE0D0n4' }
|
79
172
|
end
|
80
173
|
|
81
174
|
describe '#embed_url' do
|
82
175
|
subject { super().embed_url }
|
83
|
-
it { is_expected.to eq '//www.youtube.com/embed/
|
176
|
+
it { is_expected.to eq '//www.youtube.com/embed/mZqGqE0D0n4' }
|
84
177
|
end
|
85
178
|
|
86
179
|
describe '#embed_code' do
|
87
180
|
subject { super().embed_code }
|
88
|
-
|
181
|
+
embed_code = '<iframe src="//www.youtube.com/embed/mZqGqE0D0n4" ' \
|
182
|
+
'frameborder="0" allowfullscreen="allowfullscreen">' \
|
183
|
+
'</iframe>'
|
184
|
+
it { is_expected.to eq embed_code }
|
185
|
+
end
|
186
|
+
|
187
|
+
describe '#author' do
|
188
|
+
subject { super().author }
|
189
|
+
it { is_expected.to eql 'Cherry Bloom' }
|
190
|
+
end
|
191
|
+
|
192
|
+
describe '#author_thumbnail' do
|
193
|
+
subject { super().author_thumbnail }
|
194
|
+
author_thumbnail = 'https://yt3.ggpht.com/a/' \
|
195
|
+
'AATXAJyf5l8p3WQvOx-Q0o8ssGmIL-K5taxKHv5ZEEYc' \
|
196
|
+
'=s88-c-k-c0x00ffffff-no-rj'
|
197
|
+
|
198
|
+
it { is_expected.to eql author_thumbnail }
|
199
|
+
end
|
200
|
+
|
201
|
+
describe '#author_url' do
|
202
|
+
author_url = 'https://www.youtube.com/channel/UCzxQk-rZGowoqMBKxGD5jSA'
|
203
|
+
|
204
|
+
it { expect(subject.author_url).to eql(author_url) }
|
205
|
+
|
206
|
+
it 'can be called twice and receive the same value' do
|
207
|
+
expect(subject.author_url).to eq(subject.author_url)
|
208
|
+
end
|
89
209
|
end
|
90
210
|
|
91
211
|
describe '#title' do
|
92
212
|
subject { super().title }
|
93
|
-
it { is_expected.to eq
|
213
|
+
it { is_expected.to eq 'Cherry Bloom - King Of The Knife' }
|
94
214
|
end
|
95
215
|
|
96
216
|
describe '#description' do
|
97
217
|
subject { super().description }
|
98
|
-
|
218
|
+
description = 'The first video from the upcoming album Secret Sounds,' \
|
219
|
+
' to download in-stores April 14. ' \
|
220
|
+
'Checkout http://www.cherrybloom.net'
|
221
|
+
it { is_expected.to eq description }
|
99
222
|
end
|
100
223
|
|
101
224
|
describe '#keywords' do
|
102
225
|
subject { super().keywords }
|
103
|
-
|
226
|
+
keywords_list = %w(cherry bloom king of the knife guitar
|
227
|
+
drum clip rock alternative tremplin Paris-Forum)
|
228
|
+
it { is_expected.to eq keywords_list }
|
104
229
|
end
|
105
230
|
|
106
231
|
describe '#duration' do
|
107
232
|
subject { super().duration }
|
108
|
-
it { is_expected.to eq
|
233
|
+
it { is_expected.to eq 176 }
|
234
|
+
end
|
235
|
+
|
236
|
+
describe '#width' do
|
237
|
+
subject { super().width }
|
238
|
+
it { is_expected.to be_nil }
|
239
|
+
end
|
240
|
+
|
241
|
+
describe '#height' do
|
242
|
+
subject { super().height }
|
243
|
+
it { is_expected.to be_nil }
|
109
244
|
end
|
110
245
|
|
111
246
|
describe '#date' do
|
112
247
|
subject { super().date }
|
113
|
-
|
248
|
+
|
249
|
+
it 'should return date video was posted' do
|
250
|
+
if api_key.nil?
|
251
|
+
is_expected.to eq Time.parse('Sat Apr 12 2008', Time.now.utc)
|
252
|
+
else
|
253
|
+
is_expected.to eq Time.parse('Sat Apr 12 22:34:48 UTC 2008',
|
254
|
+
Time.now.utc)
|
255
|
+
end
|
256
|
+
end
|
114
257
|
end
|
115
258
|
|
116
259
|
describe '#thumbnail_small' do
|
117
260
|
subject { super().thumbnail_small }
|
118
|
-
|
261
|
+
thumbnail_url = 'https://i.ytimg.com/vi/mZqGqE0D0n4/default.jpg'
|
262
|
+
it { is_expected.to eq thumbnail_url }
|
119
263
|
end
|
120
264
|
|
121
265
|
describe '#thumbnail_medium' do
|
122
266
|
subject { super().thumbnail_medium }
|
123
|
-
|
267
|
+
thumbnail_url = 'https://i.ytimg.com/vi/mZqGqE0D0n4/mqdefault.jpg'
|
268
|
+
it { is_expected.to eq thumbnail_url }
|
124
269
|
end
|
125
270
|
|
126
271
|
describe '#thumbnail_large' do
|
127
272
|
subject { super().thumbnail_large }
|
128
|
-
|
273
|
+
thumbnail_url = 'https://i.ytimg.com/vi/mZqGqE0D0n4/hqdefault.jpg'
|
274
|
+
it { is_expected.to eq thumbnail_url }
|
129
275
|
end
|
130
276
|
|
131
|
-
describe '#
|
132
|
-
subject { super().
|
133
|
-
|
277
|
+
describe '#thumbnail_large_2x' do
|
278
|
+
subject { super().thumbnail_large_2x }
|
279
|
+
thumbnail_url = 'https://i.ytimg.com/vi/mZqGqE0D0n4/sddefault.jpg'
|
280
|
+
it { is_expected.to eq thumbnail_url }
|
134
281
|
end
|
135
|
-
end
|
136
|
-
|
137
|
-
context "with 'video no longer available due to a copyright claim' video", :vcr do
|
138
|
-
subject { VideoInfo.new('http://www.youtube.com/watch?v=ffClNhwx0KU') }
|
139
282
|
|
140
|
-
describe '#
|
141
|
-
subject { super().
|
142
|
-
|
283
|
+
describe '#thumbnail_maxres' do
|
284
|
+
subject { super().thumbnail_maxres }
|
285
|
+
thumbnail_url = 'https://i.ytimg.com/vi/mZqGqE0D0n4/maxresdefault.jpg'
|
286
|
+
it { is_expected.to eq thumbnail_url }
|
143
287
|
end
|
144
|
-
end
|
145
|
-
end
|
146
|
-
|
147
|
-
context "with video mZqGqE0D0n4", :vcr do
|
148
|
-
subject { VideoInfo.new('http://www.youtube.com/watch?v=mZqGqE0D0n4') }
|
149
|
-
|
150
|
-
describe '#provider' do
|
151
|
-
subject { super().provider }
|
152
|
-
it { is_expected.to eq 'YouTube' }
|
153
|
-
end
|
154
|
-
|
155
|
-
describe '#video_id' do
|
156
|
-
subject { super().video_id }
|
157
|
-
it { is_expected.to eq 'mZqGqE0D0n4' }
|
158
|
-
end
|
159
|
-
|
160
|
-
describe '#url' do
|
161
|
-
subject { super().url }
|
162
|
-
it { is_expected.to eq 'http://www.youtube.com/watch?v=mZqGqE0D0n4' }
|
163
|
-
end
|
164
|
-
|
165
|
-
describe '#embed_url' do
|
166
|
-
subject { super().embed_url }
|
167
|
-
it { is_expected.to eq '//www.youtube.com/embed/mZqGqE0D0n4' }
|
168
|
-
end
|
169
|
-
|
170
|
-
describe '#embed_code' do
|
171
|
-
subject { super().embed_code }
|
172
|
-
it { is_expected.to eq '<iframe src="//www.youtube.com/embed/mZqGqE0D0n4" frameborder="0" allowfullscreen="allowfullscreen"></iframe>' }
|
173
|
-
end
|
174
|
-
|
175
|
-
describe '#title' do
|
176
|
-
subject { super().title }
|
177
|
-
it { is_expected.to eq 'Cherry Bloom - King Of The Knife' }
|
178
|
-
end
|
179
|
-
|
180
|
-
describe '#description' do
|
181
|
-
subject { super().description }
|
182
|
-
it { is_expected.to eq 'The first video from the upcoming album Secret Sounds, to download in-stores April 14. Checkout http://www.cherrybloom.net' }
|
183
|
-
end
|
184
|
-
|
185
|
-
describe '#keywords' do
|
186
|
-
subject { super().keywords }
|
187
|
-
it { is_expected.to eq %w(cherry bloom king of the knife guitar drum clip rock alternative tremplin Paris-Forum) }
|
188
|
-
end
|
189
|
-
|
190
|
-
describe '#duration' do
|
191
|
-
subject { super().duration }
|
192
|
-
it { is_expected.to eq 176 }
|
193
|
-
end
|
194
|
-
|
195
|
-
describe '#width' do
|
196
|
-
subject { super().width }
|
197
|
-
it { is_expected.to be_nil }
|
198
|
-
end
|
199
|
-
|
200
|
-
describe '#height' do
|
201
|
-
subject { super().height }
|
202
|
-
it { is_expected.to be_nil }
|
203
|
-
end
|
204
|
-
|
205
|
-
describe '#date' do
|
206
|
-
subject { super().date }
|
207
|
-
it { is_expected.to eq Time.parse('Sat Apr 12 2008', Time.now.utc) }
|
208
|
-
end
|
209
|
-
|
210
|
-
describe '#thumbnail_small' do
|
211
|
-
subject { super().thumbnail_small }
|
212
|
-
it { is_expected.to eq 'https://i.ytimg.com/vi/mZqGqE0D0n4/default.jpg' }
|
213
|
-
end
|
214
|
-
|
215
|
-
describe '#thumbnail_medium' do
|
216
|
-
subject { super().thumbnail_medium }
|
217
|
-
it { is_expected.to eq 'https://i.ytimg.com/vi/mZqGqE0D0n4/mqdefault.jpg' }
|
218
|
-
end
|
219
|
-
|
220
|
-
describe '#thumbnail_large' do
|
221
|
-
subject { super().thumbnail_large }
|
222
|
-
it { is_expected.to eq 'https://i.ytimg.com/vi/mZqGqE0D0n4/hqdefault.jpg' }
|
223
|
-
end
|
224
|
-
|
225
|
-
describe '#view_count' do
|
226
|
-
subject { super().view_count }
|
227
|
-
it { is_expected.to be > 4000 }
|
228
|
-
end
|
229
|
-
end
|
230
|
-
|
231
|
-
context "with video oQ49W_xKzKA", :vcr do
|
232
|
-
subject { VideoInfo.new('http://www.youtube.com/watch?v=oQ49W_xKzKA') }
|
233
|
-
|
234
|
-
it { expect(subject.embed_code(url_attributes: { autoplay: 1 })).to match(/autoplay=1/) }
|
235
|
-
end
|
236
|
-
|
237
|
-
context "with video oQ49W_xKzKA", :vcr do
|
238
|
-
subject { VideoInfo.new('http://www.youtube.com/watch?v=oQ49W_xKzKA') }
|
239
|
-
|
240
|
-
describe '#provider' do
|
241
|
-
subject { super().provider }
|
242
|
-
it { is_expected.to eq 'YouTube' }
|
243
|
-
end
|
244
288
|
|
245
|
-
|
246
|
-
|
247
|
-
|
289
|
+
describe '#view_count' do
|
290
|
+
subject { super().view_count }
|
291
|
+
it { is_expected.to be > 4000 }
|
292
|
+
end
|
248
293
|
end
|
249
|
-
end
|
250
294
|
|
251
|
-
|
252
|
-
|
295
|
+
context 'with video oQ49W_xKzKA' do
|
296
|
+
subject { VideoInfo.new('http://www.youtube.com/watch?v=oQ49W_xKzKA') }
|
253
297
|
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
describe '#video_id' do
|
260
|
-
subject { super().video_id }
|
261
|
-
it { is_expected.to eq 'Xp6CXF-Cesg' }
|
298
|
+
it 'should properly apply arbitrary url attributes' do
|
299
|
+
embed_code = subject.embed_code(url_attributes: { autoplay: 1 })
|
300
|
+
expect(embed_code).to match(/autoplay=1/)
|
301
|
+
end
|
262
302
|
end
|
263
|
-
end
|
264
303
|
|
265
|
-
|
266
|
-
|
304
|
+
context 'with video oQ49W_xKzKA' do
|
305
|
+
subject { VideoInfo.new('http://www.youtube.com/watch?v=oQ49W_xKzKA') }
|
267
306
|
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
307
|
+
describe '#provider' do
|
308
|
+
subject { super().provider }
|
309
|
+
it { is_expected.to eq 'YouTube' }
|
310
|
+
end
|
272
311
|
|
273
|
-
|
274
|
-
|
275
|
-
|
312
|
+
describe '#video_id' do
|
313
|
+
subject { super().video_id }
|
314
|
+
it { is_expected.to eq 'oQ49W_xKzKA' }
|
315
|
+
end
|
276
316
|
end
|
277
317
|
|
278
|
-
|
279
|
-
subject {
|
280
|
-
it { is_expected.to eq 'http://www.youtube.com/user/EducatorVids3?v=VeasFckfMHY' }
|
281
|
-
end
|
282
|
-
end
|
318
|
+
context 'with video Xp6CXF-Cesg' do
|
319
|
+
subject { VideoInfo.new('http://www.youtube.com/watch?v=Xp6CXF-Cesg') }
|
283
320
|
|
284
|
-
|
285
|
-
|
321
|
+
describe '#provider' do
|
322
|
+
subject { super().provider }
|
323
|
+
it { is_expected.to eq 'YouTube' }
|
324
|
+
end
|
286
325
|
|
287
|
-
|
288
|
-
|
289
|
-
|
326
|
+
describe '#video_id' do
|
327
|
+
subject { super().video_id }
|
328
|
+
it { is_expected.to eq 'Xp6CXF-Cesg' }
|
329
|
+
end
|
290
330
|
end
|
291
331
|
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
end
|
332
|
+
context 'with video VeasFckfMHY in user url' do
|
333
|
+
video_url = 'http://www.youtube.com/user/EducatorVids3?v=VeasFckfMHY'
|
334
|
+
subject { VideoInfo.new(video_url) }
|
296
335
|
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
end
|
336
|
+
describe '#provider' do
|
337
|
+
subject { super().provider }
|
338
|
+
it { is_expected.to eq 'YouTube' }
|
339
|
+
end
|
302
340
|
|
303
|
-
|
304
|
-
|
341
|
+
describe '#video_id' do
|
342
|
+
subject { super().video_id }
|
343
|
+
it { is_expected.to eq 'VeasFckfMHY' }
|
344
|
+
end
|
305
345
|
|
306
|
-
|
307
|
-
|
308
|
-
|
346
|
+
describe '#url' do
|
347
|
+
subject { super().url }
|
348
|
+
it { is_expected.to eq video_url }
|
349
|
+
end
|
309
350
|
end
|
310
351
|
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
end
|
315
|
-
end
|
352
|
+
context 'with video VeasFckfMHY after params' do
|
353
|
+
video_url = 'http://www.youtube.com/watch?feature=player_profilepage&v=VeasFckfMHY'
|
354
|
+
subject { VideoInfo.new(video_url) }
|
316
355
|
|
317
|
-
|
318
|
-
|
356
|
+
describe '#provider' do
|
357
|
+
subject { super().provider }
|
358
|
+
it { is_expected.to eq 'YouTube' }
|
359
|
+
end
|
319
360
|
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
361
|
+
describe '#video_id' do
|
362
|
+
subject { super().video_id }
|
363
|
+
it { is_expected.to eq 'VeasFckfMHY' }
|
364
|
+
end
|
324
365
|
|
325
|
-
|
326
|
-
|
327
|
-
|
366
|
+
describe '#url' do
|
367
|
+
subject { super().url }
|
368
|
+
it { is_expected.to eq video_url }
|
369
|
+
end
|
328
370
|
end
|
329
|
-
end
|
330
371
|
|
331
|
-
|
332
|
-
|
372
|
+
context 'with video VeasFckfMHY in path' do
|
373
|
+
subject { VideoInfo.new('http://www.youtube.com/v/VeasFckfMHY') }
|
333
374
|
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
375
|
+
describe '#provider' do
|
376
|
+
subject { super().provider }
|
377
|
+
it { is_expected.to eq 'YouTube' }
|
378
|
+
end
|
338
379
|
|
339
|
-
|
340
|
-
|
341
|
-
|
380
|
+
describe '#video_id' do
|
381
|
+
subject { super().video_id }
|
382
|
+
it { is_expected.to eq 'VeasFckfMHY' }
|
383
|
+
end
|
342
384
|
end
|
343
|
-
end
|
344
385
|
|
345
|
-
|
346
|
-
|
386
|
+
context 'with video VeasFckfMHY in e path' do
|
387
|
+
subject { VideoInfo.new('http://www.youtube.com/e/VeasFckfMHY') }
|
347
388
|
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
389
|
+
describe '#provider' do
|
390
|
+
subject { super().provider }
|
391
|
+
it { is_expected.to eq 'YouTube' }
|
392
|
+
end
|
352
393
|
|
353
|
-
|
354
|
-
|
355
|
-
|
394
|
+
describe '#video_id' do
|
395
|
+
subject { super().video_id }
|
396
|
+
it { is_expected.to eq 'VeasFckfMHY' }
|
397
|
+
end
|
356
398
|
end
|
357
|
-
end
|
358
399
|
|
359
|
-
|
360
|
-
|
400
|
+
context 'with video VeasFckfMHY in embed path' do
|
401
|
+
subject { VideoInfo.new('http://www.youtube.com/embed/VeasFckfMHY') }
|
361
402
|
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
403
|
+
describe '#provider' do
|
404
|
+
subject { super().provider }
|
405
|
+
it { is_expected.to eq 'YouTube' }
|
406
|
+
end
|
366
407
|
|
367
|
-
|
368
|
-
|
369
|
-
|
408
|
+
describe '#video_id' do
|
409
|
+
subject { super().video_id }
|
410
|
+
it { is_expected.to eq 'VeasFckfMHY' }
|
411
|
+
end
|
370
412
|
end
|
371
|
-
end
|
372
413
|
|
373
|
-
|
374
|
-
|
414
|
+
context 'with video JM9NgvjjVng in youtu.be url' do
|
415
|
+
subject { VideoInfo.new('http://youtu.be/JM9NgvjjVng') }
|
375
416
|
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
417
|
+
describe '#provider' do
|
418
|
+
subject { super().provider }
|
419
|
+
it { is_expected.to eq 'YouTube' }
|
420
|
+
end
|
380
421
|
|
381
|
-
|
382
|
-
|
383
|
-
|
422
|
+
describe '#video_id' do
|
423
|
+
subject { super().video_id }
|
424
|
+
it { is_expected.to eq 'JM9NgvjjVng' }
|
425
|
+
end
|
384
426
|
end
|
385
|
-
end
|
386
427
|
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
describe '#provider' do
|
391
|
-
subject { super().provider }
|
392
|
-
it { is_expected.to eq('YouTube') }
|
393
|
-
end
|
394
|
-
it { expect(subject.embed_code(iframe_attributes: { width: 800, height: 600 })).to match(/width="800"/) }
|
395
|
-
it { expect(subject.embed_code(iframe_attributes: { width: 800, height: 600 })).to match(/height="600"/) }
|
396
|
-
end
|
428
|
+
context 'without http or www' do
|
429
|
+
subject { VideoInfo.new('youtu.be/JM9NgvjjVng') }
|
397
430
|
|
398
|
-
|
399
|
-
|
431
|
+
describe '#provider' do
|
432
|
+
subject { super().provider }
|
433
|
+
it { is_expected.to eq('YouTube') }
|
434
|
+
end
|
400
435
|
|
401
|
-
|
402
|
-
|
403
|
-
|
436
|
+
describe '#video_id' do
|
437
|
+
subject { super().video_id }
|
438
|
+
it { is_expected.to eq 'JM9NgvjjVng' }
|
439
|
+
end
|
404
440
|
end
|
405
|
-
it { expect(subject.embed_code(iframe_attributes: { :'data-colorbox' => true })).to match(/data-colorbox="true"/) }
|
406
|
-
end
|
407
441
|
|
408
|
-
|
409
|
-
|
442
|
+
context 'with video url in text' do
|
443
|
+
url_in_text = '<a href="http://www.youtube.com/watch?v=mZqGqE0D0n4">' \
|
444
|
+
'http://www.youtube.com/watch?v=mZqGqE0D0n4</a>'
|
445
|
+
subject { VideoInfo.new(url_in_text) }
|
410
446
|
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
end
|
416
|
-
|
417
|
-
context "with full screen video URLs", :vcr do
|
418
|
-
subject { VideoInfo.new('http://www.youtube.com/v/mZqGqE0D0n4') }
|
447
|
+
describe '#provider' do
|
448
|
+
subject { super().provider }
|
449
|
+
it { is_expected.to eq('YouTube') }
|
450
|
+
end
|
419
451
|
|
420
|
-
|
421
|
-
|
422
|
-
|
452
|
+
describe '#video_id' do
|
453
|
+
subject { super().video_id }
|
454
|
+
it { is_expected.to eq('mZqGqE0D0n4') }
|
455
|
+
end
|
423
456
|
end
|
424
457
|
|
425
|
-
|
426
|
-
subject {
|
427
|
-
it { is_expected.to eq 'mZqGqE0D0n4' }
|
428
|
-
end
|
458
|
+
context 'with iframe attributes' do
|
459
|
+
subject { VideoInfo.new('http://www.youtube.com/watch?v=mZqGqE0D0n4') }
|
429
460
|
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
461
|
+
describe '#provider' do
|
462
|
+
subject { super().provider }
|
463
|
+
it { is_expected.to eq('YouTube') }
|
464
|
+
end
|
434
465
|
|
435
|
-
|
436
|
-
|
437
|
-
|
466
|
+
it 'should properly apply dimensions attributes' do
|
467
|
+
dimensions = { width: 800, height: 600 }
|
468
|
+
embed_code = subject.embed_code(iframe_attributes: dimensions)
|
469
|
+
expect(embed_code).to match(/width="800"/)
|
470
|
+
expect(embed_code).to match(/height="600"/)
|
471
|
+
end
|
438
472
|
end
|
439
473
|
|
440
|
-
|
441
|
-
subject {
|
442
|
-
it { is_expected.to eq '<iframe src="//www.youtube.com/embed/mZqGqE0D0n4" frameborder="0" allowfullscreen="allowfullscreen"></iframe>' }
|
443
|
-
end
|
474
|
+
context 'with arbitrary iframe_attributes' do
|
475
|
+
subject { VideoInfo.new('http://www.youtube.com/watch?v=mZqGqE0D0n4') }
|
444
476
|
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
477
|
+
describe '#provider' do
|
478
|
+
subject { super().provider }
|
479
|
+
it { is_expected.to eq('YouTube') }
|
480
|
+
end
|
449
481
|
|
450
|
-
|
451
|
-
|
452
|
-
|
482
|
+
it 'should properly apply arbitrary attributes' do
|
483
|
+
attributes = { :'data-colorbox' => true }
|
484
|
+
embed_code = subject.embed_code(iframe_attributes: attributes)
|
485
|
+
expect(embed_code).to match(/data-colorbox="true"/)
|
486
|
+
end
|
453
487
|
end
|
454
488
|
|
455
|
-
|
456
|
-
subject {
|
457
|
-
it { is_expected.to eq %w(cherry bloom king of the knife guitar drum clip rock alternative tremplin Paris-Forum) }
|
458
|
-
end
|
489
|
+
context 'with full screen video URLs' do
|
490
|
+
subject { VideoInfo.new('http://www.youtube.com/v/mZqGqE0D0n4') }
|
459
491
|
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
492
|
+
describe '#provider' do
|
493
|
+
subject { super().provider }
|
494
|
+
it { is_expected.to eq 'YouTube' }
|
495
|
+
end
|
464
496
|
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
497
|
+
describe '#video_id' do
|
498
|
+
subject { super().video_id }
|
499
|
+
it { is_expected.to eq 'mZqGqE0D0n4' }
|
500
|
+
end
|
469
501
|
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
502
|
+
describe '#url' do
|
503
|
+
subject { super().url }
|
504
|
+
it { is_expected.to eq 'http://www.youtube.com/v/mZqGqE0D0n4' }
|
505
|
+
end
|
474
506
|
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
507
|
+
describe '#embed_url' do
|
508
|
+
subject { super().embed_url }
|
509
|
+
it { is_expected.to eq '//www.youtube.com/embed/mZqGqE0D0n4' }
|
510
|
+
end
|
479
511
|
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
512
|
+
describe '#embed_code' do
|
513
|
+
subject { super().embed_code }
|
514
|
+
embed_code = '<iframe src="//www.youtube.com/embed/mZqGqE0D0n4" ' \
|
515
|
+
'frameborder="0" allowfullscreen="allowfullscreen">' \
|
516
|
+
'</iframe>'
|
517
|
+
it { is_expected.to eq embed_code }
|
518
|
+
end
|
484
519
|
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
520
|
+
describe '#title' do
|
521
|
+
subject { super().title }
|
522
|
+
it { is_expected.to eq 'Cherry Bloom - King Of The Knife' }
|
523
|
+
end
|
489
524
|
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
525
|
+
describe '#description' do
|
526
|
+
subject { super().description }
|
527
|
+
description = 'The first video from the upcoming album Secret Sounds,' \
|
528
|
+
' to download in-stores April 14. ' \
|
529
|
+
'Checkout http://www.cherrybloom.net'
|
530
|
+
it { is_expected.to eq description }
|
531
|
+
end
|
494
532
|
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
533
|
+
describe '#keywords' do
|
534
|
+
subject { super().keywords }
|
535
|
+
keywords_list = %w(cherry bloom king of the knife guitar
|
536
|
+
drum clip rock alternative tremplin Paris-Forum)
|
537
|
+
it { is_expected.to eq keywords_list }
|
538
|
+
end
|
500
539
|
|
540
|
+
describe '#duration' do
|
541
|
+
subject { super().duration }
|
542
|
+
it { is_expected.to eq 176 }
|
543
|
+
end
|
501
544
|
|
502
|
-
|
503
|
-
|
545
|
+
describe '#width' do
|
546
|
+
subject { super().width }
|
547
|
+
it { is_expected.to be_nil }
|
548
|
+
end
|
504
549
|
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
end
|
550
|
+
describe '#height' do
|
551
|
+
subject { super().height }
|
552
|
+
it { is_expected.to be_nil }
|
553
|
+
end
|
510
554
|
|
511
|
-
|
512
|
-
|
555
|
+
describe '#date' do
|
556
|
+
subject { super().date }
|
513
557
|
|
514
|
-
|
515
|
-
|
516
|
-
|
558
|
+
it 'should return date video was posted' do
|
559
|
+
if api_key.nil?
|
560
|
+
is_expected.to eq Time.parse('Sat Apr 12 2008', Time.now.utc)
|
561
|
+
else
|
562
|
+
is_expected.to eq Time.parse('Sat Apr 12 22:34:48 UTC 2008',
|
563
|
+
Time.now.utc)
|
564
|
+
end
|
565
|
+
end
|
517
566
|
end
|
518
567
|
|
519
|
-
|
520
|
-
|
568
|
+
describe '#thumbnail_small' do
|
569
|
+
subject { super().thumbnail_small }
|
570
|
+
thumbnail_url = 'https://i.ytimg.com/vi/mZqGqE0D0n4/default.jpg'
|
571
|
+
it { is_expected.to eq thumbnail_url }
|
521
572
|
end
|
522
573
|
|
523
|
-
|
524
|
-
|
574
|
+
describe '#thumbnail_medium' do
|
575
|
+
subject { super().thumbnail_medium }
|
576
|
+
thumbnail_url = 'https://i.ytimg.com/vi/mZqGqE0D0n4/mqdefault.jpg'
|
577
|
+
it { is_expected.to eq thumbnail_url }
|
525
578
|
end
|
526
|
-
end
|
527
|
-
end
|
528
579
|
|
529
|
-
|
530
|
-
|
580
|
+
describe '#thumbnail_large' do
|
581
|
+
subject { super().thumbnail_large }
|
582
|
+
thumbnail_url = 'https://i.ytimg.com/vi/mZqGqE0D0n4/hqdefault.jpg'
|
583
|
+
it { is_expected.to eq thumbnail_url }
|
584
|
+
end
|
531
585
|
|
532
|
-
|
533
|
-
|
534
|
-
|
586
|
+
describe '#thumbnail_large_2x' do
|
587
|
+
subject { super().thumbnail_large_2x }
|
588
|
+
thumbnail_url = 'https://i.ytimg.com/vi/mZqGqE0D0n4/sddefault.jpg'
|
589
|
+
it { is_expected.to eq thumbnail_url }
|
535
590
|
end
|
536
591
|
|
537
|
-
|
538
|
-
|
592
|
+
describe '#view_count' do
|
593
|
+
subject { super().view_count }
|
594
|
+
|
595
|
+
it { is_expected.to eq 7962 }
|
539
596
|
end
|
540
597
|
end
|
541
598
|
end
|