Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Music videos not playing again - possible fix #95

Open
gitman0 opened this issue Jan 20, 2015 · 10 comments
Open

Music videos not playing again - possible fix #95

gitman0 opened this issue Jan 20, 2015 · 10 comments

Comments

@gitman0
Copy link

gitman0 commented Jan 20, 2015

I found that music videos were not playing again, and again I am seeing signature extraction algorithm failing to compile in the debug log. I found that the '$' character was not being properly replaced with '_S_' in the main function name when piecing algorithm together. It does this in the _getFullAlgoCode function, but not where it concats everything together. I made the following edit and it appears to have resolved my issues. Can anyone else confirm?

--- YouTubePlayer.py    2015-01-19 21:41:53.880901235 -0500
+++ YouTubePlayer.py    2015-01-20 12:12:07.872778896 -0500
@@ -484,7 +484,7 @@
                 algoLines[i] = '\t' + algoLines[i]
             fullAlgoCode  = 'def extractedSignatureAlgo(param):'
             fullAlgoCode += '\n'.join(algoLines)
-            fullAlgoCode += '\n\treturn %s(param)' % mainFunName
+            fullAlgoCode += '\n\treturn %s(param)' % mainFunName.replace('$','_S_')
             fullAlgoCode += '\noutSignature = extractedSignatureAlgo( inSignature )\n'

             # after this function we should have all needed code in fullAlgoCode

This is the error I was seeing in the debug log. I added some extra statements to get the specific error message:

21:44:03 T:1920  NOTICE: [YouTube-4.4.10] decrypt_signature : '---------------------------------------'
21:44:03 T:1920  NOTICE: [YouTube-4.4.10] decrypt_signature : '|    ALGO FOR SIGNATURE DECRYPTION    |'
21:44:03 T:1920  NOTICE: [YouTube-4.4.10] decrypt_signature : '---------------------------------------'
21:44:03 T:1920  NOTICE: [YouTube-4.4.10] decrypt_signature : 'def extractedSignatureAlgo(param):       
                                                def _S_s(a):
                                                        a=list(a)
                                                        Zs__ur(a,28)
                                                        Zs__KU(a,29)
                                                        Zs__wt(a,1)
                                                        Zs__ur(a,23)
                                                        Zs__wt(a,1)
                                                        Zs__ur(a,31)
                                                        Zs__KU(a,4)
                                                        Zs__KU(a,28)
                                                        return "".join(a)

                                                return $s(param)
                                            outSignature = extractedSignatureAlgo( inSignature )
                                            '
21:44:03 T:1920  NOTICE: [YouTube-4.4.10] decrypt_signature : '---------------------------------------'
21:44:03 T:1920  NOTICE: [YouTube-4.4.10] decrypt_signature : 'Error: <type 'exceptions.SyntaxError'> - invalid syntax (, line 14)'
21:44:03 T:1920  NOTICE: [YouTube-4.4.10] decrypt_signature : 'decryptSignature compile algo code EXCEPTION'

I'm not sure what causes some videos to have a signature extraction function names with a dollar sign in them, it seems random. But I'm not sure why others aren't reporting the same thing more frequently.

@mark79
Copy link

mark79 commented Jan 24, 2015

gitman0: your fix worked for me. Good catch!

@mrjwm2
Copy link

mrjwm2 commented Jan 28, 2015

gitman0,
I have tried the edit and Vevo still does not play. I am using v4.4.1
Any thoughts? How could I produce the log as you have shown above? I don't see this info in my debug log.

Thanks

@mrjwm2
Copy link

mrjwm2 commented Jan 28, 2015

Update: I performed a reinstall of Helix and all is good. (must not have deleted all v5 files) I also found the method to debugging within the youtube addon.
Thanks for the fix. I use the download feature in v4.4.1 often. Thanks for keeping this version alive!

@gitman0
Copy link
Author

gitman0 commented Jan 28, 2015

good to hear, mark79 and mrjwm2!

@gitman0
Copy link
Author

gitman0 commented Jan 31, 2015

Here's a new set of edits, friends. More dollar sign issues are being accounted for here, specifically the dollar sign being used in the local object/var names:

--- YouTubePlayer.py    2015-01-30 15:25:01.000000000 -0500
+++ YouTubePlayer.py    2015-01-30 20:09:55.824869635 -0500
@@ -529,7 +530,7 @@

     def _extractLocalVarNames(self, mainFunBody ):
         valid_funcs = ( 'reverse', 'split', 'splice', 'slice', 'join' )
-        match = re.compile( r'[; =(,](\w+)\.(\w+)\(' ).findall( mainFunBody )
+        match = re.compile( r'[; =(,]([\$\w]+)\.(\w+)\(' ).findall( mainFunBody )
         local_vars = []
         for name in match:
             if name[1] not in valid_funcs:
@@ -538,7 +539,7 @@
         return set( local_vars )

     def _getLocalVarObjBody(self, varName, playerData):
-        match = re.search( r'var %s={.*?}};' % varName, playerData )
+        match = re.search( r'var %s={.*?}};' % varName.replace('$','\\$'), playerData )
         if match:
             self.common.log('Found variable object: ' + match.group(0))
             return match.group(0)
@@ -566,10 +567,12 @@
             varNames = self._extractLocalVarNames(funBody)
             if len(varNames):
                 for varName in varNames:
+                    varName_=varName.replace('$','_S_')
                     self.common.log("Found local var object: " + str(varName))
                     self.common.log("Known vars: " + str(allLocalVarNamesTab))
                     if varName not in allLocalVarNamesTab:
                         self.common.log("Adding local var object %s to known objects" % varName)
+                        funBody=funBody.replace(varName,varName_)
                         allLocalVarNamesTab.append(varName)
                         funBody = self._getLocalVarObjBody( varName, playerData ) + "\n" + funBody

@gitman0 gitman0 closed this as completed Jan 31, 2015
@gitman0 gitman0 reopened this Jan 31, 2015
@mrjwm2
Copy link

mrjwm2 commented Feb 3, 2015

Thanks gitman0, I will test and let you know.

@mrjwm2
Copy link

mrjwm2 commented Feb 4, 2015

working just fine with the changes

@gitman0
Copy link
Author

gitman0 commented Feb 4, 2015

great. any chance you had a video that wasn't working that is now working after these latest changes? thanks,

@mrjwm2
Copy link

mrjwm2 commented Feb 4, 2015

No not this edit. But the previous edit fixed Vevo. I made a log before and after this change, I am trying to see if I can figure out what does what. :) Would I be right that your new edit makes the function always replace $ with S whenever identified?

Date: Wed, 4 Feb 2015 13:32:52 -0800
From: [email protected]
To: [email protected]
CC: [email protected]
Subject: Re: [youtube-xbmc-plugin] Music videos not playing again - possible fix (#95)

great. any chance you had a video that wasn't working that is now working after these latest changes? thanks,


Reply to this email directly or view it on GitHub.

@gitman0
Copy link
Author

gitman0 commented Feb 5, 2015

the first edit was for the main function name, but the last set of edits was specifically for the function calls within the main function. it seemed totally random whether Youtube handed out the code with dollar signs in them or not. like you, i was able to fix music videos after the first edit, but last week i experienced two nonconsecutive days in which it did not work, and the reason was the dollar sign character again but this time within the function.

this is what i saw in the debug log prior to the last edits:

14:16:08 T:4800  NOTICE: [YouTube-4.4.10] decrypt_signature : 'Main signature function name = "at"'
14:16:08 T:4800  NOTICE: [YouTube-4.4.10] _extractLocalVarNames : 'Found variable names: []'
14:16:08 T:4800  NOTICE: [YouTube-4.4.10] _jsToPy : 'function at(a){a=a.split("");$s.kB(a,2);$s.tN(a,44);$s.hw(a,28);$s.kB(a,3);$s.tN(a,17);$s.kB(a,1);return a.join("")
}'
14:16:08 T:4800  NOTICE: [YouTube-4.4.10] decrypt_signature : '---------------------------------------'
14:16:08 T:4800  NOTICE: [YouTube-4.4.10] decrypt_signature : '|    ALGO FOR SIGNATURE DECRYPTION    |'
14:16:08 T:4800  NOTICE: [YouTube-4.4.10] decrypt_signature : '---------------------------------------'
14:16:08 T:4800  NOTICE: [YouTube-4.4.10] decrypt_signature : 'def extractedSignatureAlgo(param):       
                                                def at(a):
                                                        a=list(a)
                                                        $s__kB(a,2)
                                                        $s__tN(a,44)
                                                        $s__hw(a,28)
                                                        $s__kB(a,3)
                                                        $s__tN(a,17)
                                                        $s__kB(a,1)
                                                        return "".join(a)

                                                return at(param)
                                            outSignature = extractedSignatureAlgo( inSignature )
                                            '
14:16:08 T:4800  NOTICE: [YouTube-4.4.10] decrypt_signature : '---------------------------------------'
14:16:08 T:4800  NOTICE: [YouTube-4.4.10] decrypt_signature : 'decryptSignature compile algo code EXCEPTION'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants