Hacker News new | ask | show | jobs
by Sir_Cmpwn 4095 days ago
If it interests anyone here, I have written a Firefox extension that forces YouTube videos to play in an external video player (mpv in my case). You can get it here (only for Linux):

https://github.com/SirCmpwn/ExternalPlayer

I got fed up with the YouTube player and wrote this in an afternoon instead.

1 comments

HA, I did similar thing for Opera 12.xx on windows with mplayer :-)

I see you are using youtube-dl. I did too at first, but quickly swapped for YouTubeCenter plugin - it extracts link to mp4 directly in the javascript, my additional javascript grabs that and substitutes YT player window with big PLAY button with a link to custom protocol "magnet1:https://r2---sn-2apm-f5fee.googlevideo.com/videoplayback?sou....

Copying the way browsers open magnet links was the quickest and easiest way I found of passing links directly to a third party program. I simply made a new one, called it magnet1, and directed it towards \AppData\Roaming\smplayer\mplayer.bat %1

.

mplayer.bat:

echo off

set var=%1

start "" "C:\Users\bofh\AppData\Roaming\smplayer\smplayer" "%var:~9%

exit

.

cut first 9 characters (magnet1:) and run mplayer, that again was the only way I found of starting new program without keeping command line window open. No delay between clicking and starting video, no unnecesary command prompt window with youtube-dl running. I also have a second custom protocol that starts yet another bat file sending link directly to my TV - one click on a page and YT clip starts playing on the TV in the next room :o)

Feels like duct tape and glue, but works flawlessly :)

https://github.com/YePpHa/YouTubeCenter

I was using youtube-dl, but no longer. Now I just pass the URL directly into mpv, which has its own youtube-dl hook.

Side note, oh boy do you need to get some Linux in your life. That's the hackiest thing I've ever seen on Windows for something that'd take minutes to implement on Linux.

That still takes time to refetch yt page and parse for mp4 link. Smplayer can do it too, but it takes ~1 second, thats ~1 second too long for me :P. If I wasnt so lazy I would find youtubecenter code responsible for this parsing, but I am, so I simply

document.getElementById("watch8-ytcenter-buttons").children[0].children[0].href

and bam, mp4 link ready in javascript for free.

Got plenty of Linux in my life (mostly embedded, for example running my DIY TV build from recycled 32' LCD panel, universal chinese lcd controller and rasPee. Yes, I like repurposing junk). Linux is how I learned to cobble up together ugliest hacks imaginable.