X-Git-Url: https://git.camperquake.de/gitweb.cgi?a=blobdiff_plain;f=videosite%2FYouTubeGrabber.pm;h=f164af2bffabd00f809c5c17ab0023d013f437c9;hb=376da74c2839797a731f34894ea7ca35f8b2612b;hp=ca8f49bca57aefbf296e6e822b33b2fae1a4307c;hpb=3915e4c87ada6de3cba8288d9a3d08d4221d0dc2;p=videosite.git diff --git a/videosite/YouTubeGrabber.pm b/videosite/YouTubeGrabber.pm index ca8f49b..f164af2 100644 --- a/videosite/YouTubeGrabber.pm +++ b/videosite/YouTubeGrabber.pm @@ -338,8 +338,35 @@ sub _parse_by_scrape { $self->error('fmt_url_map not found in PLAYER_CONFIG'); return undef; } + } elsif ($e =~ m|yt\.playerConfig\s*=\s*(.+);\n|) { + my $args = $1; + $self->debug("Found yt.playerConfig: %s", $args); + + $jsp = videosite::JSArrayParser->new(); + $self->debug("Using %s to parse", ref($jsp)); + $r = $jsp->parse($args); + + unless(defined($r)) { + $self->error("Found information hash, but could not parse"); + return undef; + } + + if (exists($r->{'args'}) and exists($r->{'args'}->{'ps'}) and ($r->{'args'}->{'ps'} eq 'live')) { + $self->error("Video URL seems to point to a live stream, cannot save this"); + return undef; + } + + if (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: 2012 (yt.playerConfig), url_encoded_fmt_stream_map"); + } else { + $self->error('url_map not found in yt.playerConfig'); + return undef; + } } + if (%urls) { $self->__pick_url(\%urls, $preflist, $metadata); last SWF_ARGS;