download youtube youtube-dl code example

Example 1: install youtube-dl windows

1. install chocolate on your computer
--- 1. open powershell using 'RUN AS ADMINISTRATOR'
--- 2. Paste the 'follow' and 'run'

Set-ExecutionPolicy Bypass -Scope Process -Force; `
  iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))

--- 3. Close and Reopen powershell

2. install youtube-dl using choco
--- 1. choco install youtube-dl
--- 2. enter 'a' and press enter for any prompts
--- 3. choco install ffmpeg
--- 4. enter 'a' and press enter for any prompts

3. open 'cmd' and use 'youtube-dl'
--- 1. to download a single video
------>  youtube-dl -ciw -f mp4 https://www.youtube.com/watch?v=dQw4w9WgXcQ -o "%(title)s.%(ext)s"
--- 2. to download a playlist
------>  youtube-dl -ciw -f mp4 https://www.youtube.com/playlist?list=PLv3TTBr1W_9tppikBxAE_G6qjWdBljBHJ -o "%(playlist_index)s %(title)s.%(ext)s"
--- 3. to extract audio from video
------>  youtube-dl -ciw --extract-audio --audio-format mp3 --audio-quality 0 https://www.youtube.com/watch?v=dQw4w9WgXcQ -o "%(title)s.%(ext)s"

Example 2: youtube-dl

youtube-dl -o "%USERPROFILE%\Desktop\statquest\%(autonumber)s-%(title)s.%(ext)s" -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/bestvideo+bestaudio' --merge-output-format mp4 https://www.youtube.com/playlist?list=PLblh5JKOoLUICTaGLRoHQDuF_7q2GfuJF

Tags:

Misc Example