From 5835754be659ce9bce2b81d8e22f97502da42ad2 Mon Sep 17 00:00:00 2001 From: Michele Cereda Date: Sun, 1 May 2022 09:41:58 +0200 Subject: [PATCH] Added examples to youtube-dl's notes --- knowledge base/youtube-dl.md | 46 +++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 14 deletions(-) diff --git a/knowledge base/youtube-dl.md b/knowledge base/youtube-dl.md index 878d414..fb9ccf4 100644 --- a/knowledge base/youtube-dl.md +++ b/knowledge base/youtube-dl.md @@ -3,26 +3,40 @@ ## TL;DR ```shell -# limit the bandwidth -youtube-dl --format 313 --limit-rate 2M $URL +# Limit the bandwidth. +youtube-dl --format 313 --limit-rate 2M video-url -# list all available formats -youtube-dl --list-formats ${URL} +# List all available formats. +youtube-dl --list-formats video-url -# download bestvideo and bestaudio formats and merge them in a single file -youtube-dl -f bestvideo+bestaudio $URL +# Download the 'bestvideo' and 'bestaudio' formats and merge them in a single +# file. +youtube-dl -f bestvideo+bestaudio video-url -# download formats separately and do not merge them -youtube-dl -f bestvideo,bestaudio $URL +# Download formats separately and do not merge them. +youtube-dl -f bestvideo,bestaudio video-url -# download the best all-around formats -youtube-dl -f best $URL +# Download the best all-around formats. +youtube-dl -f best video-url -# also download thumbnails and other info (in separate files) -youtube-dl --write-description --write-info-json --write-annotations --write-sub --write-thumbnail $URL +# Download the first format in a list. +youtube-dl -f bestvideo+bestaudio/best video-url -# sequentially download a list of videos -parallel --jobs 1 --retries 10 'youtube-dl -f bestvideo+bestaudio "https://www.youtube.com/watch?v={}"' ::: ${CODES[@]} +# Filter formats by conditions. +youtube-dl -f bestvideo+bestaudio[height>=720]/best[filesize>100M] video-url + +# Also download thumbnails and other info (in separate files). +youtube-dl --write-description --write-info-json --write-annotations \ + --write-sub --write-thumbnail video-url + +# Sequentially download a list of videos. +parallel --jobs 1 --retries 10 \ + 'youtube-dl -f bestvideo+bestaudio "https://www.youtube.com/watch?v={}"' \ + ::: ${CODES[@]} + +# Download all videos in a YouTube channel. +youtube-dl -f "bestvideo+bestaudio/best" -ciw \ + -o "%(title)s.%(ext)s" -v channel-url ``` ## Installation @@ -37,13 +51,17 @@ python3 youtube-dl … Alternatively, most package managers will have the package available. +> To be able to merge multiple formats into one, you will also need to install `ffmpeg` or `avconv`. + ## Further readings - Github [project]'s page - [Website] - [Youtube-DL tutorial with examples for beginners] +- [using youtube-dl to download entire youtube channel] [project]: https://github.com/ytdl-org/youtube-dl [website]: http://ytdl-org.gitlab.io/youtube-dl [youtube-dl tutorial with examples for beginners]: https://ostechnix.com/youtube-dl-tutorial-with-examples-for-beginners +[using youtube-dl to download entire youtube channel]: https://askubuntu.com/questions/856911/using-youtube-dl-to-download-entire-youtube-channel#1245829