[vlc-commits] youtube.lua: basic support for scrambled signatures

Pierre Ynard git at videolan.org
Sat Jul 27 21:53:43 CEST 2013


vlc | branch: master | Pierre Ynard <linkfanel at yahoo.fr> | Sat Jul 27 21:52:00 2013 +0200| [5a414bf00b71687b9610b9311fdd2bb0102068e9] | committer: Pierre Ynard

youtube.lua: basic support for scrambled signatures

Apparently this is the new fad and comes in several length-flavors

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=5a414bf00b71687b9610b9311fdd2bb0102068e9
---

 share/lua/playlist/youtube.lua |   29 ++++++++++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)

diff --git a/share/lua/playlist/youtube.lua b/share/lua/playlist/youtube.lua
index e1ccb88..60cce81 100644
--- a/share/lua/playlist/youtube.lua
+++ b/share/lua/playlist/youtube.lua
@@ -1,7 +1,7 @@
 --[[
  $Id$
 
- Copyright © 2007-2012 the VideoLAN team
+ Copyright © 2007-2013 the VideoLAN team
 
  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
@@ -67,6 +67,26 @@ function get_fmt( fmt_list )
     return fmt
 end
 
+function descramble81( sig )
+    sig = string.reverse( sig )
+    local s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12,s13 =
+        string.match( sig, "(.)(.......................)(.)(..............)(.)(......)(.)(....)(.)(...................)(.)(........)(.)" )
+    return s3..s2..s5..s4..s1..s6..s13..s8..s7..s10..s9..s12..s11
+end
+
+local descramblers = { [81] = descramble81 }
+
+function descramble( sig )
+    vlc.msg.dbg( "Found "..string.len( sig ).."-character scrambled signature for youtube video URL, attempting to descramble... " )
+    local descrambler = descramblers[string.len( sig )]
+    if descrambler then
+        sig = descrambler( sig )
+    else
+        vlc.msg.err( "Couldn't process youtube video URL, please check for updates to this script" )
+    end
+    return sig
+end
+
 -- Parse and pick our video URL
 function pick_url( url_map, fmt )
     local path = nil
@@ -80,6 +100,13 @@ function pick_url( url_map, fmt )
                 url = vlc.strings.decode_uri( url )
 
                 local sig = string.match( stream, "sig=([^&,]+)" )
+                if not sig then
+                    -- Scrambled signature
+                    sig = string.match( stream, "s=([^&,]+)" )
+                    if sig then
+                        sig = descramble( sig )
+                    end
+                end
                 local signature = ""
                 if sig then
                     signature = "&signature="..sig



More information about the vlc-commits mailing list