diff options
author | Nigel Taylor <njtaylor0101@gmail.com> | 2013-02-06 13:10:47 +0000 |
---|---|---|
committer | Nigel Taylor <njtaylor0101@gmail.com> | 2013-02-06 13:10:47 +0000 |
commit | 0a74b2fcaf6956bea26498c72d2940999f409c23 (patch) | |
tree | fc0598db12bde16ce717ba00e991241bc5cf182f | |
parent | 44cebc53e85033e4b242ddeb9b73d292e2d305ac (diff) | |
parent | e2cffef5a2c018611ee18765f32c9e29e3033854 (diff) | |
download | get-flash-videos-0a74b2fcaf6956bea26498c72d2940999f409c23.tar.gz |
Merge branch 'master' of https://github.com/matthewbauer/get-flash-videos
-rw-r--r-- | lib/FlashVideo/Site/Ooyala.pm | 4 | ||||
-rw-r--r-- | lib/FlashVideo/Site/Youku.pm | 11 | ||||
-rw-r--r-- | lib/FlashVideo/URLFinder.pm | 5 |
3 files changed, 16 insertions, 4 deletions
diff --git a/lib/FlashVideo/Site/Ooyala.pm b/lib/FlashVideo/Site/Ooyala.pm index 15e4997..f5c84af 100644 --- a/lib/FlashVideo/Site/Ooyala.pm +++ b/lib/FlashVideo/Site/Ooyala.pm @@ -16,7 +16,7 @@ sub find_video { my ($player_js) = uri_unescape( decode_entities( - $browser->content =~ m{<script src=["'](http://player\.ooyala\.com/player\.js[^'"]*)['"]>} + $browser->content =~ m{<script[^>]+src=["'](http://player\.ooyala\.com/player\.js[^'"]*)['"]} ) ); @@ -57,7 +57,7 @@ sub can_handle { return 1 if $url && URI->new($url)->host =~ /\.ooyala\.com$/; - return $browser->content =~ m{<script src=["']http://player\.ooyala\.com/player\.js[^'"]*['"]>}; + return $browser->content =~ m{<script[^>]+src=["']http://player\.ooyala\.com/player\.js[^'"]*['"]}; } 1; diff --git a/lib/FlashVideo/Site/Youku.pm b/lib/FlashVideo/Site/Youku.pm index c4a0e30..a68eae4 100644 --- a/lib/FlashVideo/Site/Youku.pm +++ b/lib/FlashVideo/Site/Youku.pm @@ -24,7 +24,8 @@ sub find_video { # Not quite the URL we expect, maybe it's the embedded one? die "Don't recognise the youku link" unless $embed_url =~ m`player.php/sid/(.+)/v\.swf` - or $embed_url =~ m`qplayer\.swf\?VideoIDS=([^&]+)`; + or $embed_url =~ m`qplayer\.swf\?VideoIDS=([^&]+)` + or $browser->content =~ m`player.php/sid/([^/]+)/v\.swf`; $embed_url = sprintf "http://v.youku.com/v_show/id_%s.html", $1; $browser->get( $embed_url ); @@ -253,4 +254,12 @@ sub shuffle_table { return @shuffled; } +sub can_handle { + my($self, $browser, $url) = @_; + + return 1 if $url && URI->new($url)->host =~ /\.youku\.com$/; + + return $browser->content =~ m{<param[^>]+name=['"]src['"][^>]+value=["']http://player\.youku\.com/player\.php/sid/[^/]+/v\.swf}; +} + 1; diff --git a/lib/FlashVideo/URLFinder.pm b/lib/FlashVideo/URLFinder.pm index 02019a8..ecb2928 100644 --- a/lib/FlashVideo/URLFinder.pm +++ b/lib/FlashVideo/URLFinder.pm @@ -2,6 +2,7 @@ package FlashVideo::URLFinder; use strict; +use Module::Find; use FlashVideo::Mechanize; use FlashVideo::Generic; use FlashVideo::Site; @@ -15,7 +16,7 @@ use URI; # In some cases there isn't an obvious URL to find, so the following will be loaded and their 'can_handle' # method called. -my @extra_can_handle = qw(Brightcove Mtvnservices Gawker Ooyala Gorillavid); +my @extra_can_handle = findsubmod FlashVideo::Site; sub find_package { my($class, $url, $browser) = @_; @@ -38,7 +39,9 @@ sub find_package { if(!defined $package) { for(@extra_can_handle) { + s/FlashVideo::Site:://; my $possible_package = _load($_); + next unless $possible_package->can("can_handle"); $browser->get($url); |