Broken function in Youtube.

Discussion in 'OnlineVideos' started by Juppe, January 11, 2016.

  1. Juppe

    Juppe Portal Pro

    Joined:
    November 17, 2006
    Messages:
    292
    Likes Received:
    15
    Ratings:
    +20 / 0
    Home Country:
    Sweden Sweden
    Show System Specs
    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?
     
  2. Google AdSense Guest Advertisement



    to hide all adverts.
  3. Juppe

    Juppe Portal Pro

    Joined:
    November 17, 2006
    Messages:
    292
    Likes Received:
    15
    Ratings:
    +20 / 0
    Home Country:
    Sweden Sweden
    Show System Specs
    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?
     
  4. offbyone
    • Team MediaPortal

    offbyone Development Group

    Joined:
    April 26, 2008
    Messages:
    3,981
    Likes Received:
    2,704
    Gender:
    Male
    Location:
    Stuttgart
    Ratings:
    +3,303 / 3
    Home Country:
    Germany Germany
    Show System Specs
    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.
     
  5. Juppe

    Juppe Portal Pro

    Joined:
    November 17, 2006
    Messages:
    292
    Likes Received:
    15
    Ratings:
    +20 / 0
    Home Country:
    Sweden Sweden
    Show System Specs
    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#.
     
  6. Ministerk
    • Super User

    Ministerk Super User

    Joined:
    November 28, 2007
    Messages:
    970
    Likes Received:
    401
    Occupation:
    Systems developer
    Location:
    Uppsala
    Ratings:
    +831 / 3
    Home Country:
    Sweden Sweden
    Show System Specs
    That has never happened before...:rolleyes:;)(y)
     
  7. Juppe

    Juppe Portal Pro

    Joined:
    November 17, 2006
    Messages:
    292
    Likes Received:
    15
    Ratings:
    +20 / 0
    Home Country:
    Sweden Sweden
    Show System Specs
    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.
     

    Attached Files:

    • Youtube.zip
      File size:
      6.3 KB
      Uploaded:
      January 15, 2016
      Views:
      63
    • Thank You! Thank You! x 2
    • Like Like x 1
  8. offbyone
    • Team MediaPortal

    offbyone Development Group

    Joined:
    April 26, 2008
    Messages:
    3,981
    Likes Received:
    2,704
    Gender:
    Male
    Location:
    Stuttgart
    Ratings:
    +3,303 / 3
    Home Country:
    Germany Germany
    Show System Specs
    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 ;)
     
    • Thank You! Thank You! x 1
  9. Juppe

    Juppe Portal Pro

    Joined:
    November 17, 2006
    Messages:
    292
    Likes Received:
    15
    Ratings:
    +20 / 0
    Home Country:
    Sweden Sweden
    Show System Specs
    The new version that I'm working on will use Jurassic.
    Think that version will be done this weekend.
     
    • Like Like x 1
  10. Juppe

    Juppe Portal Pro

    Joined:
    November 17, 2006
    Messages:
    292
    Likes Received:
    15
    Ratings:
    +20 / 0
    Home Country:
    Sweden Sweden
    Show System Specs
    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
     

    Attached Files:

    • Youtube.zip
      File size:
      6.9 KB
      Uploaded:
      January 17, 2016
      Views:
      61
    • Thank You! Thank You! x 1
  11. Juppe

    Juppe Portal Pro

    Joined:
    November 17, 2006
    Messages:
    292
    Likes Received:
    15
    Ratings:
    +20 / 0
    Home Country:
    Sweden Sweden
    Show System Specs
    Hers comes a new update.
    It gives you access to more videos.
     

    Attached Files:

    • Youtube.zip
      File size:
      5.6 KB
      Uploaded:
      January 23, 2016
      Views:
      74
    • Thank You! Thank You! x 2
    • Like Like x 1

Users Viewing Thread (Users: 0, Guests: 0)

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice
  • About The Project

    The vision of the MediaPortal project is to create a free open source media centre application, which supports all advanced media centre functions, and is accessible to all Windows users.

    In reaching this goal we are working every day to make sure our software is one of the best.

             

  • Support MediaPortal!

    The team works very hard to make sure the community is running the best HTPC-software. We give away MediaPortal for free but hosting and software is not for us.

    Care to support our work with a few bucks? We'd really appreciate it!