Broken function in Youtube. (1 Viewer)

Juppe

Portal Pro
November 17, 2006
308
42
Home Country
Sweden Sweden
Hi all.

I have a problem playing some videos in Youtube.
For example search for "amaranthe nexus" and select the first video that comes up. It should have a watermark "Vevo".
Try to play that one. There are more files from that search that I cant play.

All I get when I try is an error that says something like "Error start playing. Connection is lost, cannot reopen.

I think I've found why this happens, the url that onlineVideos try to play is invalid because that the url has not been "decrypted".

I've tried to fix this, but my knowledge of javascript is not that good.
I think that the function that is broken is "string DecryptSignature(string javascriptUrl, string s)" in Youtube.cs.
What I can see in that function, there are at least two errors.
The first is that the Regexp that tries to make the string fixedJs shorter so that it ends after the function that onlinevideos shall call, returns nothing.
The second is that the call to the javascript in function engine.CallGlobalFunction returns with the error that the function onlinevideos tries to call is not a function.
I think that the second error is because that the javascript has change, before this change I think that every function did have a name and looked something like "function gr(a) {somecode}"
but now it lookes like this "gr=function(a){somecode)" and all functions seems to be anonymous and are part of a bigger function that contains "all" the function in that javascript.

Is there anyone that know javascript and and have the time to look into this?
 

Juppe

Portal Pro
November 17, 2006
308
42
Home Country
Sweden Sweden
I've tested a little on this error and I think that I've a solution for it soon.
Tested with hardcoded example and that works in the standalone application, but when I take that DLL and put it in the plugin folder for MP1 it doesn't work.
Well sort of working. If I've a video in my favorites that didn't work before it works now, but the Youtube part of onlinevideos is not working at all.

Is there anyone that have any suggestion what the error can be?
What is the difference between the standalone app and mediaportal1 when it comes to this DLL?

When I'm ready with this fix, can a put it here, so someone can get it into the repo?
I'm not sure that I can fix it my self to get it into to the repo, so should appreciate if someone could help me with that?
 

offbyone

Development Group
  • Team MediaPortal
  • April 26, 2008
    3,989
    3,712
    Stuttgart
    Home Country
    Germany Germany
    Hi,
    it's my dll or project your are building there :) - it has some special build tasks to merge some dll into it - it looks like those did not run on your dev machine.
    If you have the fixed regex to extract the neccessary javascript from that large js file from youtube, I'll happyily push it to github.
     

    Juppe

    Portal Pro
    November 17, 2006
    308
    42
    Home Country
    Sweden Sweden
    I'll soon be there, but I did not do it my self. I "stole" it from the plugin used in Kodi. Hope that is OK?
    I translated there Python-code to C#.
     

    Juppe

    Portal Pro
    November 17, 2006
    308
    42
    Home Country
    Sweden Sweden
    I've a fix for the problem above.
    offbyone can you test the files and then push them to the repo?
    Can you tell me when the new dll is available to donwload to onlinevideos via the auto update in MP1?.

    There are 3 new files and in youtube.cs I've only changed the function DecryptSignature.

    This is a first fix, I'm trying to do a more general fix that uses the original functions from the java script instead of my own functions in C#.
    But that will take a little time.
     

    Attachments

    • Youtube.zip
      6.3 KB

    offbyone

    Development Group
  • Team MediaPortal
  • April 26, 2008
    3,989
    3,712
    Stuttgart
    Home Country
    Germany Germany
    Hi,
    thanks for taking care of it!
    I committed it pushed to git and updated the new DLL.

    The previous version used the Jurassic Javascript Engine to execute the JS. You can try to use that again if you feel brave ;)
     

    Juppe

    Portal Pro
    November 17, 2006
    308
    42
    Home Country
    Sweden Sweden
    Here are my new version.

    I'm using Jurassic now, but I still have to parse the javascript file.

    I've read i little about Jurassic and can't find a way to make it work with the original javascript file.
    One problem is that the start function is anonymous, and Jurassic can't call an anonymous function what I can see.
    If anyone know a way to call a anonymous function directly from Jurassic, please let me know.
    Another thing is that the functions that the first function use are inside of an javascript object and I don't know how Jurassic cope with that.

    So for now the original javascript is parsed and then a new javascript is created with the result from the parsing.
    One advantage with this is that the signature now is decrypted with javascript functions and not with the one in C#.

    In the file Youtube.cs I've only made changes to the method DecryptWithCustomParser.
    The other files are almost completly rewriten
     

    Attachments

    • Youtube.zip
      6.9 KB

    Users who are viewing this thread

    Top Bottom