video_info 2.6.0 → 2.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -1
- data/.rubocop.yml +242 -1
- data/.travis.yml +9 -8
- data/CONTRIBUTING.md +11 -0
- data/Gemfile +1 -1
- data/Guardfile +1 -1
- data/README.md +34 -1
- data/lib/video_info.rb +22 -26
- data/lib/video_info/provider.rb +8 -10
- data/lib/video_info/providers/dailymotion.rb +6 -3
- data/lib/video_info/providers/vimeo.rb +3 -3
- data/lib/video_info/providers/vimeo_api.rb +13 -4
- data/lib/video_info/providers/vimeo_scraper.rb +33 -13
- data/lib/video_info/providers/vkontakte.rb +38 -14
- data/lib/video_info/providers/wistia.rb +2 -1
- data/lib/video_info/providers/youtube.rb +4 -2
- data/lib/video_info/providers/youtube_api.rb +38 -3
- data/lib/video_info/providers/youtube_scraper.rb +26 -12
- data/lib/video_info/providers/youtubeplaylist.rb +5 -2
- data/lib/video_info/providers/youtubeplaylist_api.rb +8 -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 +89 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Dailymotion/_available_/with_valid_video/_available_/1_2_1_1_1.yml +92 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Dailymotion/with_video_x7lni3/_date/should_show_correct_date.yml +95 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Dailymotion/with_video_x7lni3/_description/1_3_7_1.yml +95 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Dailymotion/with_video_x7lni3/_duration/1_3_9_1.yml +95 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Dailymotion/with_video_x7lni3/_keywords/1_3_8_1.yml +95 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Dailymotion/with_video_x7lni3/_thumbnail_large/1_3_15_1.yml +95 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Dailymotion/with_video_x7lni3/_thumbnail_medium/1_3_14_1.yml +95 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Dailymotion/with_video_x7lni3/_thumbnail_small/1_3_13_1.yml +95 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Dailymotion/with_video_x7lni3/_title/1_3_6_1.yml +95 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Dailymotion/with_video_x7lni3/_view_count/1_3_16_1.yml +95 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/_available_/with_password_required_video/_available_/1_2_3_1_1.yml +964 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/_available_/with_password_required_video/_available_/2_2_3_1_1.yml +59 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/_available_/with_this_video_does_not_exist_video/_available_/1_2_2_1_1.yml +936 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/_available_/with_this_video_does_not_exist_video/_available_/2_2_2_1_1.yml +61 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/_available_/with_valid_video/_available_/1_2_1_1_1.yml +2692 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/_available_/with_valid_video/_available_/2_2_1_1_1.yml +119 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_author/1_3_17_1.yml +1530 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_author/2_3_17_1.yml +68 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_author_thumbnail/1_3_16_1.yml +1530 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_author_thumbnail/2_3_16_1.yml +68 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_author_url/1_3_18_1.yml +1529 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_author_url/2_3_18_1.yml +68 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_date/should_have_correct_upload_date.yml +1595 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_description/1_3_7_1.yml +1602 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_description/2_3_7_1.yml +68 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_duration/1_3_9_1.yml +1530 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_duration/2_3_9_1.yml +68 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_height/1_3_11_1.yml +1529 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_height/2_3_11_1.yml +68 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_keywords/should_return_a_string_list_of_keywords.yml +1595 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_thumbnail_large/1_3_15_1.yml +1530 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_thumbnail_large/2_3_15_1.yml +68 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_thumbnail_medium/1_3_14_1.yml +1530 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_thumbnail_medium/2_3_14_1.yml +68 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_thumbnail_small/1_3_13_1.yml +1530 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_thumbnail_small/2_3_13_1.yml +68 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_title/1_3_6_1.yml +1602 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_title/2_3_6_1.yml +68 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_view_count/1_3_19_1.yml +1530 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_view_count/2_3_19_1.yml +68 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_width/1_3_10_1.yml +1530 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_136971428/_width/2_3_10_1.yml +68 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_898029/_author/1_3_17_1.yml +2559 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_898029/_author/2_3_17_1.yml +159 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_898029/_author_thumbnail/1_3_16_1.yml +2559 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_898029/_author_thumbnail/2_3_16_1.yml +159 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_898029/_author_url/1_3_18_1.yml +2559 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_898029/_author_url/2_3_18_1.yml +159 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_898029/_date/should_have_correct_upload_date.yml +2714 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_898029/_description/1_3_7_1.yml +2692 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_898029/_description/2_3_7_1.yml +159 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_898029/_duration/1_3_9_1.yml +2829 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_898029/_duration/2_3_9_1.yml +159 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_898029/_height/1_3_11_1.yml +2828 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_898029/_height/2_3_11_1.yml +159 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_898029/_keywords/should_return_a_string_list_of_keywords.yml +2716 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_898029/_thumbnail_large/1_3_15_1.yml +2560 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_898029/_thumbnail_large/2_3_15_1.yml +159 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_898029/_thumbnail_medium/1_3_14_1.yml +2558 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_898029/_thumbnail_medium/2_3_14_1.yml +159 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_898029/_thumbnail_small/1_3_13_1.yml +2558 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_898029/_thumbnail_small/2_3_13_1.yml +159 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_898029/_title/1_3_6_1.yml +2961 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_898029/_title/2_3_6_1.yml +159 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_898029/_view_count/1_3_19_1.yml +2560 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_898029/_view_count/2_3_19_1.yml +159 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_898029/_width/1_3_10_1.yml +2560 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_898029/_width/2_3_10_1.yml +159 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/_available_/with_hashes/available_/1_2_6_1_1.yml +2996 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/_available_/with_invalid_video/available_/1_2_2_1_1.yml +46 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/_available_/with_private_video/available_/1_2_3_1_1.yml +865 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/_available_/with_redirect/available_/1_2_4_1_1.yml +666 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/_available_/with_redirect_to_main_page_for_auth/available_/1_2_5_1_1.yml +46 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/_available_/with_valid_video/available_/1_2_1_1_1.yml +2118 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_from_kirill_lyanoi_z_video2152699_168591741_2F56fd229a9dfe2dcdbe/author/1_5_14_1.yml +518 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_from_kirill_lyanoi_z_video2152699_168591741_2F56fd229a9dfe2dcdbe/author_thumbnail/1_5_15_1.yml +519 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_from_kirill_lyanoi_z_video2152699_168591741_2F56fd229a9dfe2dcdbe/author_url/1_5_16_1.yml +520 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_from_kirill_lyanoi_z_video2152699_168591741_2F56fd229a9dfe2dcdbe/description/1_5_8_1.yml +518 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_from_kirill_lyanoi_z_video2152699_168591741_2F56fd229a9dfe2dcdbe/duration/1_5_10_1.yml +517 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_from_kirill_lyanoi_z_video2152699_168591741_2F56fd229a9dfe2dcdbe/embed_code/1_5_6_1.yml +517 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_from_kirill_lyanoi_z_video2152699_168591741_2F56fd229a9dfe2dcdbe/embed_url/1_5_5_1.yml +519 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_from_kirill_lyanoi_z_video2152699_168591741_2F56fd229a9dfe2dcdbe/height/1_5_12_1.yml +517 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_from_kirill_lyanoi_z_video2152699_168591741_2F56fd229a9dfe2dcdbe/title/1_5_7_1.yml +517 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_from_kirill_lyanoi_z_video2152699_168591741_2F56fd229a9dfe2dcdbe/view_count/1_5_13_1.yml +521 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_from_kirill_lyanoi_z_video2152699_168591741_2F56fd229a9dfe2dcdbe/width/1_5_11_1.yml +517 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_https_/vk_com/id44052340_z_video61291456_159590018_2F2521d92730a272a9ea/author/1_3_7_1.yml +399 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_https_/vk_com/id44052340_z_video61291456_159590018_2F2521d92730a272a9ea/embed_code/1_3_6_1.yml +399 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_https_/vk_com/id44052340_z_video61291456_159590018_2F2521d92730a272a9ea/embed_url/1_3_5_1.yml +399 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_https_/vk_com/id44052340_z_video61291456_159590018_2F2521d92730a272a9ea/title/1_3_4_1.yml +399 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_video-54799401_165822734/title/1_7_4_1.yml +682 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_video3552522_171340713/embed_url/1_10_1_1.yml +501 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_video39576223_108370515/description/1_6_8_1.yml +449 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_video39576223_108370515/duration/1_6_10_1.yml +449 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_video39576223_108370515/embed_code/1_6_6_1.yml +449 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_video39576223_108370515/embed_url/1_6_5_1.yml +449 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_video39576223_108370515/height/1_6_12_1.yml +449 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_video39576223_108370515/title/1_6_7_1.yml +449 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_video39576223_108370515/view_count/1_6_13_1.yml +449 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_video39576223_108370515/width/1_6_11_1.yml +449 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_videos43640822_/video43640822_168790809/author/1_4_5_1.yml +527 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_videos43640822_/video43640822_168790809/author_thumbnail/1_4_6_1.yml +527 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_videos43640822_/video43640822_168790809/author_url/1_4_7_1.yml +527 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_videos43640822_/video43640822_168790809/title/1_4_4_1.yml +527 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Wistia/_available_/with_invalid_video/_available_/1_2_2_1_1.yml +71 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Wistia/_available_/with_valid_video/_available_/1_2_1_1_1.yml +73 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Wistia/with_video_pxonqr42is/_duration/1_4_7_1.yml +80 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Wistia/with_video_pxonqr42is/_height/1_4_9_1.yml +80 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Wistia/with_video_pxonqr42is/_thumbnail_large/1_4_12_1.yml +80 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Wistia/with_video_pxonqr42is/_thumbnail_medium/1_4_11_1.yml +80 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Wistia/with_video_pxonqr42is/_thumbnail_small/1_4_10_1.yml +80 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Wistia/with_video_pxonqr42is/_title/1_4_6_1.yml +80 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Wistia/with_video_pxonqr42is/_width/1_4_8_1.yml +80 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Wistia/with_video_rs1me54mpw/_duration/1_3_7_1.yml +80 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Wistia/with_video_rs1me54mpw/_height/1_3_9_1.yml +80 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Wistia/with_video_rs1me54mpw/_thumbnail_large/1_3_12_1.yml +80 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Wistia/with_video_rs1me54mpw/_thumbnail_medium/1_3_11_1.yml +80 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Wistia/with_video_rs1me54mpw/_thumbnail_small/1_3_10_1.yml +80 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Wistia/with_video_rs1me54mpw/_title/1_3_6_1.yml +80 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Wistia/with_video_rs1me54mpw/_width/1_3_8_1.yml +80 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/_available_/with_unavailable_video/_available_/1_2_2_1_1.yml +516 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/_available_/with_unavailable_video/_available_/2_2_2_1_1.yml +56 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/_available_/with_unavailable_video/_date/1_2_2_11_1.yml +519 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/_available_/with_unavailable_video/_date/2_2_2_11_1.yml +56 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/_available_/with_unavailable_video/_description/1_2_2_8_1.yml +521 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/_available_/with_unavailable_video/_description/2_2_2_8_1.yml +56 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/_available_/with_unavailable_video/_duration/1_2_2_10_1.yml +519 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/_available_/with_unavailable_video/_duration/2_2_2_10_1.yml +56 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/_available_/with_unavailable_video/_keywords/1_2_2_9_1.yml +519 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/_available_/with_unavailable_video/_keywords/2_2_2_9_1.yml +56 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/_available_/with_unavailable_video/_title/1_2_2_7_1.yml +519 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/_available_/with_unavailable_video/_title/2_2_2_7_1.yml +56 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/_available_/with_unavailable_video/_view_count/1_2_2_15_1.yml +516 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/_available_/with_unavailable_video/_view_count/2_2_2_15_1.yml +56 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/_available_/with_valid_video/_available_/1_2_1_1_1.yml +3930 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/_available_/with_valid_video/_available_/2_2_1_1_1.yml +127 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/_available_/with_video_removed_because_of_copyright_claim/_available_/1_2_3_1_1.yml +578 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/_available_/with_video_removed_because_of_copyright_claim/_available_/2_2_3_1_1.yml +117 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_full_screen_video_URLs/_date/should_return_date_video_was_posted.yml +3912 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_full_screen_video_URLs/_description/1_17_7_1.yml +4007 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_full_screen_video_URLs/_description/2_17_7_1.yml +127 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_full_screen_video_URLs/_duration/1_17_9_1.yml +3982 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_full_screen_video_URLs/_duration/2_17_9_1.yml +127 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_full_screen_video_URLs/_keywords/1_17_8_1.yml +3984 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_full_screen_video_URLs/_keywords/2_17_8_1.yml +127 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_full_screen_video_URLs/_title/1_17_6_1.yml +3946 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_full_screen_video_URLs/_title/2_17_6_1.yml +127 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_full_screen_video_URLs/_view_count/1_17_16_1.yml +3948 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_full_screen_video_URLs/_view_count/2_17_16_1.yml +127 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/_author/1_3_6_1.yml +4006 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/_author/2_3_6_1.yml +127 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/_author_thumbnail/1_3_7_1.yml +4027 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/_author_thumbnail/2_3_7_1.yml +212 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/_author_url/1_3_8_1.yml +4080 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/_author_url/2_3_8_1.yml +212 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/_date/should_return_date_video_was_posted.yml +3982 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/_description/1_3_10_1.yml +3992 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/_description/2_3_10_1.yml +127 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/_duration/1_3_12_1.yml +3961 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/_duration/2_3_12_1.yml +127 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/_keywords/1_3_11_1.yml +3928 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/_keywords/2_3_11_1.yml +127 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/_title/1_3_9_1.yml +3974 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/_title/2_3_9_1.yml +127 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/_view_count/1_3_19_1.yml +3950 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/_view_count/2_3_19_1.yml +127 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/_available_/with_invalid_playlist/_available_/1_2_2_1_1.yml +62 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/_available_/with_invalid_playlist/_available_/2_2_2_1_1.yml +62 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/_available_/with_list_url/_available_/1_2_3_1_1.yml +96 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/_available_/with_list_url/_available_/2_2_3_1_1.yml +96 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/_available_/with_valid_playlist/_available_/1_2_1_1_1.yml +96 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/_available_/with_valid_playlist/_available_/2_2_1_1_1.yml +96 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/with_playlist_PL9hW1uS6HUftLdHI6RIsaf/_author/1_3_18_1.yml +107 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/with_playlist_PL9hW1uS6HUftLdHI6RIsaf/_author/2_3_18_1.yml +107 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/with_playlist_PL9hW1uS6HUftLdHI6RIsaf/_author_thumbnail/1_3_19_1.yml +193 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/with_playlist_PL9hW1uS6HUftLdHI6RIsaf/_author_thumbnail/2_3_19_1.yml +193 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/with_playlist_PL9hW1uS6HUftLdHI6RIsaf/_author_url/1_3_20_1.yml +193 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/with_playlist_PL9hW1uS6HUftLdHI6RIsaf/_author_url/2_3_20_1.yml +193 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/with_playlist_PL9hW1uS6HUftLdHI6RIsaf/_description/1_3_7_1.yml +107 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/with_playlist_PL9hW1uS6HUftLdHI6RIsaf/_description/2_3_7_1.yml +107 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/with_playlist_PL9hW1uS6HUftLdHI6RIsaf/_keywords/1_3_8_1.yml +107 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/with_playlist_PL9hW1uS6HUftLdHI6RIsaf/_keywords/2_3_8_1.yml +107 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/with_playlist_PL9hW1uS6HUftLdHI6RIsaf/_thumbnail_large/1_3_15_1.yml +107 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/with_playlist_PL9hW1uS6HUftLdHI6RIsaf/_thumbnail_large/2_3_15_1.yml +107 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/with_playlist_PL9hW1uS6HUftLdHI6RIsaf/_thumbnail_medium/1_3_14_1.yml +107 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/with_playlist_PL9hW1uS6HUftLdHI6RIsaf/_thumbnail_medium/2_3_14_1.yml +107 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/with_playlist_PL9hW1uS6HUftLdHI6RIsaf/_thumbnail_small/1_3_13_1.yml +107 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/with_playlist_PL9hW1uS6HUftLdHI6RIsaf/_thumbnail_small/2_3_13_1.yml +107 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/with_playlist_PL9hW1uS6HUftLdHI6RIsaf/_title/1_3_6_1.yml +107 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/with_playlist_PL9hW1uS6HUftLdHI6RIsaf/_title/2_3_6_1.yml +107 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/with_playlist_PL9hW1uS6HUftLdHI6RIsaf/_videos/returns_list_of_videos_in_playlist.yml +267 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/with_playlist_that_does_not_exist_in_embed_path/_videos/1_4_2_1.yml +56 -0
- data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_YoutubePlaylist/with_playlist_that_does_not_exist_in_embed_path/_videos/2_4_2_1.yml +56 -0
- data/spec/lib/video_info/provider_spec.rb +42 -22
- data/spec/lib/video_info/providers/dailymotion_spec.rb +41 -23
- data/spec/lib/video_info/providers/vimeo_spec.rb +212 -177
- data/spec/lib/video_info/providers/vkontakte_spec.rb +132 -63
- data/spec/lib/video_info/providers/wistia_spec.rb +34 -13
- data/spec/lib/video_info/providers/youtube_playlist_spec.rb +185 -139
- data/spec/lib/video_info/providers/youtube_spec.rb +400 -385
- data/spec/lib/video_info_spec.rb +27 -21
- data/video_info.gemspec +7 -10
- metadata +424 -87
- data/foo.txt +0 -33
- data/spec/lib/video_info/providers/vimeo_api_spec.rb +0 -242
- 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,6 +1,6 @@
|
|
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
|
@@ -12,7 +12,7 @@ class VideoInfo
|
|
12
12
|
_set_video_id_from_url
|
13
13
|
end
|
14
14
|
|
15
|
-
def self.usable?(
|
15
|
+
def self.usable?(_url)
|
16
16
|
raise NotImplementedError.new(
|
17
17
|
'Provider class must implement .usable? public method'
|
18
18
|
)
|
@@ -20,12 +20,12 @@ class VideoInfo
|
|
20
20
|
|
21
21
|
def embed_code(options = {})
|
22
22
|
iframe_attributes = options.fetch(:iframe_attributes, {})
|
23
|
-
iframe_attrs = ["src=\"#{_embed_url(options)}\"",
|
23
|
+
iframe_attrs = ["src=\"#{_embed_url(options)}\"", 'frameborder="0"']
|
24
24
|
iframe_attrs << _hash_to_attributes(
|
25
25
|
_default_iframe_attributes.merge(iframe_attributes)
|
26
26
|
)
|
27
27
|
|
28
|
-
"<iframe #{iframe_attrs.reject(&:empty?).join(
|
28
|
+
"<iframe #{iframe_attrs.reject(&:empty?).join(' ')}></iframe>"
|
29
29
|
end
|
30
30
|
|
31
31
|
def data
|
@@ -42,7 +42,7 @@ class VideoInfo
|
|
42
42
|
uri = URI.parse(_api_url)
|
43
43
|
http = Net::HTTP.new(uri.host, uri.port)
|
44
44
|
|
45
|
-
if
|
45
|
+
if uri.scheme == 'https'
|
46
46
|
_https_response_code(http)
|
47
47
|
else
|
48
48
|
_http_response_code(http)
|
@@ -96,7 +96,7 @@ class VideoInfo
|
|
96
96
|
|
97
97
|
def _set_data_from_api_impl(api_url)
|
98
98
|
uri = open(api_url, options)
|
99
|
-
|
99
|
+
JSON.load(uri.read)
|
100
100
|
end
|
101
101
|
|
102
102
|
def _not_openuri_option_symbol?(key)
|
@@ -145,9 +145,7 @@ class VideoInfo
|
|
145
145
|
end
|
146
146
|
|
147
147
|
def _hash_to_params(hash)
|
148
|
-
|
149
|
-
uri.query_values = hash
|
150
|
-
uri.query
|
148
|
+
URI.encode_www_form(hash)
|
151
149
|
end
|
152
150
|
end
|
153
151
|
end
|
@@ -56,11 +56,11 @@ class VideoInfo
|
|
56
56
|
end
|
57
57
|
|
58
58
|
def _url_regex
|
59
|
-
|
59
|
+
%r{dai(?:\.ly|lymotion\.com\/(?:embed\/)?video)\/([a-zA-Z0-9]*)}
|
60
60
|
end
|
61
61
|
|
62
62
|
def _api_base
|
63
|
-
|
63
|
+
'api.dailymotion.com'
|
64
64
|
end
|
65
65
|
|
66
66
|
def _api_path
|
@@ -68,7 +68,10 @@ class VideoInfo
|
|
68
68
|
end
|
69
69
|
|
70
70
|
def _api_url
|
71
|
-
"https://#{_api_base}#{_api_path}?
|
71
|
+
"https://#{_api_base}#{_api_path}?" \
|
72
|
+
'fields=id,title,description,duration,created_time,' \
|
73
|
+
'url,views_total,tags,thumbnail_url,thumbnail_720_url,' \
|
74
|
+
'thumbnail_240_url,thumbnail_60_url'
|
72
75
|
end
|
73
76
|
|
74
77
|
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,8 +26,13 @@ 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
|
@@ -36,7 +41,11 @@ class VideoInfo
|
|
36
41
|
|
37
42
|
def thumbnail(width = 200, height = nil)
|
38
43
|
base_uri = "https://i.vimeocdn.com/video/#{thumbnail_id}"
|
39
|
-
|
44
|
+
if height
|
45
|
+
base_uri + "_#{width}x#{height}.jpg"
|
46
|
+
else
|
47
|
+
base_uri + "_#{width}.jpg"
|
48
|
+
end
|
40
49
|
end
|
41
50
|
|
42
51
|
def thumbnail_small
|
@@ -52,7 +61,7 @@ class VideoInfo
|
|
52
61
|
end
|
53
62
|
|
54
63
|
def keywords
|
55
|
-
keywords_array
|
64
|
+
keywords_array
|
56
65
|
end
|
57
66
|
|
58
67
|
def keywords_array
|
@@ -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
|
@@ -6,18 +6,36 @@ class VideoInfo
|
|
6
6
|
module Providers
|
7
7
|
module VimeoScraper
|
8
8
|
def author
|
9
|
-
|
9
|
+
json_info['author']['name']
|
10
10
|
end
|
11
11
|
|
12
12
|
def author_thumbnail
|
13
|
-
|
14
|
-
|
13
|
+
split_point = 'window.vimeo.clip_page_config ='
|
14
|
+
script_tags = data.css('script')
|
15
|
+
|
16
|
+
script_index = script_tags.find_index do |x|
|
17
|
+
x.text.include?(split_point)
|
18
|
+
end
|
19
|
+
|
20
|
+
script_text = script_tags[script_index].text
|
21
|
+
|
22
|
+
split_script_text = script_text.split(split_point)[1]
|
23
|
+
|
24
|
+
parsed_data = JSON.parse(split_script_text.split(";\n")[0])
|
25
|
+
|
26
|
+
parsed_data['owner']['portrait']['src']
|
27
|
+
end
|
28
|
+
|
29
|
+
def author_url
|
30
|
+
json_info['author']['url']
|
15
31
|
end
|
16
32
|
|
17
33
|
def available?
|
18
34
|
is_available = super
|
19
35
|
|
20
|
-
if
|
36
|
+
if data.nil?
|
37
|
+
is_available = false
|
38
|
+
elsif is_available
|
21
39
|
page_header = data.css('#page_header')
|
22
40
|
|
23
41
|
if page_header.text == "\n Private Video\n "
|
@@ -47,19 +65,19 @@ class VideoInfo
|
|
47
65
|
end
|
48
66
|
|
49
67
|
def keywords
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
68
|
+
if json_info['keywords']
|
69
|
+
json_info['keywords']
|
70
|
+
else
|
71
|
+
[]
|
72
|
+
end
|
55
73
|
end
|
56
74
|
|
57
75
|
def height
|
58
|
-
|
76
|
+
json_info['height']
|
59
77
|
end
|
60
78
|
|
61
79
|
def width
|
62
|
-
|
80
|
+
json_info['width']
|
63
81
|
end
|
64
82
|
|
65
83
|
def thumbnail_small
|
@@ -117,7 +135,10 @@ class VideoInfo
|
|
117
135
|
end
|
118
136
|
|
119
137
|
def _set_data_from_api_impl(api_url)
|
120
|
-
Oga.parse_html(open(api_url.to_s
|
138
|
+
Oga.parse_html(open(api_url.to_s).read)
|
139
|
+
|
140
|
+
rescue OpenURI::HTTPError
|
141
|
+
nil
|
121
142
|
end
|
122
143
|
|
123
144
|
def _api_url
|
@@ -132,4 +153,3 @@ class VideoInfo
|
|
132
153
|
end
|
133
154
|
end
|
134
155
|
end
|
135
|
-
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# encoding: UTF-8
|
2
|
-
require '
|
2
|
+
require 'cgi'
|
3
3
|
require 'net/http'
|
4
|
+
require 'oga'
|
4
5
|
|
5
6
|
class VideoInfo
|
6
7
|
module Providers
|
@@ -14,8 +15,9 @@ class VideoInfo
|
|
14
15
|
|
15
16
|
def self.usable?(url)
|
16
17
|
url.strip!
|
17
|
-
vkontakte = !!(url =~
|
18
|
-
|
18
|
+
vkontakte = !!(url =~ %r{\A(http|https):\/\/(vk\.com)|
|
19
|
+
(vkontakte\.ru)\z})
|
20
|
+
valid = !!(url =~ /\A#{URI.regexp(%w[http https])}\z/)
|
19
21
|
vkontakte && valid
|
20
22
|
end
|
21
23
|
|
@@ -25,9 +27,12 @@ class VideoInfo
|
|
25
27
|
|
26
28
|
def description
|
27
29
|
content = data[/"desc":"(.*?)",/, 1]
|
28
|
-
|
30
|
+
CGI.unescape_html(content).gsub(' ', ' ')
|
31
|
+
end
|
32
|
+
|
33
|
+
def keywords
|
34
|
+
nil
|
29
35
|
end
|
30
|
-
alias_method :keywords, :description
|
31
36
|
|
32
37
|
def width
|
33
38
|
{ 240 => 320,
|
@@ -38,11 +43,28 @@ class VideoInfo
|
|
38
43
|
end
|
39
44
|
|
40
45
|
def height
|
41
|
-
data[/url(\d+)/,1].to_i
|
46
|
+
data[/url(\d+)/, 1].to_i
|
47
|
+
end
|
48
|
+
|
49
|
+
def author
|
50
|
+
data_after_author_div = data.split('<a class="mem_link" href="')[1]
|
51
|
+
data_after_author_div.split('</a>')[0].split('">')[1]
|
52
|
+
end
|
53
|
+
|
54
|
+
def author_thumbnail
|
55
|
+
split_point = '<img id="mv_author_img" class="mv_author_img" src="'
|
56
|
+
author_img_split = data.split(split_point)[1]
|
57
|
+
author_img_split.split('">')[0]
|
58
|
+
end
|
59
|
+
|
60
|
+
def author_url
|
61
|
+
split_point = '"author_href":"\\/'
|
62
|
+
author_url_path = data.split(split_point)[1].split('"')[0]
|
63
|
+
'https://vk.com/' + author_url_path
|
42
64
|
end
|
43
65
|
|
44
66
|
def title
|
45
|
-
data[
|
67
|
+
data[%r{\="mv_title">(.*)<\/div>}, 1].gsub(' | ВКонтакте', '')
|
46
68
|
end
|
47
69
|
|
48
70
|
def view_count
|
@@ -51,16 +73,16 @@ class VideoInfo
|
|
51
73
|
|
52
74
|
def embed_url
|
53
75
|
iframe_src = data[
|
54
|
-
/iframe\ id=\"
|
76
|
+
/iframe\ id=\"video_yt_player\".*src=\"([^\"]*)\".*frameborder=/, 1
|
55
77
|
]
|
56
78
|
if iframe_src
|
57
79
|
# it may be youtube video
|
58
80
|
VideoInfo::Providers::Youtube.new(
|
59
|
-
URI.unescape(iframe_src.
|
81
|
+
URI.unescape(iframe_src.delete(/\\/, ''))
|
60
82
|
).embed_url
|
61
83
|
else
|
62
|
-
"//vk.com/video_ext.php?oid=#{video_owner}"
|
63
|
-
|
84
|
+
"//vk.com/video_ext.php?oid=#{video_owner}" \
|
85
|
+
"&id=#{video_id}&hash=#{_data_hash}"
|
64
86
|
end
|
65
87
|
rescue
|
66
88
|
# or rutube video
|
@@ -72,7 +94,8 @@ class VideoInfo
|
|
72
94
|
end
|
73
95
|
|
74
96
|
def available?
|
75
|
-
!%w[403 404 302 401].include?(_response_code)
|
97
|
+
!%w[403 404 302 401].include?(_response_code) &&
|
98
|
+
!(data =~ /Ошибка доступа/)
|
76
99
|
end
|
77
100
|
|
78
101
|
private
|
@@ -101,7 +124,7 @@ class VideoInfo
|
|
101
124
|
|
102
125
|
def _error_found?(response)
|
103
126
|
title = response.body[
|
104
|
-
|
127
|
+
%r{<title>(.*)<\/title>}, 1
|
105
128
|
].force_encoding(
|
106
129
|
'cp1251'
|
107
130
|
).encode(
|
@@ -151,7 +174,8 @@ class VideoInfo
|
|
151
174
|
end
|
152
175
|
|
153
176
|
def _url_regex
|
154
|
-
|
177
|
+
%r{(?:vkontakte\.ru\/video|vk\.com\/video
|
178
|
+
|vk\.com\/.*?video)(-?\d+_\d+)}i
|
155
179
|
end
|
156
180
|
|
157
181
|
def _default_iframe_attributes
|
@@ -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
|
@@ -46,7 +47,8 @@ class VideoInfo
|
|
46
47
|
private
|
47
48
|
|
48
49
|
def _url_regex
|
49
|
-
|
50
|
+
%r{(?:youtube(?:-nocookie)?\.com\/(?:[^\/]+\/.+\/|(?:v|e(?:mbed)?)\/|
|
51
|
+
.*[?&]v=)|youtu\.be\/)([^"&?\/ ]{11})}x
|
50
52
|
end
|
51
53
|
|
52
54
|
def _default_iframe_attributes
|
@@ -5,6 +5,19 @@ class VideoInfo
|
|
5
5
|
VideoInfo.provider_api_keys[:youtube]
|
6
6
|
end
|
7
7
|
|
8
|
+
def author
|
9
|
+
_video_snippet['channelTitle']
|
10
|
+
end
|
11
|
+
|
12
|
+
def author_thumbnail
|
13
|
+
_channel_snippet['thumbnails']['default']['url']
|
14
|
+
end
|
15
|
+
|
16
|
+
def author_url
|
17
|
+
channel_id = _channel_info['items'][0]['id']
|
18
|
+
'https://www.youtube.com/channel/' + channel_id
|
19
|
+
end
|
20
|
+
|
8
21
|
def title
|
9
22
|
_video_snippet['title']
|
10
23
|
end
|
@@ -28,13 +41,18 @@ class VideoInfo
|
|
28
41
|
end
|
29
42
|
|
30
43
|
def view_count
|
31
|
-
_video_statistics['viewCount'].to_i
|
44
|
+
_video_statistics['viewCount'].to_i
|
32
45
|
end
|
33
46
|
|
34
47
|
private
|
35
48
|
|
36
49
|
def available?
|
37
|
-
data['items'].
|
50
|
+
if !data['items'].empty?
|
51
|
+
upload_status = data['items'][0]['status']['uploadStatus']
|
52
|
+
'rejected' != upload_status
|
53
|
+
else
|
54
|
+
false
|
55
|
+
end
|
38
56
|
rescue VideoInfo::HttpError
|
39
57
|
false
|
40
58
|
end
|
@@ -44,7 +62,9 @@ class VideoInfo
|
|
44
62
|
end
|
45
63
|
|
46
64
|
def _api_path
|
47
|
-
"/youtube/v3/videos?id=#{video_id}
|
65
|
+
"/youtube/v3/videos?id=#{video_id}" \
|
66
|
+
'&part=snippet,statistics,status,contentDetails&fields=' \
|
67
|
+
"items(id,snippet,statistics,status,contentDetails)&key=#{api_key}"
|
48
68
|
end
|
49
69
|
|
50
70
|
def _api_url
|
@@ -56,6 +76,21 @@ class VideoInfo
|
|
56
76
|
data['items'][0]['snippet']
|
57
77
|
end
|
58
78
|
|
79
|
+
def _channel_api_url(channel_id)
|
80
|
+
"https://#{_api_base}/youtube/v3/channels?part=snippet&id" \
|
81
|
+
"=#{channel_id}&key=#{api_key}"
|
82
|
+
end
|
83
|
+
|
84
|
+
def _channel_info
|
85
|
+
channel_url = _channel_api_url(_video_snippet['channelId'])
|
86
|
+
@channel_data ||= open(channel_url)
|
87
|
+
JSON.load(@channel_data.read)
|
88
|
+
end
|
89
|
+
|
90
|
+
def _channel_snippet
|
91
|
+
_channel_info['items'][0]['snippet']
|
92
|
+
end
|
93
|
+
|
59
94
|
def _video_content_details
|
60
95
|
return {} unless available?
|
61
96
|
data['items'][0]['contentDetails']
|