Tag Archives: bash


In order to avoid having to run proprietary code from Google I cobbled together a script a few days ago combining youtube-dl and vlc. The result is far from perfect, but allows me to both download videos off of YouTube for safekeeping and make use of features in vlc such as fixing aspect ratios and incorrect cropping. I’m placing the following script in the public domain, in the hope that it will be useful to someone:

TITLE=$(youtube-dl -j $1 | sed -e 's/.*"fulltitle": "//;s/".*//')
echo $TITLE
cd /tmp
youtube-dl $1 -o "${TITLE}.mp4" &

# A bit of an ugly hack here, but it works
#if [ -f "${TITLE}.mp4" ]
#    # Already have the file
#    vlc "${TITLE}.mp4"
#    exit 0

# Wait for the download to start
while [ ! -f "${TITLE}.mp4.part" ]
    echo Waiting
    sleep 1

# Wait a little more so we have some data..
sleep 1
vlc "${TITLE}.mp4.part"

Some improvements could still be made. One issue is that sometimes the download finished during the final sleep, so vlc get the wrong filename. Meh!

edit: this feature is now built into both vlc and mpv, and implemented much better. Yay!