patching youtube-dl

I have youtube-dl installed on linux as a “binary”. I’m using quotes because it’s not really binary but zipped executable. I needed to patch my youtube-dl with a patch from some user that provided it in github issues. So, here it goes.

The main installation method to install youtube-dl, according to is to

sudo wget -O /usr/local/bin/youtube-dl
sudo chmod a+rx /usr/local/bin/youtube-dl

You end up with a single executable file in /usr/local/bin/ and that’s totally fine. Updating youtube-dl to the latest version is usually done with

sudo youtube-dl -U

But how to patch this? Contrary to usual logic it’s possible to simply unpack executalble and patch. That executable is actually a zip file. I first create a folder for hacking and extract the zip into it:

mkdir ~/.local/src/youtube-dl
unzip /usr/local/bin/youtube-dl -d ~/.local/src/youtube-dl/

I have downloaded a patch to enable some franceTV videos to be downloaded, since they changed their API, into a file ~/.local/src/youtube-dl/youtube-dl-patch.txt, so in order to patch the extractor for franceTV – I do

patch ~/.local/src/youtube-dl/youtube_dl/extractor/ < ~/.local/src/youtube-dl/youtube-dl-patch.txt

I can then run the program simply by running

cd ~/.local/src/youtube-dl/
./ --verbose

There’s a way to pack the new patched tree back into an executable zip with ‘make youtube-dl’, but I couldn’t find a way yet.