diff options
author | Tomáš Čech <sleep_walker@suse.cz> | 2013-04-01 14:57:49 +0200 |
---|---|---|
committer | Tomáš Čech <sleep_walker@suse.cz> | 2013-04-01 14:57:49 +0200 |
commit | e4da231361f8b3b7e24a81ed887293cd70f01cb1 (patch) | |
tree | 360996197bdbe49489acff4c00bcba8bc0454413 | |
parent | 06860ae3cde100007c87b554853bb86a7603b514 (diff) | |
download | get-flash-videos-e4da231361f8b3b7e24a81ed887293cd70f01cb1.tar.gz |
add initial support for Vkontakte and Vk.com embedded frames
-rw-r--r-- | lib/FlashVideo/Site/Vk.pm | 57 | ||||
-rw-r--r-- | lib/FlashVideo/Site/Vkontakte.pm | 7 |
2 files changed, 64 insertions, 0 deletions
diff --git a/lib/FlashVideo/Site/Vk.pm b/lib/FlashVideo/Site/Vk.pm new file mode 100644 index 0000000..105d6b0 --- /dev/null +++ b/lib/FlashVideo/Site/Vk.pm @@ -0,0 +1,57 @@ +# Part of get-flash-videos. See get_flash_videos for copyright. +package FlashVideo::Site::Vk; + +use strict; +use FlashVideo::Utils; + +sub find_video { + my ($self, $browser, $embed_url) = @_; + my $title = ""; + my $host = ""; + my $uid = ""; + my $vtag = ""; + my $url = ""; + my $reget = 0; +# return unless ($embed_url !~ /^http:\/\/([^.\/]+\.)?vk\.com\/.*/); + + # it seems that ampersands are often escaped (why?) + if ($embed_url =~ /&/) { + info ("URI with encoded ampersands... re-GETing"); + $embed_url =~ s/&/&/g; + $reget = 1; + } + + # vkontakte.ru is the same page as vk.com, but it redirects to login (?) + if ($embed_url =~ /http:\/\/vkontakte.ru\//) { + $embed_url =~ s/http:\/\/vkontakte.ru\//http:\/\/vk.com\//; + $reget = 1; + } + + # in either of case above let's get the page again with changed URL + if ($reget) { + $browser->get($embed_url); + } + debug ("URI: " . $embed_url); + + if ($browser->content =~ /\s*var video_title = '([^']+)';/) { + $title = $1; + debug ("Title: '" . $title . "'"); + } + + return unless ($browser->content =~ /\s*var video_host = '([^']+)';/); + $host = $1; + debug ("Host: '" . $host . "'"); + + return unless ($browser->content =~ /\s*var video_uid = '([^']+)';/); + $uid = $1; + debug ("UID: '" . $uid . "'"); + + return unless ($browser->content =~ /\s*var video_vtag = '([^']+)';/); + $vtag = $1; + + $url = $host . "u" . $uid . "/videos/" . $vtag . ".360.mp4"; + debug ("URL: '" . $url . "'"); + return $url, title_to_filename($title); +} + +1; diff --git a/lib/FlashVideo/Site/Vkontakte.pm b/lib/FlashVideo/Site/Vkontakte.pm new file mode 100644 index 0000000..a399a77 --- /dev/null +++ b/lib/FlashVideo/Site/Vkontakte.pm @@ -0,0 +1,7 @@ +# Part of get-flash-videos. See get_flash_videos for copyright. +package FlashVideo::Site::Vkontakte; + +use strict; +use base 'FlashVideo::Site::Vk'; + +1; |