(.+?))[0];
16 | die "Unable to extract url" unless $url;
17 |
18 | # Extract filename from page and format
19 |
20 | # title_to_filename() can't extract extension from URLs like
21 | # foo.flv?stuff - should probably change, but for now don't bother
22 | # passing in the URL. (Will default to .flv)
23 |
24 | return { rtmp => "rtmp://flv.nhk.or.jp/ondemand/flv/news/".$url,
25 | flv => $url};
26 | }
27 |
28 | 1;
29 |
--------------------------------------------------------------------------------
/t/google_video_search.t:
--------------------------------------------------------------------------------
1 | #!perl
2 | use strict;
3 | no warnings;
4 | use lib qw(..);
5 | use Test::More;
6 | use FlashVideo::Site::Googlevideosearch;
7 |
8 | {
9 | my $mech = FlashVideo::Mechanize->new;
10 | $mech->get("http://www.google.com");
11 | plan skip_all => "We don't appear to have an internet connection" if $mech->response->is_error;
12 | }
13 |
14 | plan tests => 2;
15 |
16 | my @results = FlashVideo::Site::Googlevideosearch->search('Iron Man trailer');
17 |
18 | ok(@results > 1, "Results returned");
19 |
20 | # Check to see if the results look sane
21 | my $sane_result_count = 0;
22 |
23 | foreach my $result (@results) {
24 | if ((ref($result) eq 'HASH') and
25 | $result->{name} and
26 | $result->{url} =~ m'^https?://') {
27 | $sane_result_count++;
28 | }
29 | }
30 |
31 | ok($sane_result_count == @results, "Results look sane");
32 |
--------------------------------------------------------------------------------
/utils/combine-tail:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env perl
2 | #
3 | # get_flash_videos -- download all the Flash videos off a web page
4 | #
5 | # http://code.google.com/p/get-flash-videos/
6 | #
7 | # Copyright 2009, zakflash and MonsieurVideo
8 | #
9 |
10 | # Fix up for modules only used once giving compile warnings
11 | # use a second time to stop typo warning....
12 |
13 | use HTTP::Headers qw(referrer);
14 | use HTTP::Request qw(url);
15 | my $dummy = $IO::Uncompress::Bunzip2::Bunzip2Error;
16 | $dummy = $IO::Uncompress::Inflate::InflateError;
17 | $dummy = $IO::Compress::Bzip2::Bzip2Error;
18 | $dummy = $IO::Compress::Deflate::DeflateError;
19 | $dummy = $HTTP::Status::RC_MOVED_TEMPORARILY;
20 | $dummy = $HTTP::Status::RC_NO_CODE;
21 | $dummy = $XML::Simple::xml_out;
22 | $dummy = $XML::Simple::xml_in;
23 | $dummy = $XML::SAX::ParserPackage;
24 | $dummy = $Net::HTTPS::blocking;
25 |
26 | 1;
27 |
--------------------------------------------------------------------------------
/lib/FlashVideo/VideoPreferences.pm:
--------------------------------------------------------------------------------
1 | # Part of get-flash-videos. See get_flash_videos for copyright.
2 | package FlashVideo::VideoPreferences;
3 |
4 | use strict;
5 | use FlashVideo::VideoPreferences::Quality;
6 | use FlashVideo::VideoPreferences::Account;
7 |
8 | sub new {
9 | my($class, %opt) = @_;
10 |
11 | return bless {
12 | raw => $opt{raw} || 0,
13 | quality => $opt{quality} || "high",
14 | subtitles => $opt{subtitles} || 0,
15 | type => $opt{type} || "",
16 | }, $class;
17 | }
18 |
19 | sub quality {
20 | my($self) = @_;
21 |
22 | return FlashVideo::VideoPreferences::Quality->new($self->{quality});
23 | }
24 |
25 | sub subtitles {
26 | my($self) = @_;
27 |
28 | return $self->{subtitles};
29 | }
30 |
31 | sub account {
32 | my($self, $site, $prompt) = @_;
33 |
34 | return FlashVideo::VideoPreferences::Account->new($site, $prompt);
35 | }
36 |
37 | 1;
38 |
--------------------------------------------------------------------------------
/lib/FlashVideo/Site/Xhamster.pm:
--------------------------------------------------------------------------------
1 | # Part of get-flash-videos. See get_flash_videos for copyright.
2 | package FlashVideo::Site::Xhamster;
3 |
4 | use strict;
5 | use FlashVideo::Utils;
6 |
7 | sub find_video {
8 | my ($self, $browser) = @_;
9 |
10 | my $server;
11 | if ($browser->content =~ m{'srv': '(http://[^'"]+)'}) {
12 | $server = $1;
13 | }
14 | else {
15 | die "Couldn't determine xhamster server";
16 | }
17 |
18 | my $video_file;
19 | if ($browser->content =~ m{'file': '([^'"]+\.flv)'}) {
20 | $video_file = $1;
21 | }
22 | else {
23 | die "Couldn't determine xhamster video filename";
24 | }
25 |
26 | my $filename = title_to_filename(extract_title($browser));
27 |
28 | my $url = sprintf "%s/flv2/%s", $server, $video_file;
29 |
30 | # I want to follow redirects now
31 | $browser->allow_redirects;
32 |
33 | return $url, $filename;
34 | }
35 |
36 | 1;
37 |
--------------------------------------------------------------------------------
/lib/FlashVideo/Site/Xnxx.pm:
--------------------------------------------------------------------------------
1 | # Part of get-flash-videos. See get_flash_videos for copyright.
2 | package FlashVideo::Site::Xnxx;
3 |
4 | use strict;
5 | use FlashVideo::Utils;
6 | use URI::Escape;
7 |
8 | sub find_video {
9 | my ($self, $browser, $embed_url) = @_;
10 |
11 | # Grab the file from the page..
12 | my $url = ($browser->content =~ /flv_url=(.+?)&/)[0];
13 | $url = uri_unescape($url);
14 | die "Unable to extract url" unless $url;
15 |
16 | # Extract filename from page and format
17 | $browser->content =~ /(?:
|\s*)([^<]+)/;
18 |
19 | # title_to_filename() can't extract extension from URLs like
20 | # foo.flv?stuff - should probably change, but for now don't bother
21 | # passing in the URL. (Will default to .flv)
22 | my $filename = title_to_filename($1);
23 |
24 | return $url, $filename;
25 | }
26 |
27 | 1;
28 |
--------------------------------------------------------------------------------
/lib/FlashVideo/Site/Aniboom.pm:
--------------------------------------------------------------------------------
1 | # Part of get-flash-videos. See get_flash_videos for copyright.
2 | package FlashVideo::Site::Aniboom;
3 |
4 | use strict;
5 | use FlashVideo::Utils;
6 |
7 | sub find_video {
8 | my ($self, $browser, $embed_url) = @_;
9 |
10 | my ($id, $url, $title);
11 |
12 | if ($browser->uri->as_string =~ /\/animation-video\/(\d*)\/([^\/]*)/) {
13 | $id = $1;
14 | $title = $2;
15 | $title =~ s/-/ /g;
16 | } else {
17 | die "Could not detect video ID!";
18 | }
19 |
20 | $browser->get("http://www.aniboom.com/animations/player/handlers/animationDetails.aspx?mode=&movieid=$id");
21 |
22 | if ($browser->content =~ /(?:mp4|flv)=([^&]*)/) {
23 | $url = $1;
24 | $url =~ s/%([0-9A-Fa-f]{2})/chr(hex($1))/eg;
25 | } else {
26 | die "Could not get flv/mp4 location!";
27 | }
28 |
29 | return $url, title_to_filename($title);
30 | }
31 |
32 | 1;
33 |
34 |
--------------------------------------------------------------------------------
/lib/FlashVideo/Site/Video44.pm:
--------------------------------------------------------------------------------
1 | # Part of get-flash-videos. See get_flash_videos for copyright.
2 | package FlashVideo::Site::Video44;
3 |
4 | use strict;
5 | use FlashVideo::Utils;
6 | use URI::Escape;
7 |
8 | our $VERSION = '0.01';
9 | sub Version() { $VERSION; }
10 |
11 | sub find_video {
12 | my ($self, $browser, $embed_url) = @_;
13 |
14 | my $flashvars = "";
15 | my $file = "";
16 | my $url = "";
17 | my $name = "";
18 |
19 | debug ("Content: " . $browser->content);
20 | if ($browser->content =~ /file: "(http:[^"]*\.(flv|mp4))",/) {
21 | $file = $1;
22 | } else {
23 | debug("Can't find file");
24 | return;
25 | }
26 |
27 | debug("File: " . $file);
28 |
29 | $url = uri_unescape($file);
30 | debug("URL: '" . $url . "'");
31 |
32 | # URL ends with filename
33 | $name = $url;
34 | $name =~ s/.*\/([^\/]+)/$1/;
35 | return $url, title_to_filename($name);
36 | }
37 |
38 | 1;
39 |
--------------------------------------------------------------------------------
/lib/FlashVideo/Site/Zshare.pm:
--------------------------------------------------------------------------------
1 | # A get-flash-videos module for the zshare.net website
2 | # Copyright (C) 2011 Rudolf Olah
3 | # Licensed under the GNU GPL v3 or later
4 |
5 | # Created using the instructions from: http://code.google.com/p/get-flash-videos/wiki/AddingSite
6 |
7 | package FlashVideo::Site::Zshare;
8 |
9 | use strict;
10 | use FlashVideo::Utils;
11 |
12 | sub find_video {
13 | my ($self, $browser, $embed_url, $prefs) = @_;
14 | # $browser is a WWW::Mechanize object
15 | # $embed_url will normally be the same as the page, but in the case
16 | # of embedded content it may differ.
17 | $embed_url = ($browser->content =~ /iframe src="(.*videoplayer.*?)"/i)[0];
18 | $browser->get($embed_url);
19 | my $url = ($browser->content =~ /file:.*"(.*?)"/i)[0];
20 | my $filename = ($browser->content =~ /.*?- (.*)<\/title>/i)[0];
21 | return $url, $filename;
22 | }
23 |
24 | 1;
25 |
--------------------------------------------------------------------------------
/lib/FlashVideo/Site/Expertvillage.pm:
--------------------------------------------------------------------------------
1 | # Part of get-flash-videos. See get_flash_videos for copyright.
2 | package FlashVideo::Site::Expertvillage;
3 |
4 | use strict;
5 | use FlashVideo::Utils;
6 | use URI::Escape;
7 |
8 | sub find_video {
9 | my ($self, $browser) = @_;
10 |
11 | my($fn) = $browser->content =~ /SWFObject\(['"][^'"]+flv=([^'"]+)/;
12 | my $embedvars = uri_unescape($browser->content =~ /embedvars['"],\s*['"]([^'"]+)/);
13 | die "Unable to find video info" unless $fn and $embedvars;
14 |
15 | my($title) = $browser->content =~ m{]*>(.*)}s;
16 | my $filename = title_to_filename($title);
17 |
18 | $browser->get("$embedvars?fn=$fn");
19 | die "Unable to get emebdding info" if $browser->response->is_error;
20 |
21 | my $url = uri_unescape($browser->content =~ /source=([^&]+)/);
22 | die "Unable to find video URL" unless $url;
23 |
24 | return $url, $filename;
25 | }
26 |
27 | 1;
28 |
--------------------------------------------------------------------------------
/t/00_load.t:
--------------------------------------------------------------------------------
1 | #!perl
2 |
3 | use warnings;
4 | use strict;
5 | use Test::More tests => 20;
6 |
7 | BEGIN {
8 | chdir 't' if -d 't';
9 | push @INC, '../lib';
10 |
11 | my @classes = qw(
12 | Compress::Zlib
13 | FlashVideo::Downloader
14 | FlashVideo::Generic
15 | FlashVideo::Mechanize
16 | FlashVideo::RTMPDownloader
17 | FlashVideo::Search
18 | FlashVideo::Site
19 | FlashVideo::URLFinder
20 | FlashVideo::Utils
21 | FlashVideo::VideoPreferences
22 | HTML::Entities
23 | HTML::TokeParser
24 | HTTP::Config
25 | HTTP::Cookies
26 | HTTP::Request::Common
27 | LWP::Protocol::http
28 | Tie::IxHash
29 | URI
30 | WWW::Mechanize
31 | XML::Simple
32 | );
33 |
34 | foreach my $class (@classes) {
35 | use_ok $class or BAIL_OUT("Could not load $class");
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/utils/combine-header:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env perl
2 | #
3 | # get_flash_videos -- download all the Flash videos off a web page
4 | #
5 | # http://code.google.com/p/get-flash-videos/
6 | #
7 | # Copyright 2009, zakflash and MonsieurVideo
8 | #
9 | # Licensed under the Apache License, Version 2.0 (the "License"); you may
10 | # not use this file except in compliance with the License. You may obtain a
11 | # copy of the License at
12 | # http://www.apache.org/licenses/LICENSE-2.0
13 | # Unless required by applicable law or agreed to in writing, software
14 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16 | # License for the specific language governing permissions and limitations
17 | # under the License.
18 | #
19 | # Contributions are welcome and encouraged, but please take care to
20 | # maintain the JustWorks(tm) nature of the program.
21 |
--------------------------------------------------------------------------------
/lib/FlashVideo/Site/Collegehumor.pm:
--------------------------------------------------------------------------------
1 | # Part of get-flash-videos. See get_flash_videos for copyright.
2 | package FlashVideo::Site::Collegehumor;
3 |
4 | use strict;
5 | use FlashVideo::Utils;
6 |
7 | sub find_video {
8 | my ($self, $browser, $embed_url) = @_;
9 | my $base = "http://www.collegehumor.com/moogaloop";
10 |
11 | my $id;
12 | if($browser->content =~ /video:(\d+)/) {
13 | $id = $1;
14 | } elsif($embed_url =~ m!) {
15 | # XXX: This is broken still...
16 | # I don't know a good way to turn new IDs to old IDs, I may just load the page based on this id and then go back to the first case
17 | $id = $1;
18 | }
19 | die "No ID found\n" unless $id;
20 |
21 | $browser->get("$base/video:$id");
22 |
23 | my $xml = from_xml($browser);
24 |
25 | my $title = $xml->{video}->{caption};
26 | $title = extract_title($browser) if ref $title;
27 |
28 | return $xml->{video}->{file}, title_to_filename($title);
29 | }
30 |
31 | 1;
32 |
--------------------------------------------------------------------------------
/lib/FlashVideo/Site/Bing.pm:
--------------------------------------------------------------------------------
1 | # Part of get-flash-videos. See get_flash_videos for copyright.
2 | package FlashVideo::Site::Bing;
3 | use strict;
4 | use FlashVideo::Utils;
5 |
6 | sub find_video {
7 | my ($self, $browser, $embed_url, $prefs) = @_;
8 |
9 | my $count = 0;
10 | while((my $location = $browser->response->header("Location")) && $count++ < 5) {
11 | $browser->get($location);
12 | }
13 |
14 | my $title;
15 | if ($browser->content =~ /sourceFriendly:\s*'([^']+)'[\s\S]+?\s*title:\s*'([^']+)'/) {
16 | $title = "$1 - $2";
17 | }
18 |
19 | my $url;
20 | if ($browser->content =~ /formatCode:\s*1003,\s*url:\s*'([^']+)'/) {
21 | $url = $1;
22 |
23 | # Unencode the url
24 | $url =~ s/\\x([0-9a-f]{2})/chr hex $1/egi;
25 | }
26 | die "Unable to extract video url" unless $url;
27 |
28 | # MSNBC hosted videos use 302 redirects
29 | $browser->allow_redirects;
30 |
31 | return $url, title_to_filename($title);
32 | }
33 |
34 | 1;
35 |
--------------------------------------------------------------------------------
/lib/FlashVideo/Site/Ima.pm:
--------------------------------------------------------------------------------
1 | # Part of get-flash-videos. See get_flash_videos for copyright.
2 | package FlashVideo::Site::Ima;
3 |
4 | use strict;
5 | use FlashVideo::Utils;
6 |
7 | sub find_video {
8 | my ($self, $browser) = @_;
9 |
10 | my($id) = $browser->uri =~ /id=(\d+)/;
11 | die "ID not found" unless $id;
12 |
13 | my $rpc = "http://www.ima.umn.edu/videos/video_rpc.php?id=$id";
14 | $browser->get($rpc);
15 |
16 | my($title) = $browser->content =~ m{(.*)};
17 | my($instance) = $browser->content =~ m{(.*)};
18 | my($file) = $browser->content =~ m{(.*)};
19 |
20 | return {
21 | rtmp => "rtmp://reel.ima.umn.edu/ima/$instance/$file",
22 | flv => title_to_filename($title)
23 | };
24 | }
25 |
26 | sub can_handle {
27 | my($self, $browser, $url) = @_;
28 |
29 | my $host = URI->new($url)->host;
30 | return $host =~ /ima\.umn\.edu/i;
31 | }
32 |
33 | 1;
34 |
--------------------------------------------------------------------------------
/lib/FlashVideo/Site/About.pm:
--------------------------------------------------------------------------------
1 | # Part of get-flash-videos. See get_flash_videos for copyright.
2 | package FlashVideo::Site::About;
3 |
4 | use strict;
5 | use FlashVideo::Utils;
6 | use base 'FlashVideo::Site::Brightcove';
7 |
8 | my $JS_RE = qr/vdo_None\.js/;
9 |
10 | sub find_video {
11 | my($self, $browser, $embed_url) = @_;
12 |
13 | my($video_ref) = $browser->content =~ /zIvdoId=["']([^"']+)/;
14 | die "Unable to extract video ref" unless $video_ref;
15 |
16 | my($js_src) = $browser->content =~ /["']([^"']+$JS_RE)/;
17 | $browser->get($js_src);
18 | my($player_id) = $browser->content =~ /playerId.*?(\d+)/;
19 | die "Unable to extract playerId" unless $player_id;
20 |
21 | return $self->amfgateway($browser, $player_id, { videoRefId => $video_ref });
22 | }
23 |
24 | sub can_handle {
25 | my($self, $browser, $url) = @_;
26 |
27 | # can only handle videos embedded with this javascript code.
28 | return $browser->content =~ $JS_RE;
29 | }
30 |
31 | 1;
32 |
--------------------------------------------------------------------------------
/lib/FlashVideo/Site/Filebox.pm:
--------------------------------------------------------------------------------
1 | # Part of get-flash-videos. See get_flash_videos for copyright.
2 |
3 | package FlashVideo::Site::Filebox;
4 |
5 | use strict;
6 | use FlashVideo::Utils;
7 |
8 | sub find_video {
9 | my ($self, $browser, $embed_url) = @_;
10 |
11 | my $pause = 5; #if we don't pause, we don't get the proper video page
12 | info 'Pausing for '.$pause.' seconds (or the server won\'t respond)...';
13 | sleep($pause);
14 |
15 | my $btn_id = 'btn_download'; #the ID of the button to submit the form
16 | for my $form ($browser->forms) {
17 | if ($form->find_input('#'.$btn_id)){
18 | info 'Submitting form to get real video page.';
19 | $browser->request($form->click('#'.$btn_id)); #submit to get the real page
20 | }
21 | }
22 |
23 | my ($filename) = ($browser->content =~ /product_file_name=(.*?)[&'"]/);
24 | my ($url) = ($browser->content =~ /product_download_url=(.*?)[&'"]/);
25 |
26 | return $url, $filename;
27 | }
28 |
29 | 1;
30 |
--------------------------------------------------------------------------------
/lib/FlashVideo/Site/Videofun.pm:
--------------------------------------------------------------------------------
1 | # Part of get-flash-videos. See get_flash_videos for copyright.
2 | package FlashVideo::Site::Videofun;
3 |
4 | use strict;
5 | use FlashVideo::Utils;
6 | use URI::Escape;
7 |
8 | our $VERSION = '0.01';
9 | sub Version() { $VERSION; }
10 |
11 | sub find_video {
12 | my ($self, $browser, $embed_url) = @_;
13 |
14 | my $coded_url = "";
15 | my $url = "";
16 | my $name = "";
17 |
18 |
19 | # read URL from the configuration passed to flash player
20 | if ($browser->content =~ /\s*{url: "(http[^"]+)".*autoBuffering.*/) {
21 | $coded_url = $1;
22 | } else {
23 | # if we can't get it, just leave as the video URL is there
24 | return;
25 | }
26 |
27 | debug ("Coded URL: " . $coded_url);
28 |
29 |
30 | $url = uri_unescape($coded_url);
31 | debug("URL: '" . $url . "'");
32 |
33 | # URL ends with filename
34 | $name = $url;
35 | $name =~ s/.*\/([^\/]+)\?.*/$1/;
36 | return $url, title_to_filename($name);
37 | }
38 |
39 | 1;
40 |
--------------------------------------------------------------------------------
/lib/FlashVideo/Site/Theonion.pm:
--------------------------------------------------------------------------------
1 | # Part of get-flash-videos. See get_flash_videos for copyright.
2 | package FlashVideo::Site::Theonion; # horrible casing :(
3 |
4 | use strict;
5 | use FlashVideo::Utils;
6 |
7 | sub find_video {
8 | my ($self, $browser) = @_;
9 |
10 | if ($browser->response->is_redirect) {
11 | $browser->get( $browser->response->header('Location') );
12 |
13 | if (!$browser->success) {
14 | die "Couldn't follow Onion redirect: " .
15 | $browser->response->status_line;
16 | }
17 | }
18 |
19 | my $title;
20 | if ($browser->content =~ /var video_title = "([^"]+)"/) {
21 | $title = $1;
22 | }
23 | else {
24 | $title = extract_info($browser)->{meta_title};
25 | }
26 |
27 | my $filename = title_to_filename($title);
28 |
29 | # They now pass the URL as a param, so the generic code can extract it.
30 | my $url = (FlashVideo::Generic->find_video($browser, $browser->uri))[0];
31 |
32 | return $url, $filename;
33 | }
34 |
35 | 1;
36 |
--------------------------------------------------------------------------------
/lib/FlashVideo/Site/Todaysbigthing.pm:
--------------------------------------------------------------------------------
1 | # Part of get-flash-videos. See get_flash_videos for copyright.
2 | package FlashVideo::Site::Todaysbigthing;
3 |
4 | use strict;
5 | use FlashVideo::Utils;
6 |
7 | my $base = "http://www.todaysbigthing.com/betamax";
8 |
9 | sub find_video {
10 | my ($self, $browser, $embed_url) = @_;
11 |
12 | my $id;
13 | if($browser->content =~ /item_id=(\d+)/) {
14 | $id = $1;
15 | } elsif($embed_url =~ m!) {
16 | $id = $1;
17 | }
18 | die "No ID found\n" unless $id;
19 |
20 | $browser->get("$base:$id");
21 |
22 | my $xml = from_xml($browser);
23 |
24 | my $title = $xml->{title};
25 | $title = extract_title($browser) if ref $title;
26 | my $filename = title_to_filename($title);
27 |
28 | my $url = $xml->{flv};
29 | die "No FLV location" unless $url;
30 |
31 | return $url, $filename;
32 | }
33 |
34 | sub can_handle {
35 | my($self, $browser, $url) = @_;
36 |
37 | return $browser->content =~ $base;
38 | }
39 |
40 | 1;
41 |
--------------------------------------------------------------------------------
/lib/FlashVideo/Site/Vidzur.pm:
--------------------------------------------------------------------------------
1 | # Part of get-flash-videos. See get_flash_videos for copyright.
2 | package FlashVideo::Site::Vidzur;
3 |
4 | use strict;
5 | use FlashVideo::Utils;
6 | use URI::Escape;
7 |
8 | our $VERSION = '0.01';
9 | sub Version() { $VERSION; }
10 |
11 | sub find_video {
12 | my ($self, $browser, $embed_url) = @_;
13 |
14 | my $coded_url = "";
15 | my $url = "";
16 | my $name = "";
17 |
18 |
19 | # read URL from the configuration passed to flash player
20 | if ($browser->content =~ /\s*url: '(http:\/\/[^']+vidzur.com%2Fvideos%2F[^']+)',.*/) {
21 | $coded_url = $1;
22 | } else {
23 | # if we can't get it, just leave as the video URL is there
24 | return;
25 | }
26 |
27 | debug ("Coded URL: " . $coded_url);
28 |
29 |
30 | $url = uri_unescape($coded_url);
31 | debug("URL: '" . $url . "'");
32 |
33 | # URL ends with filename
34 | $name = $url;
35 | $name =~ s/.*\/([^\/]+)\?.*/$1/;
36 | return $url, title_to_filename($name);
37 | }
38 |
39 | 1;
40 |
--------------------------------------------------------------------------------
/lib/FlashVideo/Site/Facebook.pm:
--------------------------------------------------------------------------------
1 | # Part of get-flash-videos. See get_flash_videos for copyright.
2 | package FlashVideo::Site::Facebook;
3 |
4 | use strict;
5 | use FlashVideo::Utils;
6 |
7 | use URI::Escape;
8 |
9 | our $VERSION = '0.01';
10 | sub Version { $VERSION; }
11 |
12 | sub find_video {
13 | my ($self, $browser, $embed_url) = @_;
14 |
15 | # If we should process Facebook's Like button, leave
16 | return if ($embed_url =~ /http:\/\/www\.facebook\.com\/plugins\/like\.php/);
17 |
18 | # Grab the file from the page..
19 | my $params = ($browser->content =~ /\["params","(.+?)"\]/)[0];
20 | $params =~ s/\\u([[:xdigit:]]{1,4})/chr(eval("0x$1"))/egis;
21 | $params = uri_unescape($params);
22 | my $url = ($params =~ /"hd_src":"([^"]*)"/)[0];
23 | if (!$url) { $url = ($params =~ /"sd_src":"([^"]*)"/)[0]; }
24 | $url =~ s/\\\//\//g;
25 | die "Unable to extract url" unless $url;
26 |
27 | my $filename = ($url =~ /([^\/]*)\?/)[0];
28 |
29 | return $url, $filename;
30 | }
31 |
32 | 1;
33 |
--------------------------------------------------------------------------------
/lib/FlashVideo/Site/Movieclips.pm:
--------------------------------------------------------------------------------
1 | # Part of get-flash-videos. See get_flash_videos for copyright.
2 | package FlashVideo::Site::Movieclips;
3 |
4 | use strict;
5 | use FlashVideo::Utils;
6 |
7 | sub find_video {
8 | my ($self, $browser, $embed_url) = @_;
9 |
10 | my $video_id = ($browser->content =~ /get("http://config.movieclips.com/player/config/embed/$video_id/?loc=US");
15 |
16 | my $xml = from_xml($browser->content);
17 |
18 | my $playpath = $xml->{video}->{properties}->{file_path};
19 |
20 | my $title = $xml->{video}->{properties}->{clip_title};
21 |
22 | debug $playpath;
23 | debug title_to_filename($title);
24 |
25 | return {
26 | flv => title_to_filename($title, 'flv'),
27 | swfUrl => "http://static.movieclips.com/embedplayer.swf?shortid=$video_id",
28 | app => "ondemand",
29 | rtmp => "rtmp://media.movieclips.com",
30 | playpath => $playpath
31 | };
32 | }
33 |
34 | 1;
35 |
--------------------------------------------------------------------------------
/lib/FlashVideo/Site/Spike.pm:
--------------------------------------------------------------------------------
1 | # Part of get-flash-videos. See get_flash_videos for copyright.
2 | package FlashVideo::Site::Spike;
3 |
4 | use strict;
5 | use base 'FlashVideo::Site::Mtvnservices';
6 |
7 | use FlashVideo::Utils;
8 | use URI::Escape;
9 |
10 | sub find_video {
11 | my ($self, $browser, $embed_url) = @_;
12 |
13 | my $page_url = $browser->uri->as_string;
14 |
15 | my $config_url;
16 | if($browser->content =~ /config_url\s*=\s*["']([^"']+)/) {
17 | $config_url = $1;
18 | } elsif($browser->content =~ /(?:ifilmId|flvbaseclip)=(\d+)/) {
19 | $config_url = "/ui/xml/mediaplayer/config.groovy?ifilmId=$1";
20 | }
21 | die "No config_url/id found\n" unless $config_url;
22 |
23 | $browser->get(uri_unescape($config_url));
24 | my $xml = from_xml($browser);
25 |
26 | my $feed = uri_unescape($xml->{player}->{feed});
27 | die "Unable to find feed URL\n" unless $feed;
28 |
29 | $browser->get($feed);
30 |
31 | return $self->handle_feed($browser->content, $browser, $page_url);
32 | }
33 |
34 | 1;
35 |
--------------------------------------------------------------------------------
/lib/FlashVideo/Site/Munkvideo.pm:
--------------------------------------------------------------------------------
1 | # Part of get-flash-videos. See get_flash_videos for copyright.
2 | package FlashVideo::Site::Munkvideo;
3 |
4 | use strict;
5 | use FlashVideo::Utils;
6 | use URI::Escape;
7 |
8 | our $VERSION = '0.01';
9 | sub Version() { $VERSION; }
10 |
11 | sub find_video {
12 | my ($self, $browser, $embed_url) = @_;
13 |
14 | my $url = "";
15 |
16 |
17 | # read URL from the configuration passed to flash player
18 | if ($embed_url =~ /(http:\/\/www.munkvideo.cz\/video\/[^?]+)?.*/) {
19 | $url = "$1?munkvideo=original";
20 | } else {
21 | # if we can't get it, just leave as the video URL is there
22 | return;
23 | }
24 |
25 | # $browser->allow_redirects;
26 | # obtained URL will be redirected
27 | $browser->get($url);
28 | $url = $browser->response->header('Location');
29 | if ($url =~ /http:\/\/www\.munkvideo\.cz\/error\.php?type=video_missing/) {
30 | return;
31 | }
32 | debug("URL: '" . $url . "'");
33 |
34 | return $url, title_to_filename($url);
35 | }
36 |
37 | 1;
38 |
--------------------------------------------------------------------------------
/lib/FlashVideo/Site/Truveo.pm:
--------------------------------------------------------------------------------
1 | # Part of get-flash-videos. See get_flash_videos for copyright.
2 | package FlashVideo::Site::Truveo;
3 |
4 | use strict;
5 | use FlashVideo::Utils;
6 |
7 | sub find_video {
8 | my($self, $browser, $embed_url, $prefs) = @_;
9 |
10 | my($videourl) = $browser->content =~ /var videourl = "(.*?)"/;
11 |
12 | # Maybe we were given a direct URL..
13 | $videourl = $embed_url
14 | if !$videourl && $browser->uri->host eq 'xml.truveo.com';
15 |
16 | die "videourl not found" unless $videourl;
17 |
18 | $browser->get($videourl);
19 |
20 | if($browser->content =~ /url=(http:.*?)["']/) {
21 | my $redirect = url_exists($browser, $1);
22 |
23 | $browser->get($redirect);
24 |
25 | my($package, $possible_url) = FlashVideo::URLFinder->find_package($redirect, $browser);
26 |
27 | die "Recursion detected" if $package eq __PACKAGE__;
28 |
29 | return $package->find_video($browser, $possible_url, $prefs);
30 | } else {
31 | die "Redirect URL not found";
32 | }
33 | }
34 |
35 | 1;
36 |
--------------------------------------------------------------------------------
/lib/FlashVideo/Site/Nicovideo.pm:
--------------------------------------------------------------------------------
1 | # Part of get-flash-videos. See get_flash_videos for copyright.
2 | package FlashVideo::Site::Nicovideo;
3 |
4 | use strict;
5 | use FlashVideo::Utils;
6 | use URI::Escape;
7 |
8 | sub find_video {
9 | my ($self, $browser, $embed_url) = @_;
10 | my $id = ($embed_url =~ /([ns]m\d+)/)[0];
11 | die "No ID found\n" unless $id;
12 |
13 | my $base = "http://ext.nicovideo.jp/thumb_watch/$id";
14 |
15 | if($embed_url !~ /ext\.nicovideo\.jp\/thumb_watch/) {
16 | $embed_url = "$base?w=472&h=374&n=1";
17 | }
18 |
19 | $browser->get($embed_url);
20 | my $playkey = ($browser->content =~ /'thumbPlayKey': '([^']+)/)[0];
21 | die "No playkey found\n" unless $playkey;
22 |
23 | my $title = ($browser->content =~ /title: '([^']+)'/)[0];
24 | $title =~ s/\\u([a-f0-9]{1,5})/chr hex $1/eg;
25 |
26 | $browser->get($base . "/$playkey");
27 | my $url = uri_unescape(($browser->content =~ /url=([^&]+)/)[0]);
28 |
29 | return $url, title_to_filename($title, $id =~ /^nm/ ? "swf" : "flv");
30 | }
31 |
32 | 1;
33 |
--------------------------------------------------------------------------------
/lib/FlashVideo/Site/Abclocal.pm:
--------------------------------------------------------------------------------
1 | # Part of get-flash-videos. See get_flash_videos for copyright.
2 | package FlashVideo::Site::Abclocal;
3 |
4 | use strict;
5 | use FlashVideo::Utils;
6 | use Data::Dumper;
7 | use File::Basename;
8 |
9 | sub find_video {
10 | my ($self, $browser, $embed_url, $prefs) = @_;
11 |
12 | my($station,$id) = $browser->content =~ m{http://cdn.abclocal.go.com/[^"']*station=([^&;"']+)[^"']*mediaId=([^&;"']+)}s;
13 |
14 | die "No media id and station found" unless $id;
15 |
16 | $browser->get("http://cdn.abclocal.go.com/$station/playlistSyndicated?id=$id");
17 |
18 | my @tmp = $browser->content =~ m{ |