yt-dlp / yt-dlp

A feature-rich command-line audio/video downloader
https://discord.gg/H5MNcFW63r
The Unlicense
73.35k stars 5.81k forks source link

yt-dlp cannot download video using its id code: no such option: -0. How i can do it? #9956

Closed estatistics closed 2 weeks ago

estatistics commented 2 weeks ago

DO NOT REMOVE OR SKIP THE ISSUE TEMPLATE

Checklist

Provide a description that is worded well enough to be understood

yt-dlp cannot download video using its id code: no such option: -0. How i can do it?

I use to download videos from youtube using their ids: yt-dlp id, and its works. but now "-40JTHtTjCk" this is got as option and not as id. what i must do?

Maybe, just maybe you can do it as in ffmpeg style eg.: yt-dlp "ids: -40JTHtTjCk dfdsftTjCk j56gfdg .... "

Provide verbose output that clearly demonstrates the problem

Complete Verbose Output

yt-dlp -vU   --no-warning  --username oauth2 --password ''  -o "%(title)s_[%(id)s].%(ext)s"  "-40JTHtTjCk" 
[debug] Command-line config: ['-vU', '--no-warning', '--username', 'PRIVATE', '--password', 'PRIVATE', '-o', '%(title)s_[%(id)s].%(ext)s', '-40JTHtTjCk']

Usage: yt-dlp [OPTIONS] URL [URL...]

yt-dlp: error: no such option: -0

yt-dlp -v
[debug] Command-line config: ['-v']
[debug] Encodings: locale UTF-8, fs utf-8, pref UTF-8, out utf-8, error utf-8, screen utf-8
[debug] yt-dlp version stable@2024.04.09 from yt-dlp/yt-dlp [ff0779267] (zip)
[debug] Python 3.11.9 (CPython x86_64 64bit) - Linux-6.1.0-15-amd64-x86_64-with-glibc2.38 (OpenSSL 3.2.2-dev , glibc 2.38)
[debug] exe versions: ffmpeg 6.1.1-4 (setts), ffprobe 6.1.1-4, rtmpdump 2.4
[debug] Optional libraries: Cryptodome-3.11.0, brotli-1.1.0, certifi-2023.11.17, mutagen-1.46.0, pyxattr-0.8.1, requests-2.31.0, sqlite3-3.45.3, urllib3-1.26.18, websockets-10.4
[debug] Proxy map: {}
seproDev commented 2 weeks ago

Add -- before you start with the list of IDs to indicate to yt-dlp that no more regular arguments follow. So instead of

yt-dlp -F "-40JTHtTjCk"

You would run

yt-dlp -F -- "-40JTHtTjCk"

Alternatively, you can use -a to load in a list of URLs/IDs (docs).

estatistics commented 2 weeks ago

THANKS!

dirkf commented 2 weeks ago

Is the -- behaviour actually documented?

The optparse documentation says that its default behaviour is to support "... only the most common command-line syntax and semantics conventionally used under Unix" and then summarises these with no mention of the -- convention for ending the option list.

yt-dlp overrides the default argument processing with parse_known_args() but both implement the -- option break.

Since this isn't an obvious feature of the program or Python-based programs generally (nor is it universal even in GNU/POSIX despite ...), it should be in the help's option list, both here and upstream. Presumably the automatic generation of the list skips it as a prefix of other options?

Grub4K commented 2 weeks ago

This is domumentation about that exact case: How do I download a video starting with a -?

dirkf commented 2 weeks ago

Wouldn't it be better to document the -- option internally?

It looks like the only easy way (say, without patching .print_help()) to do that would use thedescription/epilogoptions of_YoutubeDLOptionParser/optparse.OptionParser. yt-dl could useepilog` but that's spoken for here. Maybe:

            description='Use option -- to force treatment of all subsequent items as URLs',