Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- # update script for yt-dlp v1.4
- TMP=/media/ramdisk/release_$(date +%y%m%d%H%M%S%3N) # adjust TMP & BIN path to your own system specific
- BIN=/home/pintcat/ubin
- URL=https://github.com
- CLEAN(){ # output exit message, clean up tmp data & quit
- echo $1
- rm -f "$TMP"
- exit
- }
- DOWNLOAD(){ # check if link is valid, prepare existing binary for backup, download new binary & make it executable
- echo "Starting download..."
- if ! wget -q --spider $URL$(grep "/yt-dlp_linux\"" "$TMP" | awk -F \" '{print $2}'); then
- echo "\033[0;31mError - download failed: $URL$(grep "yt-dlp_linux\"" "$TMP" | awk -F \" '{print $2}')\033[0m"
- return 1
- fi
- [ -e "$BIN"/yt-dlp~ ] && rm -f "$BIN"/yt-dlp~
- [ -e "$BIN"/yt-dlp ] && mv "$BIN"/yt-dlp "$BIN"/yt-dlp~
- wget -q --show-progress -O "$BIN"/yt-dlp $URL$(grep "/yt-dlp_linux\"" "$TMP" | awk -F \" '{print $2}')
- chmod +x "$BIN"/yt-dlp
- }
- echo "Obtaining version information..."
- wget -q -O "$TMP" $URL/yt-dlp/yt-dlp/releases || CLEAN "\033[0;31mError - couldn't connect to github page $URL/yt-dlp/yt-dlp/releases\033[0m"
- LATEST_VER=$(grep "/yt-dlp_linux\"" "$TMP" | awk -F / '{print $6}')
- printf "Latest version: $LATEST_VER, current installed version: "
- [ -x "$BIN"/yt-dlp ] && CURRENT_VER=$(yt-dlp --version) || echo "yt-dlp is not yet installed."
- [ -n "$CURRENT_VER" ] && echo $CURRENT_VER.
- if [ -n "$CURRENT_VER" ] && [ $CURRENT_VER = $LATEST_VER ]; then
- read -p "yt-dlp is up to date. Download anyway (y/N)? " YN
- case $YN in
- [Yy]*)
- DOWNLOAD && CLEAN Success.
- ;;
- esac
- else
- DOWNLOAD && CLEAN Success.
- fi
- CLEAN "Nothing changed."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement