Yt-dlp doesn't work in Manjaro (zsh)

I have now also installed yt-dlp in Manjaro (Plasma 6), as I have been using it on my computer with EndeavourOS for some time and would also like to use it with manjaro. However, I always get the same message every time I enter something:

zsh: no matches found: https://www.youtube.com/watch?v=o-X-rAEBSng

Is this possibly due to zsh (only tested with bash so far)?

To help us help you, please see the following and edit your topic title to be clear and concise about the issue and correct your spelling. Please also edit your post to provide more information like the command your ran and complete output.

Use bash or zsh with quotes! (just tested). The problem seems to be some autocompletion or auto search function or config of zsh - it seems confused by the question mark in the url. What exactly is for you to find, i do not use zsh, but this works

yt-dlp "https://www.youtube.com/watch?v=o-X-rAEBSng"
2 Likes

With the quotation marks it works at least now, but I still get 2 strange warning messages:

yt-dlp "https://www.youtube.com/watch?v=QOcznP1AU9E"                          ✔  12s 
[youtube] Extracting URL: https://www.youtube.com/watch?v=QOcznP1AU9E
[youtube] QOcznP1AU9E: Downloading webpage
WARNING: [youtube] Unable to download webpage: <urllib3.connection.HTTPSConnection object at 0x7e3a94e8c620>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution
[youtube] QOcznP1AU9E: Downloading ios player API JSON
[youtube] QOcznP1AU9E: Downloading android player API JSON
[youtube] QOcznP1AU9E: Downloading iframe API JS
[youtube] QOcznP1AU9E: Downloading player 74a3a562
[youtube] QOcznP1AU9E: Downloading web player API JSON
WARNING: [youtube] Skipping player responses from android clients (got player responses for video "aQvGIIdgFDM" instead of "QOcznP1AU9E")
[youtube] QOcznP1AU9E: Downloading m3u8 information
[youtube] QOcznP1AU9E: Downloading initial data API JSON
[info] QOcznP1AU9E: Downloading 1 format(s): 303+251
[download] Destination: KENWOOD speaker system restoration ⧸⧸ The best restoration you've ever seen [QOcznP1AU9E].f303.webm
[download] 100% of  558.37MiB in 00:00:51 at 10.88MiB/s
[download] Destination: KENWOOD speaker system restoration ⧸⧸ The best restoration you've ever seen [QOcznP1AU9E].f251.webm
[download] 100% of   25.29MiB in 00:00:03 at 6.80MiB/s
[Merger] Merging formats into "KENWOOD speaker system restoration ⧸⧸ The best restoration you've everseen [QOcznP1AU9E].webm"
Deleting original file KENWOOD speaker system restoration ⧸⧸ The best restoration you've ever seen [QOcznP1AU9E].f251.webm (pass -k to keep)
Deleting original file KENWOOD speaker system restoration ⧸⧸ The best restoration you've ever seen [QOcznP1AU9E].f303.webm (pass -k to keep)

I don’t see what I did wrong other than the typo in the title. Sorry for the harassment :saluting_face:

You didn’t do anything wrong, per say. However, without knowing what command you ran and what the full output was, it’s hard for anyone to know how to help–well, except maybe for @Teo since he seems to be experienced enough with yt-dlp to know what you were talking about.

By the way it’s doesn’t with the apostrophe between the N and the T as in an abbreviation for does not. :wink:

Thanks @Teo :+1:

Thanks @Teo :+1:, what’s with the warning messages? Can I do anything about it?

WARNING: [youtube] Unable to download webpage: <urllib3.connection.HTTPSConnection object at 0x7e3a94e8c620>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution

WARNING: [youtube] Skipping player responses from android clients (got player responses for video "aQvGIIdgFDM" instead of "QOcznP1AU9E")

No idea about that, sorry.

Ok, in the end the video is downloaded without errors, so thanks.

Add this to your rc file:

script
# Downloads    youtube-dl, clipgrab
yt() {
    path_="$HOME/Downloads/yt"
    if [ ! -d "$path_" ]; then
        mkdir -p "$path_" || echo "mkdir error"
    fi

    if [ -d "$path_" ]; then
        cd "$path_" || true
    else
        echo "$path_ does not exist"
        exit
    fi
    yt-dlp --add-metadata -i -f "bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best" "$1" && echo "done" || echo "failed"
}
yta() {
    # audio only
    path_="$HOME/Downloads/yt"
    if [ ! -d "$path_" ]; then
        mkdir -p "$path_" || echo "mkdir error"
    fi

    if [ -d "$path_" ]; then
        cd "$path_" || true
    else
        echo "$path_ does not exist"
        exit
    fi

    yt-dlp -x -f bestaudio/best "$1" && echo "done" || echo "failed"
}

with that, just run yt <yourURL>

2 Likes

I have and never had an rc file for yt-dlp.

I have now created a yt-dlprc in ~/user/.config/ and put in the content of your script. Hope that was right, because it still only works with " URL ".

No, it was supposed to go in your .bashrc or .zshrc

I have

# Downloads    youtube-dl, clipgrab
yt() {
    mkdir -p ~/Downloads/yt
    cd ~/Downloads/yt || true
    yt-dlp --add-metadata -i -f "bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best" "$1" || echo "failed"
    echo "done"
}
yta() {
    # audio only
    mkdir -p ~/Downloads/yt
    cd ~/Downloads/yt || true
    yt-dlp -x -f bestaudio/best "$1" || exit
    echo "done"
}

first added to the .bashrc - no change,
then into the .zshrc, also no change.

It would at least be nice if the download path and quality could be configured.

You would need to start a new session or

source ~/.zshrc

Depending on your shell. zsh is the default with manjaro.

Also. In case it needs saying. What those lines do is provide you with commands
yt and yta
So that you could

yta https://www.youtube.com/watch?v=o-X-rAEBSng

(I also noticed the code above was missing the bottom bracket so I added it in. :slightly_smiling_face:)


They can. The project has instructions for using a configuration file.

2 Likes

Thanks for mentioning that out, so I refactor that script to change the path in the first line.

For different Quality, I don’t have any need for, so check the link from @cscs or man yt-dlp.

From there you can switch out the different options.

1 Like

Thanks for your patience, I’ll settle for @Teo’s solution. That’s enough to save videos before they fall victim to divine censorship :wink: .

Here’s another option for your consideration. It lets you copy the URL and then just run a command, no need for quotes or even pasting.

Assuming you save it as ~/.local/bin/ytdlp, copy the URL and run ytdlp, the video will be downloaded to the current dir, unless you uncomment the download_dir lines.

You could bind it to a keyboard shortcut but you should set a download dir first.

#!/usr/bin/bash

# Copy the url, eg with Ctrl + C
url=$(xclip -o -selection clipboard)

# If you'd rather just select the url then uncomment this
# and comment the line above 
#url=$(xclip -o -selection primary)

# The regular expression is so we don't try to download 
# random stuff in the clipboard, it shouldn't matter
# yt-dlp should complain and exit anyway
# but this way the output is short and clear

# for youtube
regex='^https://www.youtube.com/watch.*'

# for any site, not tested
#regex="^https?://www\..*"

# set a location to download to
# download_dir=~/Videos/yt-dlp

# or with a parameter
# download_dir="$1"

if [[ $url =~ $regex ]]; then
    # mkdir "$download_dir"     # if it already exists, nothing happens
    # cd "$download_dir"
    yt-dlp "$url"
else
    echo "Invalid URL: $url"
fi

This was simplified from another script I made, I haven’t tested this version.

1 Like

Thanks for the script and the effort you’ve put in, but it just looks like there are problems with characters in the URLS, which is where the quotes come in:

yt-dlp https://www.youtube.com/watch?v=N_5s8x6OojY
zsh: no matches found: https://www.youtube.com/watch?v=N_5s8x6OojY
1 Like

The problems come from zsh trying to interpret the characters, the quotes stop this. AFAIK it should work in bash (does normally, but I can’t say for certain that there aren’t any problematic chars), which is what the script runs in but I’ve edited the script just in case.

I’ve used the original script and it definitely works (and includes the quotes I’ve added above).

It was designed so I don’t have to type out the command every time, especially in zsh where quotes are needed.

That’s right, I also used it with EndeavourOS with bash.