Update: Changed the method for finding the latest version

I had been using a script which kept youtube-dl up to date automatically, but youtube-dl doesn't seem to have received an update for a long time. It still works, but very slowly for some reason. I have now found yt-dlp which seems to be almost a drop in replacement for youtube-dl (at least for what I used it for). I have now modified my update script and the SlackBuild so that it works with yt-dlp. This SlackBuild will also create a symlink from youtube-dl to yt-dlp so that anything looking for youtube-dl will still work.

You can download the script and SlackBuild here
yt-dlp-updater.tar.gz

And here is what the new update script looks like

#!/bin/bash

# Remember where the SlackBuild script is
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
SBDIR=$DIR/yt-dlp
echo DIR: $DIR, SBDIR: $SBDIR
if [ ! -f $SBDIR/yt-dlp.SlackBuild ]; then
        echo "SlackBuild not found"
        exit 1
fi

# find the latest version
VERSION=$(curl -sv https://github.com/yt-dlp/yt-dlp/releases/latest 2>&1 | grep -e '^< location: ' | sed -n 's#.*releases/tag/\(.*\)\r$#\1#p')
LATEST_URL=https://github.com/yt-dlp/yt-dlp/archive/refs/tags/$VERSION.tar.gz

# download it to /tmp
TMPDIR=$(mktemp -d /tmp/yt-dlp-updater-XXXXXX)

cd $TMPDIR
wget $LATEST_URL

# copy the SlackBuild there too
cp $SBDIR/* $TMPDIR

echo "Latest is $VERSION at $LATEST_URL"
echo "Working in $TMPDIR"

# Build the package
ARCH=$(uname -m)
VERSION=$VERSION sh ./yt-dlp.SlackBuild

# and install it
/sbin/upgradepkg --install-new --reinstall /tmp/yt-dlp-$VERSION-$ARCH-1_SBo.tgz

# cleanup
if [ -d $TMPDIR ]; then
        echo "Removing $TMPDIR"
        rm -r $TMPDIR
fi

Previous Post Next Post