diff --git a/knowledge base/yt-dlp.md b/knowledge base/yt-dlp.md index 03b6772..6eec09d 100644 --- a/knowledge base/yt-dlp.md +++ b/knowledge base/yt-dlp.md @@ -1,65 +1,95 @@ # Yt-dlp -Improved fork of [youtube-dl]. - -## Table of contents +Improved fork of [`youtube-dl`][youtube-dl]. 1. [TL;DR](#tldr) 1. [Further readings](#further-readings) ## TL;DR -> To be able to merge multiple formats into one, you will also need to install `ffmpeg`. +> [!tip] +> Also install [`ffmpeg`][ffmpeg] to support merging multiple formats into one. + +
+ Setup ```sh -# Install it. -python3 -m pip install -U --user yt-dlp +brew install 'yt-dlp' +pipx install 'yt-dlp' +python3 -m pip install -U --user 'yt-dlp' +``` +
+ +
+ Usage + +```sh # List all available formats. -yt-dlp -F AK44wAvv2E4 +yt-dlp -F 'AK44wAvv2E4' +yt-dlp --list-formats 'AK44wAvv2E4' # See all available information from a video. -yt-dlp -j BaW_jenozKc +yt-dlp -j 'BaW_jenozKc' +yt-dlp --dump-json 'BaW_jenozKc' # List available subtitiles. -yt-dlp --list-subs rQnNghhPw6o +yt-dlp --list-subs 'rQnNghhPw6o' # Check what name will be used for the destination. # Output templates at https://github.com/yt-dlp/yt-dlp#output-template, or use # '-j' to see the json file with all of them. yt-dlp --get-filename \ - -o "%(season_number)d.%(episode_number)02d %(episode)U.%(ext)s" \ - https://www.crunchyroll.com/some/good/serie + -o '%(season_number)d.%(episode_number)02d %(episode)U.%(ext)s' \ + 'https://www.crunchyroll.com/some/good/serie' + +# Get a video in the best available quality. +yt-dlp -f 'bestvideo+bestaudio/best' 'https://www.youtube.com/watch?v=abc4EFG89jK' +yt-dlp --format 'bestvideo+bestaudio/best' 'https://www.youtube.com/watch?v=abc4EFG89jK' # Download all videos in a YouTube channel. -yt-dlp -f "bestvideo+bestaudio/best" -ciw \ - -o "%(title)#S.%(ext)s" -v https://www.youtube.com/c/pbsspacetime/videos +yt-dlp -ciw 'https://www.youtube.com/c/somechannel/videos' +yt-dlp --continue --ignore-errors --no-overwrites 'https://www.youtube.com/c/somechannel/videos' +``` -# As above with improvements. +
+ +
+ Real world use cases + +```sh +# Get a video in the best available quality. +yt-dlp -f 'bestvideo+bestaudio/best' -ciw -o '%(title)#S.%(ext)s' 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' + +# Download all videos in a YouTube channel (improved). # Slow down the requests to avoid issues in retrieving the data. # Include chapters, metadata and selected subtitles. # Prefix the file name with its timestamp, or upload date if it is null. yt-dlp -ciw \ --retry-sleep 3 --sleep-requests 0 --sleep-subtitles 3 \ --embed-chapters --embed-metadata --embed-subs \ - --sub-langs "(de|en|fr|es|it|ja|nl|zh(-Han.*)?)(-en)?" \ - --sub-format "ass/srt/best" --write-auto-subs \ - -f "bestvideo+bestaudio/best" \ - -o "%(timestamp>%Y-%m-%d,upload_date>%Y-%m-%d)s %(title)U.%(ext)s" \ - https://www.youtube.com/c/becausescience/videos + --sub-langs '(de|en|fr|es|it|ja|nl|zh(-Han.*)?)(-en)?' \ + --sub-format 'ass/srt/best' --write-auto-subs \ + -f 'bestvideo+bestaudio/best' \ + -o '%(timestamp>%Y-%m-%d,upload_date>%Y-%m-%d)s %(title)U.%(ext)s' \ + 'https://www.youtube.com/c/becausescience/videos' ``` +
+ ## Further readings -- [GitHub] -- [youtube-dl] +- [Codebase] +- [`youtube-dl`][youtube-dl] - -[github]: https://github.com/yt-dlp/yt-dlp - +[ffmpeg]: ffmpeg.md [youtube-dl]: youtube-dl.md + + +[Codebase]: https://github.com/yt-dlp/yt-dlp