Search code examples
javascripturlyoutubeuser-experience

youtube/hooktube url to redirect.googlevideo url


hooktube main page states:

Share YouTube videos without giving them views. Bypass country blocks and age restrictions. Download YouTube videos and music. Keep your data private from the G.

HOW: Just replace the domain in any YT link with hooktube.com and you get a light-weight page that loads YouTube's media files (mp4, webm, etc) directly into your browser's native media player. https://youtube.com/watch?v=S6bOkFLrsAc becomes https://hooktube.com/watch?v=S6bOkFLrsAc, etc. Supported parameters: start, end, loop (1 for on), speed (range: 0.01 to 4), autoplay (0 for off, default is 1).

<html>
    <body>
        <video id="player-obj" controls="" src="https://hooktube.com/watch?v=S6bOkFLrsAc"><source></video>
    </body>
</html>

creates a blank video...

but if inspect the hooktube.com page and take the src they use I get the video!

and then change my code to

<html>
    <body>
        <video id="player-obj" controls="" src="https://redirector.googlevideo.com/videoplayback?expire=1521934253&ei=TIu2WrrXO8bODLKyhagJ&key=yt6&sparams=clen,dur,ei,gir,id,ip,ipbits,itag,lmt,mime,mm,mn,ms,mv,pl,ratebypass,requiressl,source,expire&c=WEB&mn=sn-vgqs7nlz,sn-qxo7rn7e&mm=31,26&ip=107.178.195.196&ms=au,onr&requiressl=yes&pl=28&itag=18&mt=1521912516&dur=141.502&id=o-APewcHzWYR6z7tqcyH4vPDJrWHLRasMAk6PS8yRJcGO0&mime=video/mp4&mv=m&ipbits=0&gir=yes&fexp=23731051&lmt=1497461692839692&signature=4E21F594CBFB85E6B9AB57AC1A04A7251A0D0D92.2AE4154A6F9CE79DD832BCD8C9803A67F458E68A&source=youtube&ratebypass=yes&fvip=1&clen=4946318&utmg=ytap1,,medium"><source></video>
    </body>
</html>

Question: how does one convert (via Javascript) a hooktube url into a redirector.googlevideo.com url programmatically?

I would like to just convert the hooktube programmatically, but if it is unknown I will:

1.) get the youtube url (change it to a hooktube link) and do a jquery get to a php file 2.) the php file will echo file_get_contents($_GET["hooktube"]) 3.) I will split the result of the jquery get body to find the element with id player-obj 4.) some more splits to extract only the src and add to my page a video element with the redirect.googlevideo instead of cia youtube

My fix will work but It is lonnnng and It would require some disruption in app loading time and user experience, so any clues as to how to directly convert a yt url into the redirect.googlevideo url is much appreciated!

(Why am I asking this question?: youtube has a bug https://github.com/CookPete/react-player/issues/288 that is stopping peoples apps from performing correctly and it does not look like they wan't to fix it any time soon! This bug after a few page loads breaks my application on the browser side after a few page refreshes! This would make it look like my site is broken and provide a very bad user experience!)


Solution

  • My first idea did not work.

    but digging into hooktubes network request did

    'https://hooktube.com/api?mode=video&id='+YOUTUBE_VIDEO_ID
    

    it returns json