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
  • 2
    what does file /usr/local/bin/youtube-dl and head /usr/local/bin/youtube-dl say? I suspect you've somehow managed to wget an html page or something, not the actual youtube-dl script. – popey Mar 05 '23 at 15:18
  • Why not make life easy and download Youtube Downloader as outlined in this post by another ask ubuntu subscriber. I use it almost daily. – graham Mar 05 '23 at 17:41
  • Just now I followed instructions to install youtube-dl -- Which instructions? Please edit the post and describe what you did. – Archisman Panigrahi Mar 05 '23 at 20:21

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,080
  • 2
    Yes I agree. They appear to have stopped developing it. yt-dlp is being kept up to date. –  Mar 12 '23 at 15:05
  • 1
    And https://clipgrab.org uses yt-dlp and clipGrab works for me on Ubu 22.04 – Pedroski Mar 21 '23 at 05:23
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

Gytis Bliu
  • 161
  • 1
  • 5
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.

  • I have python/pip problems so my quick fix was to download t https://github.com/yt-dlp/yt-dlp/archive/master.tar.gz unzip it and run it from that location using sh yt-dlp.sh there were some audio issues though and it was downloading in partial files then periodically adding to the one that would play whilst downloading. $PATH setting as above would be an improvement – pierrely Apr 01 '23 at 21:58
  • 1
    and for multiple urls I save to list.txt and run as for i in $(cat list.txt); do sh yt-dlp.sh "$i" ;done

    no problems now with the previous errors. downloading is erratic in bandwidth usage though but it worked

    – pierrely May 01 '23 at 05:44