Author: glen
Date: Sun Aug 21 20:26:19 2011
New Revision: 12332

Modified:
   toys/rsget.pl/Video/YouTube
Log:
- update for youtube site changes

Modified: toys/rsget.pl/Video/YouTube
==============================================================================
--- toys/rsget.pl/Video/YouTube (original)
+++ toys/rsget.pl/Video/YouTube Sun Aug 21 20:26:19 2011
@@ -2,6 +2,7 @@
 # Video::YouTube - Video getter plugin for rsget.pl
 #
 # 2009-2011 (c) Przemysław Iskra <[email protected]>
+# 2011 (c) Elan Ruusamäe <[email protected]>
 #              This program is free software,
 # you may distribute it under GPL v2 or newer.
 
@@ -10,7 +11,7 @@
 web: "http://www.youtube.com/";
 uri: qr{youtube\.com/watch\?v=.*}
 slots: max
-status: OK 2011-03-25
+status: OK 2011-08-21
 
 unify:
        s/#.*//;
@@ -28,7 +29,7 @@
 
        sub best_format
        {
-               /"fmt_map"\s*:\s*"(.*?)"/ or m{&fmt_map=(\S+?)&}
+               /"fmt_list"\s*:\s*"(.*?)"/ or m{&fmt_map=(\S+?)&}
                        or return undef;
                my %fmts = map { m{(\d+)\\?/}; $1 => $_ } split ",", 
uri_unescape( $1 );
 
@@ -40,6 +41,33 @@
                return undef;
        }
 
+       # decodes urls for formats
+       # tries to put url together as seen in net console in browser
+       sub get_uris
+       {
+               my ($map) = @_;
+               my @uri = map { { map { split /=/, $_, 2 } split /&/, 
uri_unescape($_) } } split /,/, $map;
+               my %uri = ();
+               foreach my $p (@uri) {
+                       # will not be added again to url
+                       my $url = $p->{url};
+                       undef $p->{url};
+
+                       # we need just first part
+                       my @id = split /\\u0026/, $p->{id};
+                       $p->{id} = $id[0];
+
+                       # rest of the keys go to url
+                       while (my($k, $v) = each %$p) {
+                               $url .= '&' . $k . '=' . $v if $v;
+                       }
+
+                       # itag is format id
+                       $uri{$p->{itag}} = $url;
+               }
+               return %uri;
+       }
+
 start:
        GET( $-{_uri} );
 
@@ -73,17 +101,14 @@
        my $t = $1;
 
        my $fmt = $-{fmt};
-       my $fmtstr = $fmt ? "&fmt=$fmt->[0]" : "";
        $fmt ||= [ 5, "flv", "vLQ" ];
 
        $-{fname} = $name . "." . $fmt->[1];
 
-       /"fmt_url_map": "(.*?)"/;
-       my %uri = map /(\d+)\|(.*)/, split /,/, $1;
+       /"url_encoded_fmt_stream_map": "(.*?)"/;
+       my %uri = get_uris($1);
        my $uri = $uri{ $fmt->[0] };
-       $uri =~ s#\\u0026#&#g;
-       $uri =~ s#\\/#/#g;
-       $-{file_uri} = uri_unescape( $uri );
+       $-{file_uri} = $uri;
 
        GET( $-{file_uri}, headonly => 1 );
 
_______________________________________________
pld-cvs-commit mailing list
[email protected]
http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit

Reply via email to