App-get_flash_videos
view release on metacpan or search on metacpan
lib/FlashVideo/Site/Tudou.pm view on Meta::CPAN
# Video ID is in the URL if we are either at the redirected URL
# or at the embedded link that sends the redirect
( $videoID ) = ( $embed_url =~ m`tudou.com/player/outside/player_outside.swf\?iid=(\d+)` );
}
die "Couldn't extract video ID, we are out probably out of date" unless $videoID;
debug "Using video ID $videoID";
# Get video info; safe keys seen: YouNeverKnowThat, IAlsoNeverKnow
# but they're not even verifying either safekey or noCatch
# (maybe noCatch means no cache?)
$browser->get(
sprintf "http://v2.tudou.com/v2/kili?safekey=%s&id=%s&noCatch=%d",
'YouNeverKnowThat', $videoID, rand( 10000 ) );
# Fallback URL in case the first one doesn't have our video information
if ( not $browser->success )
{
debug 'Using fallback tudou link for video info';
$browser->get(
lib/FlashVideo/Site/Youtube.pm view on Meta::CPAN
if ($browser->response->header('Location') =~ m!/swf/.*video_id=([^&]+)!
|| $embed_url =~ m!/v/([-_a-z0-9]+)!i
|| $browser->uri =~ m!v%3D([-_a-z0-9]+)!i) {
# We ended up on a embedded SWF or other redirect page
$embed_url = "http://www.youtube.com/watch?v=$1";
$browser->get($embed_url);
}
}
if (!$browser->success) {
verify_age($browser, $prefs);
}
my $title = extract_info($browser)->{meta_title};
if (!$title and
$browser->content =~ /<div id="vidTitle">\s+<span ?>(.+?)<\/span>/ or
$browser->content =~ /<div id="watch-vid-title">\s*<div ?>(.+?)<\/div>/) {
$title = $1;
}
# If the page contains fmt_url_map, then process this. With this, we
lib/FlashVideo/Site/Youtube.pm view on Meta::CPAN
my $alert = $1;
$alert =~ s/(^\s+|\s+$)//g;
$message .= "\nYouTube: $alert";
error $message;
exit 1;
} else {
die "$message\n";
}
}
sub verify_age {
my($browser, $prefs) = @_;
my $orig_uri = $browser->uri;
if ($browser->response->code == 303
&& $browser->response->header('Location') =~ m!/verify_age|/accounts/!) {
my $confirmation_url = $browser->response->header('Location');
$browser->get($confirmation_url);
if($browser->content =~ /has_verified=1/) {
my($verify_url) = $browser->content =~ /href="(.*?has_verified=1)"/;
$verify_url = decode_entities($verify_url);
$browser->get($verify_url);
# Great that worked, otherwise probably does want a login
return if $browser->response->code == 200;
}
# Lame age verification page - yes, we are grown up, please just give
# us the video!
my $account = $prefs->account("youtube", <<EOT);
Unfortunately, due to Youtube being lame, you have to have
an account to download this video. (See the documentation for how to configure
~/.netrc)
lib/FlashVideo/Utils.pm view on Meta::CPAN
}
# Ensure the end time for the last subtitle is correct.
$subtitles[$count - 1]->{end} = $last_proper_sub_end_time;
# Write subtitles
open my $subtitle_fh, '>', $filename
or die "Can't open subtitles file $filename: $!";
# Set filehandle to UTF-8 to avoid "wide character in print" warnings.
# Note this does *not* double-encode data as UTF-8 (verify with hexdump).
# As per the documentation for binmode: ":utf8 just marks the data as
# UTF-8 without further checking". This will cause mojibake if
# ISO-8859-1/Latin1 and UTF-8 and are mixed in the same file though.
binmode $subtitle_fh, ':utf8';
$count = 1;
foreach my $subtitle (@subtitles) {
print $subtitle_fh "$count\n$subtitle->{start} --> $subtitle->{end}\n" .
"$subtitle->{text}\n\n";
( run in 1.397 second using v1.01-cache-2.11-cpan-39bf76dae61 )