diff options
author | Nigel Taylor <njtaylor0101@gmail.com> | 2013-04-03 07:29:32 -0700 |
---|---|---|
committer | Nigel Taylor <njtaylor0101@gmail.com> | 2013-04-03 07:29:32 -0700 |
commit | 8ef3332c754851f20740658cbdb4abee4414e72d (patch) | |
tree | f2b53027937c4f06682343de40c65073a1ef650b | |
parent | 06860ae3cde100007c87b554853bb86a7603b514 (diff) | |
parent | 4283749e2da2cdd3e2a66a786cbe0e197b19d616 (diff) | |
download | get-flash-videos-8ef3332c754851f20740658cbdb4abee4414e72d.tar.gz |
Merge pull request #111 from sleep-walker/master
add support for vkontakte.ru (and vk.com)
-rw-r--r-- | lib/FlashVideo/Generic.pm | 2 | ||||
-rw-r--r-- | lib/FlashVideo/Site/Vk.pm | 48 | ||||
-rw-r--r-- | lib/FlashVideo/Site/Vkontakte.pm | 7 |
3 files changed, 57 insertions, 0 deletions
diff --git a/lib/FlashVideo/Generic.pm b/lib/FlashVideo/Generic.pm index a3b0e49..1625df4 100644 --- a/lib/FlashVideo/Generic.pm +++ b/lib/FlashVideo/Generic.pm @@ -6,6 +6,7 @@ use FlashVideo::Utils; use URI; use FlashVideo::URLFinder; use URI::Escape qw(uri_unescape); +use HTML::Entities qw(decode_entities); my $video_re = qr!http[-:/a-z0-9%_.?=&]+@{[EXTENSIONS]} # Grab any params that might be used for auth.. @@ -71,6 +72,7 @@ sub find_video { if(!$actual_url) { for my $iframe($browser->content =~ /<iframe[^>]+src=["']?([^"'>]+)/gi) { $iframe = URI->new_abs($iframe, $browser->uri); + $iframe = decode_entities($iframe); debug "Found iframe: $iframe"; my $sub_browser = $browser->clone; $sub_browser->get($iframe); diff --git a/lib/FlashVideo/Site/Vk.pm b/lib/FlashVideo/Site/Vk.pm new file mode 100644 index 0000000..581784f --- /dev/null +++ b/lib/FlashVideo/Site/Vk.pm @@ -0,0 +1,48 @@ +# Part of get-flash-videos. See get_flash_videos for copyright. +package FlashVideo::Site::Vk; + +use strict; +use FlashVideo::Utils; + +our $VERSION = '0.01'; +sub Version() { $VERSION; } + +sub find_video { + my ($self, $browser, $embed_url) = @_; + my $new_embed_url = ""; + my $title = ""; + my $host = ""; + my $uid = ""; + my $vtag = ""; + my $url = ""; + + # 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\//; + $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, "mp4"); +} + +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; |