diff options
author | ZakFlash <zakflashvideo@gmail.com> | 2012-06-30 20:51:31 +0100 |
---|---|---|
committer | ZakFlash <zakflashvideo@gmail.com> | 2012-06-30 20:51:31 +0100 |
commit | d630a98d8a5b1b2186d1a5a42bf24291aa232487 (patch) | |
tree | c66e0d644651f1f26f7259bed93b097b521ce1cd | |
parent | e6f6700820da41708b279127ffcc14b4d96b955c (diff) | |
parent | d8f97a965502f993e6e740f6047d641b1a3ce294 (diff) | |
download | get-flash-videos-d630a98d8a5b1b2186d1a5a42bf24291aa232487.tar.gz |
Merge branch 'master' of gfv-git:monsieurvideo/get-flash-videos
-rw-r--r-- | lib/FlashVideo/Site/Google.pm | 3 | ||||
-rw-r--r-- | lib/FlashVideo/Site/Vimeo.pm | 42 | ||||
-rw-r--r-- | t/urls | 2 |
3 files changed, 28 insertions, 19 deletions
diff --git a/lib/FlashVideo/Site/Google.pm b/lib/FlashVideo/Site/Google.pm index 76078c0..c80ef77 100644 --- a/lib/FlashVideo/Site/Google.pm +++ b/lib/FlashVideo/Site/Google.pm @@ -37,7 +37,8 @@ sub find_video { sub can_handle { my($self, $browser, $url) = @_; - return $browser->response->header('Location') =~ /google/i + return $url =~ m,http://video\.google\.,i + || ($browser->response && $browser->response->header('Location') =~ /google/i) || $browser->content =~ /googleplayer\.swf/; } diff --git a/lib/FlashVideo/Site/Vimeo.pm b/lib/FlashVideo/Site/Vimeo.pm index bbf9d15..34d6edf 100644 --- a/lib/FlashVideo/Site/Vimeo.pm +++ b/lib/FlashVideo/Site/Vimeo.pm @@ -2,37 +2,45 @@ package FlashVideo::Site::Vimeo; use strict; +use warnings; use FlashVideo::Utils; +use FlashVideo::JSON; sub find_video { my ($self, $browser, $embed_url) = @_; - my $base = "http://vimeo.com/moogaloop"; my $id; - if($embed_url =~ /clip_id=(\d+)/) { + if ($embed_url =~ /clip_id=(\d+)/) { $id = $1; - } elsif($embed_url =~ m!/(\d+)!) { + } elsif ($embed_url =~ m!/(\d+)!) { $id = $1; } die "No ID found\n" unless $id; - $browser->get("$base/load/clip:$id/embed?param_fullscreen=1¶m_clip_id=$id¶m_show_byline=0¶m_server=vimeo.com¶m_color=cc6600¶m_show_portrait=0¶m_show_title=1"); + my $sig = ($browser->content =~ /"signature":"(\w+)"/)[0]; + my $time = ($browser->content =~ /"timestamp":([0-9]+)/)[0]; + my $quality = ($browser->content =~ /"videoQuality" content="([A-Z]+)"/)[0]; + $quality = lc $quality; - my $xml = from_xml($browser); - my $filename = title_to_filename($xml->{video}->{caption}); - my $request_signature = $xml->{request_signature}; - my $request_signature_expires = $xml->{request_signature_expires}; - my $isHD = $xml->{video}->{isHD}; + # Use the embed api to get the correctly formatted title of the video + my $info_url = "http://vimeo.com/api/oembed.json?url=http://vimeo.com/$id"; + $browser->get($info_url); + my $video_data = from_json($browser->content); + my $title = $video_data->{title}; + + debug "id: $id \n" . + "sig: $sig \n" . + "time: $time \n" . + "quality: $quality \n" . + "title: $title \n"; + + my $url = "http://player.vimeo.com/play_redirect?" . + "clip_id=$id&sig=$sig&time=$time&quality=$quality" . + "&codecs=H264,VP8,VP6&type=moogaloop_local&embed_location="; + my $filename = title_to_filename($title, "flv"); - # I want to follow redirects now. $browser->allow_redirects; - - my $url = "$base/play/clip:$id/$request_signature/$request_signature_expires/?q=hd&type=embed"; - # Check if hd quality is available. - if ($isHD == '1') { - return $url, $filename; - }; - $url = "$base/play/clip:$id/$request_signature/$request_signature_expires/?q=sd&type=embed"; + return $url, $filename; } @@ -16,7 +16,7 @@ http://www.metacafe.com/watch/825729/chi_power_amazing_anti_gravity_top/ http://www.5min.com/Video/How-Evolution-Happens-4804307 # Google Video -http://video.google.com/videoplay?docid=-5813927386194445157 +http://video.google.com/videoplay?docid=-5541517488932573071 # Vimeo https://ubiquity.mozilla.com/ |