fix following youtube changes; patch pointed out by nigel@

This commit is contained in:
sthen 2011-08-16 08:23:09 +00:00
parent 2dd585500f
commit 93c98b9abd
2 changed files with 67 additions and 1 deletions

View File

@ -1,9 +1,10 @@
# $OpenBSD: Makefile,v 1.7 2011/07/12 13:02:28 sthen Exp $
# $OpenBSD: Makefile,v 1.8 2011/08/16 08:23:09 sthen Exp $
COMMENT= download flash video files from various sites
DISTNAME= App-get_flash_videos-1.24.20110712
PKGNAME= ${DISTNAME:S/App-//}
REVISION= 0
CATEGORIES= multimedia
HOMEPAGE= http://get-flash-videos.googlecode.com/

View File

@ -0,0 +1,65 @@
$OpenBSD: patch-lib_FlashVideo_Site_Youtube_pm,v 1.1 2011/08/16 08:23:09 sthen Exp $
--- lib/FlashVideo/Site/Youtube.pm.orig Fri Aug 5 18:00:19 2011
+++ lib/FlashVideo/Site/Youtube.pm Fri Aug 5 18:00:42 2011
@@ -133,11 +133,61 @@ sub find_video {
} elsif($info{fmt_url_map}) {
debug "Using fmt_url_map method from info";
return $self->download_fmt_map($prefs, $browser, $title, \%info, $info{fmt_url_map});
+ } elsif($info{url_encoded_fmt_stream_map}) {
+ debug "Using url_encoded_fmt_stream_map method from info";
+ return $self->download_url_encoded_fmt_stream_map($prefs, $browser, $title, \%info, $info{url_encoded_fmt_stream_map});
}
}
# Try old get_video method, just incase.
return download_get_video($browser, $prefs, $video_id, $title, $t);
+}
+
+sub download_url_encoded_fmt_stream_map {
+ my($self, $prefs, $browser, $title, $info, $fmt_map) = @_;
+
+ my $fmt_url_map = parse_youtube_url_encoded_fmt_stream_map($fmt_map);
+
+ if (!$title and $browser->uri->as_string =~ m'/user/.*?#') {
+ my $video_id = (split /\//, $browser->uri->fragment)[-1];
+
+ my %info = get_youtube_video_info($browser->clone, $video_id);
+
+ $title = $info->{title};
+ }
+
+ my $preferred_quality = $prefs->quality->choose(map { $fmt_url_map->{$_->{id}}
+ ? { resolution => $_->{resolution}, url => $fmt_url_map->{$_->{id}} }
+ : () } @formats);
+
+ $browser->allow_redirects;
+
+ return $preferred_quality->{url}, title_to_filename($title, "mp4");
+}
+
+sub parse_youtube_url_encoded_fmt_stream_map {
+ my($raw_map) = @_;;
+
+ my $map = {};
+
+ foreach my $params (split /,/, $raw_map) {
+
+ my $format = "";
+ my $url = "";
+
+ foreach my $pair (split /&/, $params) {
+ my ($name, $value) = split /=/, $pair;
+ if ($name eq "itag"){
+ $format = $value;
+ } elsif ($name eq "url") {
+ $url = uri_unescape($value);
+ }
+ }
+
+ $map->{$format} = $url;
+ }
+
+ return $map;
}
sub download_fmt_map {