aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNigel Taylor <njtaylor0101@gmail.com>2013-02-12 14:59:58 -0800
committerNigel Taylor <njtaylor0101@gmail.com>2013-02-12 14:59:58 -0800
commitb24d733991fae27578fb8f366501dccdc9577642 (patch)
tree5a0b1142b742673348e927d6f255deffa52aaeed
parent6ee0210e05214fc45e5c72d186d4539002534ccc (diff)
parente2cffef5a2c018611ee18765f32c9e29e3033854 (diff)
downloadget-flash-videos-b24d733991fae27578fb8f366501dccdc9577642.tar.gz
Merge pull request #91 from matthewbauer/master
misc fixes, check all plugins for can_handle method
-rw-r--r--lib/FlashVideo/Site/Ooyala.pm4
-rw-r--r--lib/FlashVideo/Site/Youku.pm11
-rw-r--r--lib/FlashVideo/URLFinder.pm5
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 8277967..8b4cb12 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);