Botspot / youtubuddy

Search/Watch/Download YouTube videos with a lightweight, interactive tool
GNU General Public License v3.0
36 stars 10 forks source link

youtube-dl check is unstable and will produce false positives #19

Closed theofficialgman closed 2 years ago

theofficialgman commented 2 years ago

I have youtube-dl version 2022.02.04 (a self compiled version)

What is the goal here?

  if ! command -v youtube-dl >/dev/null || [ ! -z "$(youtube-dl -v 2>&1 | grep '2019\|2020')" ] || [ ! -z "$(youtube-dl -v 2>&1 | grep 'youtube-dl version 2021.01.08')" ] || [ "$(stat --printf="%s" $(command -v youtube-dl))" -ge 2000 ];then

if you just want to make sure youtube-dl is "new enough" then why not do something like this:

function version { echo "$@" | awk -F. '{ printf("%04d%02d%02d\n", $1,$2,$3); }'; }
ytdl_version=$(youtube-dl --version)
if [ $(version "$ytdl_version") -lt $(version "2021.10.07") ]; then
    echo "do stuff to install new version"
fi

also FYI, anything older than something from Feb 2022 is going to be EXTREMLY SLOW to download videos from youtube due to a change on youtube's end that now clients have to solve a puzzle to get fullspeed you can read about it here: https://github.com/ytdl-org/youtube-dl/pull/30184 commits with the fix are at the bottom

yes I realize this tool does not use youtube-dl to actually download the files (thats handled through the vlc lua script) but you should at least be doing proper checking

Botspot commented 2 years ago

I ended up doing:

if ! command -v youtube-dl >/dev/null || [ "$(date +%s -d "$(youtube-dl --version | tr '.' '/')")" -lt "$(date +%s -d "2021/12/17")" ];then