aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNigel Taylor <njtaylor0101@gmail.com>2013-04-09 13:04:47 -0700
committerNigel Taylor <njtaylor0101@gmail.com>2013-04-09 13:04:47 -0700
commit2c29ad2e7e60d85523a045d3be7b4bd2ee493562 (patch)
tree4a88db70a41e2953564b9d98a9f6af0198ebec11
parent2d29a1bcc35593e57a42cdb6fa78a9e34b0ceff6 (diff)
parent232f28a49a110c1b8bc61c2bd85435b87fad260e (diff)
downloadget-flash-videos-2c29ad2e7e60d85523a045d3be7b4bd2ee493562.tar.gz
Merge pull request #114 from sleep-walker/master
Introduce support for GosuPark.com, Facebook like button shortcut
-rw-r--r--lib/FlashVideo/Site/Facebook.pm3
-rw-r--r--lib/FlashVideo/Site/Gosupark.pm24
-rw-r--r--lib/FlashVideo/Site/Video44.pm49
-rw-r--r--lib/FlashVideo/Site/Videofun.pm39
-rw-r--r--lib/FlashVideo/Site/Yourupload.pm60
5 files changed, 175 insertions, 0 deletions
diff --git a/lib/FlashVideo/Site/Facebook.pm b/lib/FlashVideo/Site/Facebook.pm
index 5ac4db9..ba2aff1 100644
--- a/lib/FlashVideo/Site/Facebook.pm
+++ b/lib/FlashVideo/Site/Facebook.pm
@@ -12,6 +12,9 @@ sub Version { $VERSION; }
sub find_video {
my ($self, $browser, $embed_url) = @_;
+ # If we should process Facebook's Like button, leave
+ return if ($embed_url =~ /http:\/\/www\.facebook\.com\/plugins\/like\.php/);
+
# Grab the file from the page..
my $params = ($browser->content =~ /\["params","(.+?)"\]/)[0];
$params =~ s/\\u([[:xdigit:]]{1,4})/chr(eval("0x$1"))/egis;
diff --git a/lib/FlashVideo/Site/Gosupark.pm b/lib/FlashVideo/Site/Gosupark.pm
new file mode 100644
index 0000000..3e285a4
--- /dev/null
+++ b/lib/FlashVideo/Site/Gosupark.pm
@@ -0,0 +1,24 @@
+# Part of get-flash-videos. See get_flash_videos for copyright.
+package FlashVideo::Site::Gosupark;
+
+use strict;
+use FlashVideo::Utils;
+
+our $VERSION = '0.01';
+sub Version() { $VERSION; }
+
+sub find_video {
+ my ($self, $browser, $embed_url) = @_;
+ my $url = "";
+
+ if ($browser->content =~ /.*\s*file: "(http:\/\/gosupark[^"]+).*",/) {
+ $url = $1;
+ } else {
+ return;
+ }
+ debug ("URL: '" . $url . "'");
+ return $url, title_to_filename("", "mp4");
+}
+
+1;
+
diff --git a/lib/FlashVideo/Site/Video44.pm b/lib/FlashVideo/Site/Video44.pm
new file mode 100644
index 0000000..f3dbec9
--- /dev/null
+++ b/lib/FlashVideo/Site/Video44.pm
@@ -0,0 +1,49 @@
+# Part of get-flash-videos. See get_flash_videos for copyright.
+package FlashVideo::Site::Video44;
+
+use strict;
+use FlashVideo::Utils;
+use URI::Escape;
+
+our $VERSION = '0.01';
+sub Version() { $VERSION; }
+
+sub find_video {
+ my ($self, $browser, $embed_url) = @_;
+
+ my $flashvars = "";
+ my $file = "";
+ my $url = "";
+ my $name = "";
+
+ # get configuration passed to flash player
+ if ($browser->content =~ /\s*<param name="flashvars"\s*value="([^"]+)" \/>/) {
+ $flashvars = $1;
+ } else {
+ # if we can't get it, just leave as the video URL is there
+ debug("Can't find flashvars");
+ return;
+ }
+
+ debug ("Flashvars: " . $flashvars);
+
+ # in the configuration there is also URL we're looking for
+ if ($flashvars =~ /&amp;file=(http[^&]+)&amp;/) {
+ $file = $1;
+ } else {
+ debug("Can't find file");
+ return;
+ }
+
+ debug("File: " . $file);
+
+ $url = uri_unescape($file);
+ debug("URL: '" . $url . "'");
+
+ # URL ends with filename
+ $name = $url;
+ $name =~ s/.*\/([^\/]+)/$1/;
+ return $url, title_to_filename($name);
+}
+
+1;
diff --git a/lib/FlashVideo/Site/Videofun.pm b/lib/FlashVideo/Site/Videofun.pm
new file mode 100644
index 0000000..0d16d03
--- /dev/null
+++ b/lib/FlashVideo/Site/Videofun.pm
@@ -0,0 +1,39 @@
+# Part of get-flash-videos. See get_flash_videos for copyright.
+package FlashVideo::Site::Videofun;
+
+use strict;
+use FlashVideo::Utils;
+use URI::Escape;
+
+our $VERSION = '0.01';
+sub Version() { $VERSION; }
+
+sub find_video {
+ my ($self, $browser, $embed_url) = @_;
+
+ my $coded_url = "";
+ my $url = "";
+ my $name = "";
+
+
+ # read URL from the configuration passed to flash player
+ if ($browser->content =~ /\s*{url: "(http[^"]+)".*autoBuffering.*/) {
+ $coded_url = $1;
+ } else {
+ # if we can't get it, just leave as the video URL is there
+ return;
+ }
+
+ debug ("Coded URL: " . $coded_url);
+
+
+ $url = uri_unescape($coded_url);
+ debug("URL: '" . $url . "'");
+
+ # URL ends with filename
+ $name = $url;
+ $name =~ s/.*\/([^\/]+)\?.*/$1/;
+ return $url, title_to_filename($name);
+}
+
+1;
diff --git a/lib/FlashVideo/Site/Yourupload.pm b/lib/FlashVideo/Site/Yourupload.pm
new file mode 100644
index 0000000..39ddd55
--- /dev/null
+++ b/lib/FlashVideo/Site/Yourupload.pm
@@ -0,0 +1,60 @@
+# Part of get-flash-videos. See get_flash_videos for copyright.
+package FlashVideo::Site::Yourupload;
+
+use strict;
+use FlashVideo::Utils;
+use URI::Escape;
+
+our $VERSION = '0.01';
+sub Version() { $VERSION; }
+
+sub find_video {
+ my ($self, $browser, $embed_url) = @_;
+
+ my $flashvars = "";
+ my $file = "";
+ my $url = "";
+ my $name = "";
+
+ if ($embed_url !~ /http:\/\/yourupload.com\/embed\//) {
+ if ($browser->content =~ /<iframe src="(http:\/\/yourupload.com\/embed\/[^"]+)" style/) {
+ $embed_url = $1;
+ $browser->get($embed_url);
+ } else {
+ # we can't find the frame with embed URL
+ return;
+ }
+ }
+
+ # get configuration passed to flash player
+ if ($browser->content =~ /\s*flashvars="([^"]+)"/) {
+ $flashvars = $1;
+ } else {
+ # if we can't get it, just leave as the video URL is there
+ debug("Can't find flashvars");
+ return;
+ }
+
+ debug ("Flashvars: " . $flashvars);
+
+ # in the configuration there is also URL we're looking for
+ if ($flashvars =~ /&file=(http[^&]+)&/) {
+ $file = $1;
+ } else {
+ debug("Can't find file");
+ return;
+ }
+
+ debug("File: " . $file);
+
+ $url = uri_unescape($file);
+ debug("URL: '" . $url . "'");
+
+ # URL ends with filename
+ $name = $url;
+ $name =~ s/.*\/([^\/]+\.(flv|mp4)).*/$1/;
+ debug("Filename: " . $name);
+ return $url, title_to_filename($name);
+}
+
+1;