diff options
author | Nigel Taylor <njtaylor0101@gmail.com> | 2013-01-31 22:18:02 +0000 |
---|---|---|
committer | Nigel Taylor <njtaylor0101@gmail.com> | 2013-01-31 22:18:02 +0000 |
commit | 44cebc53e85033e4b242ddeb9b73d292e2d305ac (patch) | |
tree | 72c84b81a59151e2fb648a5e33a9dbf353fa87b8 | |
parent | 26fdff36707f52de2d8f39789c1ee7d47389e835 (diff) | |
parent | 2f12e6dc9cd2ee3ecc9df285431ef6f207c0d7df (diff) | |
download | get-flash-videos-44cebc53e85033e4b242ddeb9b73d292e2d305ac.tar.gz |
Merge branch 'master' of git://github.com/monsieurvideo/get-flash-videos
-rw-r--r-- | lib/FlashVideo/Site/Daum.pm | 22 | ||||
-rw-r--r-- | lib/FlashVideo/Site/Kanal5play.pm | 39 | ||||
-rw-r--r-- | lib/FlashVideo/Site/Motherless.pm | 22 | ||||
-rw-r--r-- | lib/FlashVideo/Site/Redtube.pm | 2 |
4 files changed, 54 insertions, 31 deletions
diff --git a/lib/FlashVideo/Site/Daum.pm b/lib/FlashVideo/Site/Daum.pm index 7b10c6e..4a572be 100644 --- a/lib/FlashVideo/Site/Daum.pm +++ b/lib/FlashVideo/Site/Daum.pm @@ -50,17 +50,22 @@ sub get_video_id { die "Cannot fetch '$url'\n" if !$browser->success(); } + if ($browser->response->is_redirect()) { + my $url = $browser->response->header('Location'); + $browser->get($url); + die "Cannot fetch '$url'\n" if !$browser->success(); + } + my $document = $browser->content(); - # "http://flvs.daum.net/flvPlayer.swf?vid=FlVGvam5dPM$" - my $flv_player_url = quotemeta 'http://flvs.daum.net/flvPlayer.swf'; - my $video_id_pattern_1 = qr{['"] $flv_player_url [?] vid = ([^'"&]+)}xmsi; + # VodPlayer.swf?vid=3i5f_JquGsk$ + my $video_id_pattern_1 = qr{VodPlayer[.]swf [?] vid = (.+?) ["'&]}xmsi; my $func_name; # Story.UI.PlayerManager.createViewer('2oHFG_aR9uA$'); $func_name = quotemeta 'Story.UI.PlayerManager.createViewer'; - my $video_id_pattern_2 = qr{$func_name [(] ' (.+?) ' [)]}xms; + my $video_id_pattern_2 = qr{$func_name [(] ' (.+?) '}xms; # daum.Music.VideoPlayer.add("body_mv_player", "_nACjJ65nKg$", $func_name = quotemeta 'daum.Music.VideoPlayer.add'; @@ -69,17 +74,12 @@ sub get_video_id { # controller/video/viewer/VideoView.html?vid=90-m2tl87zM$&play_loc=... my $video_id_pattern_4 - = qr{/video/viewer/VideoView.html [?] vid = (.+?) &}xms; - - # DaumVodPlayer.swf?vid=vd247EUCULRUVVUQSVytEDS&... - my $video_id_pattern_5 - = qr{DaumVodPlayer[.]swf [?] vid = (.+?) &}xmsi; + = qr{/video/viewer/VideoView.html [?] vid = (.+?) &}xmsi; if ( $document !~ $video_id_pattern_1 && $document !~ $video_id_pattern_2 && $document !~ $video_id_pattern_3 - && $document !~ $video_id_pattern_4 - && $document !~ $video_id_pattern_5 ) + && $document !~ $video_id_pattern_4 ) { die "Cannot find video ID.\n"; } diff --git a/lib/FlashVideo/Site/Kanal5play.pm b/lib/FlashVideo/Site/Kanal5play.pm index b750efe..3f9f88c 100644 --- a/lib/FlashVideo/Site/Kanal5play.pm +++ b/lib/FlashVideo/Site/Kanal5play.pm @@ -8,21 +8,22 @@ use FlashVideo::JSON; my $bitrates = { - "low" => 250000, - "medium" => 450000, - "high" => 900000 }; + low => 250000, + medium => 450000, + high => 900000 +}; sub find_video { my ($self, $browser, $embed_url, $prefs) = @_; - if(!($browser->uri->as_string =~ m/video\/([0-9]*)/)){ - die "No video id found in url"; + if (!($browser->uri->as_string =~ m/video\/([0-9]*)/)) { + die "No video id found in url"; } my ($video_id) = $1; my $info_url = "http://www.kanal5play.se/api/getVideo?format=FLASH&videoId=$video_id"; $browser->get($info_url); - - if (!$browser->success){ - die "Couldn't download $info_url: " . $browser->response->status_line; + + if (!$browser->success) { + die "Couldn't download $info_url: " . $browser->response->status_line; } my $jsonstr = $browser->content; @@ -35,19 +36,19 @@ sub find_video { my ($rtmp) = "rtmp://fl1.c00608.cdn.qbrick.com:1935/00608"; my ($playpath) = $json->{streams}[0]->{source}; - my $i; - foreach $i (keys %{ $json->{streams} }) { - my ($rate) = int($json->{streams}[$i]->{bitrate}); - if($bitrates->{$prefs->{quality}} == $rate){ - $playpath = $json->{streams}[$i]->{source}; - } + foreach my $stream ($json->{streams}[0]) { + my ($rate) = int($stream->{bitrate}); + if ($bitrates->{$prefs->{quality}} eq $rate) { + $playpath = $stream->{source}; + last; + } } + return { - flv => title_to_filename($filename, "flv"), - rtmp => $rtmp, - playpath => $playpath, - swfVfy => "http://www.kanal5play.se/flash/StandardPlayer.swf" + flv => title_to_filename($filename, "flv"), + rtmp => $rtmp, + playpath => $playpath, + swfVfy => "http://www.kanal5play.se/flash/StandardPlayer.swf" }; - } 1; diff --git a/lib/FlashVideo/Site/Motherless.pm b/lib/FlashVideo/Site/Motherless.pm new file mode 100644 index 0000000..c576e45 --- /dev/null +++ b/lib/FlashVideo/Site/Motherless.pm @@ -0,0 +1,22 @@ +# Part of get-flash-videos. See get_flash_videos for copyright. +package FlashVideo::Site::Motherless; + +use strict; +use FlashVideo::Utils; + +sub find_video { + my ($self, $browser, $embed_url) = @_; + + my $url; + if ($browser->content =~ /file: '([^']+)'/) { + $url = $1."?start=0"; + } else { + die "Unable to extract video url"; + } + + (my $title) = extract_title($browser) =~ /:\s+(.*)/; + + return $url, title_to_filename($title, "flv"); +} + +1; diff --git a/lib/FlashVideo/Site/Redtube.pm b/lib/FlashVideo/Site/Redtube.pm index 1b54986..a748974 100644 --- a/lib/FlashVideo/Site/Redtube.pm +++ b/lib/FlashVideo/Site/Redtube.pm @@ -8,7 +8,7 @@ use URI::Escape; sub find_video { my($self, $browser, $embed_url) = @_; - my($title) = $browser->content =~ /<h1 class="videoTitle">([^<]+)</; + my($title) = extract_title($browser) =~ /(.*) \|/; my($url) = $browser->content =~ /mp4_url=([^&"]+)/; $url = uri_unescape($url); |