Close

Better youtube downloader

A project log for Silly software wishlist

Motivation to do some software projects by writing them down.

lion mclionheadlion mclionhead 01/31/2021 at 06:430 Comments

Youtube downloaders were originally necessary when Firefox & Chrome couldn't play anything.  They got to the point where if you drop kicked the browser enough & ipccleaned after their incompetent ipc management, they could play audio, but now there are so many commercials & the audio is so bad, the browser player is unwatchable again.  

Most of the original downloaders don't work anymore & new ones aren't being written anymore.  Lions believe most of the content is now being viewed on phones, where the 2 corporate app stores are simply banning anything that circumvents commercials. The lion kingdom currently uses an old version of Macx.  It's heavily crippled & can't download most of the current videos.  The latest versions don't support screen scaling.  MacOS disables VNC based on many conditions, so it requires easy access to the console.

Making a better youtube downloader should involve just wiresharking Macx.  Theoretically, it uses ffmpeg to remux the streams.  The goo tubes have had a pretty stable API for the last few years.  Lions have lost their taste for GUI's so much, it would be a command line program.

UPDATE:

Gootube downloads are back, for the moment.

After a bit of research, a lot more people have worked on youtube downloaders since 2018, when the browser player started becoming really unwatchable.  The task is not as easy as simply wireshark or chrome network analysis.  The lion kingdom managed to get youtube-dl to work.  It even has source code.

https://ytdl-org.github.io/youtube-dl/download.html

To list the available format codes:

./youtube-dl -F

Note each format is either audio or video, but not both.  To download a specific format:

./youtube-dl -f <format code> --no-mtime

It doesn't automatically multiplex the audio & video streams.  You have to specify an audio & video format in the -f argument to get it to create a single multiplexed movie.

./youtube-dl -f 137+251 --no-mtime

Unfortunately, every movie has different format codes.  The mane task for lions was making a wrapper that selected formats based on the codec & resolution.

With that, the lion kingdom finally has a better solution than MacX:

https://cdn.hackaday.io/files/1380505906331200/tube.py

It tries to select codecs based on the desired resolution & whether you want just audio.

It downloads a playlist if the URL contains "&list=".  The mane problem with youtube-dl's default playlist function is it tries to download a fixed codec even if each movie in the playlist contains different codecs.  It really has to select different codecs for each member of a playlist.

youtube-dl needs another hack to generate .mp4 files from OPUS & AVC1.  It tries to enforce standards compliance by only outputting .mkv's without indexes.

Discussions