9

I recently installed 22.04 completely from scratch. Just now I followed instructions to install youtube-dl, with wget (from github.com):

sudo wget https://yt-dl.org/downloads/latest/youtube-dl -O /usr/local/bin/youtube-dl
sudo chmod a+rx /usr/local/bin/youtube-dl

It seemed to download, but upon using it, it says this:

$ youtube-dl https://www.youtube.com/watch?v=xSyDTIAX_oE
/usr/local/bin/youtube-dl: line 1: --2023-03-05: command not found
/usr/local/bin/youtube-dl: line 2: syntax error near unexpected token `('
/usr/local/bin/youtube-dl: line 2: `Resolving yt-dl.org (yt-dl.org)... 95.143.172.170, 2001:1a50:11:0:5f:8f:acaa:177'

I am not sure if I am even giving enough/appropriate information for asking my question. Please advise me if I should explain something else. Apparently youtube-dl was not working for a while but the website says it's fine again. I don't know if that might be part of the problem?

I tried these commands as suggested:

file /usr/local/bin/youtube-dl
/usr/local/bin/youtube-dl: Unicode text, UTF-8 text, with very long lines (564)

head /usr/local/bin/youtube-dl --2023-03-05 12:38:51-- https://yt-dl.org/downloads/latest/youtube-dl Resolving yt-dl.org (yt-dl.org)... 95.143.172.170, 2001:1a50:11:0:5f:8f:acaa:177 Connecting to yt-dl.org (yt-dl.org)|95.143.172.170|:443... connected. HTTP request sent, awaiting response... 302 Found Location: https://yt-dl.org/downloads/2021.12.17/youtube-dl [following] --2023-03-05 12:38:52-- https://yt-dl.org/downloads/2021.12.17/youtube-dl Reusing existing connection to yt-dl.org:443. HTTP request sent, awaiting response... 302 Found Location: https://github.com/ytdl-org/youtube-dl/releases/download/2021.12.17/youtube-dl [following] --2023-03-05 12:38:52-- https://github.com/ytdl-org/youtube-dl/releases/download/2021.12.17/youtube-dl

Akpglt
  • 113
  • 1
  • 1
  • 5

3 Answers3

11

I found youtube-dl to be outdated, so I found a solution at:

https://www.linuxbabe.com/desktop-linux/install-youtube-dl-linux-use

I installed:

pip3 install yt-dlp

It works OK:

yt-dlp https://www.youtube.com/watch?v=youtube-dl_has_made_the_world_better

xerostomus
  • 1,060
3

try this

pip install --upgrade --force-reinstall "git+https://github.com/ytdl-org/youtube-dl.git"

source: https://github.com/ytdl-org/youtube-dl/issues/31530#issuecomment-1435477247

1

It seems that your youtube-dl download was incomplete, and the /usr/local/bin/youtube-dl contains the error messages instead of the actual binary. First, delete it.

sudo rm /usr/local/bin/youtube-dl

Then, install it with python3-pip.

sudo apt install python3-pip
pip3 install --user youtube-dl

Finally, you may have to run source .bashrc so that the youtube-dl executible is within $PATH.