Sfoglia la documentazione
Guide
Copia i comandi per video, audio, sottotitoli, dataset e ripresa di una raccolta.
In questa pagina
Configurazione e Command Conventions
python -m pip install -U --pre "yt-dlp[default,curl-cffi]"
deno --version
ffmpeg -version
python -m yt_dlp --list-impersonate-targetsLe ricette di download utilizzano Deno e --impersonate="" come linea di base. Il secondo richiede curl-cffi e permette di scegliere un’impronta del browser disponibile. Linux/macOS comanda l'uso della sintasi Bash; per un lavoratore programmato, anche rendere disponibili queste dipendenze in quel ambiente di servizio.
Questi esempi terminali utilizzano l'installazione Python di yt-dlp. Utilizzare Python, o sostituire Python -m yt_dlp con il comando standalone yt-dlp. Utilizzare Linux prima, con macOS e Windows alternative nella guida di impostazione. Installare FFmpeg/ffprobe per fusione e Deno per risolvere il problema di YouTube. Sostituisci l'URL con la tua fonte.
| Convenzione | Perché è importante |
|---|---|
| Scrivere URL e template | Il shell interprete in modo diverso personaggi come &, spazi e parentesse. |
| Mantenere %(ext)s in filename | I media selezionati e il post-processing determinano l'estensione. |
| Utilizzare --no-playlist per un orologio URL | Un video collegato da un elenco di riproduzione non dovrebbe espandere in modo inaspettato il tuo lavoro. |
| Verifica la tua configurazione salata | Esempi possono ereditare un configlio globale. Utilizzare --ignore-config per un test isolato. |
| Windows .bat: doppio modello percentuale segni | Utilizzare il %(id) in un file di pacch, ma il %(id) in file di configurazione interattivi PowerShell e normale. |
Qualità video e MP4
Baseline: ultimo notturno, Deno e FFmpeg, con --impersonate="". Le ricette utilizzano Bash; sostituire l'URL di campione con la vostra fonte.
python -m yt_dlp --js-runtimes deno --impersonate="" --no-playlist -P downloads \
-o "%(id)s.%(ext)s" "https://www.youtube.com/watch?v=jNQXAC9IVRw"python -m yt_dlp --js-runtimes deno --impersonate="" --no-playlist \
-F "https://www.youtube.com/watch?v=jNQXAC9IVRw"python -m yt_dlp --js-runtimes deno --impersonate="" --no-playlist -S "res:1080" \
"https://www.youtube.com/watch?v=jNQXAC9IVRw"python -m yt_dlp --js-runtimes deno --impersonate="" --no-playlist \
-f "bv*[height<=1080]+ba/b[height<=1080]" "https://www.youtube.com/watch?v=jNQXAC9IVRw"python -m yt_dlp --js-runtimes deno --impersonate="" --no-playlist \
-f "bv[vcodec^=avc1][height<=1080]+ba[acodec^=mp4a]/b[vcodec^=avc1][acodec^=mp4a][height<=1080]" \
--merge-output-format mp4 "https://www.youtube.com/watch?v=jNQXAC9IVRw"Set dati AI: MP4 + capzioni + metadati
python -m yt_dlp --js-runtimes deno --impersonate="" --no-playlist \
-f "bestvideo+bestaudio/best" --merge-output-format mp4 --remux-video mp4 \
--write-info-json --write-subs --write-auto-subs --sub-langs "en" --sub-format "vtt/best" \
--sleep-subtitles 5 --concurrent-fragments 1 -P dataset -o "%(id)s/%(id)s.%(ext)s" \
"https://www.youtube.com/watch?v=jNQXAC9IVRw"Il download esterno: aria2c
python -m yt_dlp --js-runtimes deno --impersonate="" --no-playlist --downloader aria2c \
--downloader "dash,m3u8:native" --downloader-args "aria2c:-x 2 -s 2 -j 1" \
--concurrent-fragments 1 -P downloads "https://www.youtube.com/watch?v=jNQXAC9IVRw"aria2 ha la sua propria implementazione di rete. yt-dlp's curl-cffi impersonation non configurerà aria2's fingerprint. Se solo il download esterno fallisce, utilizzare --downloader nativo e confrontare la stessa fonte e la strada proxy.
Il suo nome e MP3
python -m yt_dlp --js-runtimes deno --impersonate="" --no-playlist -f ba -P audio \
-o "%(id)s.%(ext)s" "https://www.youtube.com/watch?v=jNQXAC9IVRw"python -m yt_dlp --js-runtimes deno --impersonate="" --no-playlist -f ba -x \
--audio-format mp3 --audio-quality 192K -P audio \
"https://www.youtube.com/watch?v=jNQXAC9IVRw"python -m yt_dlp --js-runtimes deno --impersonate="" --no-playlist -f "ba[ext=m4a]" -P audio \
"https://www.youtube.com/watch?v=jNQXAC9IVRw"python -m yt_dlp --js-runtimes deno --impersonate="" --no-playlist -f ba -x \
--audio-format mp3 --embed-metadata --embed-thumbnail -P audio \
"https://www.youtube.com/watch?v=jNQXAC9IVRw"Capture e sottotitoli
python -m yt_dlp --js-runtimes deno --impersonate="" --no-playlist \
--list-subs "https://www.youtube.com/watch?v=jNQXAC9IVRw"python -m yt_dlp --js-runtimes deno --impersonate="" --skip-download --write-subs \
--sub-langs "en.*" --sub-format "vtt/best" -P captions -o "%(id)s.%(ext)s" \
"https://www.youtube.com/watch?v=jNQXAC9IVRw"python -m yt_dlp --js-runtimes deno --impersonate="" --skip-download --write-subs \
--write-auto-subs --sub-langs "en.*" --sub-format "vtt/best" -P captions \
-o "%(id)s.%(ext)s" "https://www.youtube.com/watch?v=jNQXAC9IVRw"python -m yt_dlp --js-runtimes deno --impersonate="" --skip-download --write-subs \
--write-auto-subs --sub-langs "en" --convert-subs srt -P captions \
"https://www.youtube.com/watch?v=jNQXAC9IVRw"python -m yt_dlp --js-runtimes deno --impersonate="" --write-subs --sub-langs "en" \
--embed-subs --remux-video mkv -P downloads "https://www.youtube.com/watch?v=jNQXAC9IVRw"Richiesta di tutte le lingue di taglio può aumentare notevolmente il numero di richieste e file. Mantenere esplicitamente le lingue richieste per il lavoro di routine. Conservare l'ID di fonte e il linguaggio nel inventario del database in modo che i trascriti non siano separati dai media che descrivono.
Metadati e percorsi di uscita
python -m yt_dlp --js-runtimes deno --impersonate="" --no-playlist \
--dump-json "https://www.youtube.com/watch?v=jNQXAC9IVRw" > video.jsonpython -m yt_dlp --js-runtimes deno --impersonate="" --skip-download --write-info-json \
-P metadata -o "%(id)s.%(ext)s" "https://www.youtube.com/watch?v=jNQXAC9IVRw"python -m yt_dlp --js-runtimes deno --impersonate="" --skip-download --write-thumbnail \
-P thumbnails -o "%(id)s.%(ext)s" "https://www.youtube.com/watch?v=jNQXAC9IVRw"python -m yt_dlp --js-runtimes deno --impersonate="" --no-playlist \
--print after_move:filepath -P downloads -o "%(id)s.%(ext)s" \
"https://www.youtube.com/watch?v=jNQXAC9IVRw"python -m yt_dlp --js-runtimes deno --impersonate="" --no-playlist \
--print-to-file after_move:filepath completed-paths.txt -P downloads \
"https://www.youtube.com/watch?v=jNQXAC9IVRw"Il tempo e i capitoli
python -m yt_dlp --js-runtimes deno --impersonate="" --no-playlist \
--download-sections "*00:00:05-00:00:10" -o "clips/%(id)s-%(section_start)s.%(ext)s" \
"https://www.youtube.com/watch?v=jNQXAC9IVRw"python -m yt_dlp --js-runtimes deno --impersonate="" --no-playlist \
--download-sections "*00:00:05-00:00:10" --force-keyframes-at-cuts \
-o "clips/%(id)s-%(section_start)s.%(ext)s" "https://www.youtube.com/watch?v=jNQXAC9IVRw"python -m yt_dlp --split-chapters -o "chapter:%(id)s-%(section_number)03d.%(ext)s" \
"https://www.youtube.com/watch?v=YOUR_VIDEO_ID"Utilizzare una politica di uscita o archivio diverso per i clip e i video completi. Un'ingresso archivio a livello di fonte non codifica le volte selezionate start/end, quindi un archivio condiviso può sopprimere un clip successivo che si intende creare.
Le liste di gioco e le URL
python -m yt_dlp --no-playlist --batch-file urls.txt -P collection -o "%(id)s.%(ext)s"python -m yt_dlp --flat-playlist \
--dump-json "https://www.youtube.com/playlist?list=YOUR_PLAYLIST_ID" > playlist.jsonlpython -m yt_dlp --playlist-items 1:5 -P collection -o "%(playlist_index)03d-%(id)s.%(ext)s" \
"https://www.youtube.com/playlist?list=YOUR_PLAYLIST_ID"python -m yt_dlp --dateafter 20260101 --match-filters "!is_live & duration <= 1800" \
--batch-file urls.txtpython -m yt_dlp --download-archive archive.txt --max-downloads 10 --batch-file urls.txtArchivi e recupero
python -m yt_dlp --download-archive archive.txt --continue --no-abort-on-error -P collection \
-o "%(id)s.%(ext)s" --batch-file urls.txtpython -m yt_dlp --sleep-requests 1 --sleep-interval 5 --max-sleep-interval 10 --retries 3 \
--fragment-retries 3 --socket-timeout 30 --batch-file urls.txtpython -m yt_dlp --js-runtimes deno --impersonate="" --limit-rate 2M \
"https://www.youtube.com/watch?v=jNQXAC9IVRw"python -m yt_dlp --js-runtimes deno --impersonate="" --concurrent-fragments 1 \
"https://www.youtube.com/watch?v=jNQXAC9IVRw"Configurazione e filename
python -m yt_dlp --ignore-config --config-locations yt-dlp-work.conf --batch-file urls.txtpython -m yt_dlp --js-runtimes deno --impersonate="" -P downloads \
-o "%(channel_id)s/%(upload_date)s-%(title).150B [%(id)s].%(ext)s" \
"https://www.youtube.com/watch?v=jNQXAC9IVRw"python -m yt_dlp --js-runtimes deno --impersonate="" -P "home:downloads" -P "temp:work" \
-o "%(id)s.%(ext)s" "https://www.youtube.com/watch?v=jNQXAC9IVRw"Per le collezioni a lungo termine, decidere se i filenami dovrebbero essere chiavi di applicazione leggibili o stabili. I nomi e i titoli dei canali possono cambiare. Channel/video I ID sono migliori chiavi per la deduplicazione, con campi descrittivi tenuti in metadati.
Cookie e percorsi di runtime
python -m yt_dlp --js-runtimes deno --impersonate="" \
--cookies-from-browser "chrome:Profile 1" \
--no-playlist "https://www.youtube.com/watch?v=jNQXAC9IVRw"python -m yt_dlp --js-runtimes deno --impersonate="" --cookies private/youtube-cookies.txt \
--no-playlist "https://www.youtube.com/watch?v=jNQXAC9IVRw"python -m yt_dlp --js-runtimes "deno:/opt/deno/bin/deno" --impersonate="" \
--no-playlist "https://www.youtube.com/watch?v=jNQXAC9IVRw"Diagnosi e verifica
python -m yt_dlp --js-runtimes deno --impersonate="" --ignore-config --verbose --simulate \
--no-playlist "https://www.youtube.com/watch?v=jNQXAC9IVRw"python -m yt_dlp --js-runtimes deno --impersonate="" --ignore-config --verbose --simulate \
--no-playlist "https://www.youtube.com/watch?v=jNQXAC9IVRw" > diagnostic.log 2>&1ffprobe -v error -show_entries format=duration,size:stream=codec_type,codec_name,width,height -of json "YOUR_OUTPUT_FILE"ffmpeg -v error -i "YOUR_OUTPUT_FILE" -f null -python -m pip install -U --pre "yt-dlp[default,curl-cffi]"
python -m yt_dlp --version