Youtube: Add new page format (yt.playerConfig)
authorRalf Ertzinger <ralf@skytale.net>
Tue, 14 Feb 2012 23:11:24 +0000 (00:11 +0100)
committerRalf Ertzinger <ralf@skytale.net>
Tue, 14 Feb 2012 23:11:24 +0000 (00:11 +0100)
videosite/YouTubeGrabber.pm

index ca8f49b..f164af2 100644 (file)
@@ -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;