From 84bcf124e34f7e12c49f03c9841d863da9da0c8e Mon Sep 17 00:00:00 2001 From: Ralf Ertzinger Date: Mon, 8 Aug 2011 22:16:23 +0200 Subject: [PATCH] YouTube: Correctly parse url_encoded_fmt_stream_map from the web scape, too --- videosite/YouTubeGrabber.pm | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/videosite/YouTubeGrabber.pm b/videosite/YouTubeGrabber.pm index 56bf65c..fd3e0c0 100644 --- a/videosite/YouTubeGrabber.pm +++ b/videosite/YouTubeGrabber.pm @@ -290,7 +290,7 @@ sub _parse_by_scrape { $urls = $self->decode_hexurl($urls); %urls = split(/[\|,]/, $urls); $self->debug("Pagetype: 2010 (swfHTML), fmt_url_map"); - } elsif ($e =~ m|\x27PLAYER_CONFIG\x27:\s+(.+)\}\);|) { + } elsif ($e =~ m|\x27PLAYER_CONFIG\x27:\s+(.+)(?:\}\);)?|) { my $args = $1; $self->debug("Found PLAYER_CONFIG: %s", $args); @@ -318,6 +318,10 @@ sub _parse_by_scrape { $urls{$_} = $self->decode_hexurl($urls{$_}); } $self->debug("Pagetype: 2011 (PLAYER_CONFIG), fmt_url_map"); + } elsif (exists($r->{'args'}) and exists($r->{'args'}->{'url_encoded_fmt_stream_map'}) and ($r->{'args'}->{'url_encoded_fmt_stream_map'} ne '')) { + %urls = %{$self->_decode_url_encoded_fmt_stream_map($r->{'args'}->{'url_encoded_fmt_stream_map'}, 0)}; + + $self->debug("Pagetype: 2011 (PLAYER_CONFIG), url_encoded_fmt_stream_map"); } else { $self->error('fmt_url_map not found in PLAYER_CONFIG'); return undef; @@ -459,9 +463,11 @@ sub __login { # matching video IDs to download URLs sub _decode_url_encoded_fmt_stream_map { my $self = shift; - my $data = $self->decode_hexurl(shift); + my $data = shift; + my $dataencoded = shift; my @data; + $data = $self->decode_hexurl($data) if (defined($dataencoded) && $dataencoded); # This will # - Split the decoded string into segments (along ,) # - Interpret each segment as a concatenated key-value list (key and value separated by =, pairs separated by & -- 1.8.3.1