Score:2

how do I fix youtube-dl: running it gives error message about incorrect syntax

tv flag

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
pl flag
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.
24601 avatar
in flag
Why not make life easy and download [Youtube Downloader](https://askubuntu.com/a/1410302/307670) as outlined in this post by another ask ubuntu subscriber. I use it almost daily.
us flag
`Just now I followed instructions to install youtube-dl` -- Which instructions? Please edit the post and describe what you did.
Score:4
sy flag

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

Raffles avatar
in flag
Yes I agree. They appear to have stopped developing it. yt-dlp is being kept up to date.
Pedroski avatar
es flag
And https://clipgrab.org uses yt-dlp and clipGrab works for me on Ubu 22.04
Score:1
us flag

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.

pierrely avatar
cn flag
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 <url> 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 avatar
cn flag
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
Score:0
jp flag

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

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.