Skip to content

Instantly share code, notes, and snippets.

@Hrissimir
Created August 17, 2023 06:34
Show Gist options
  • Save Hrissimir/091494b7d0994d6abe4388066065adee to your computer and use it in GitHub Desktop.
Save Hrissimir/091494b7d0994d6abe4388066065adee to your computer and use it in GitHub Desktop.
Instructions: How to install and configure 'yt-dlp' on Windows 10 machine
# =========================================================================
# Instructions: How to install and configure 'yt-dlp' on Windows 10 machine
#
# NOTE: Lines starting with # are treated as comments
# -------------------------------------------------------------------------
#
#
# =========================================================================
# Part I. "Install Prerequisites"
# -------------------------------------------------------------------------
#
# 1. Download https://github.com/yt-dlp/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-win64-gpl.zip
# - Extract it to "C:\Programs\ffmpeg-master-latest-win64-gpl"
# - Add "C:\Programs\ffmpeg-master-latest-win64-gpl\bin" to PATH
# 2. Download https://github.com/wez/atomicparsley/releases/latest
# - Extract it to "C:\Programs\AtomicParsleyWindows"
# - Add "C:\Programs\AtomicParsleyWindows" to PATH
# 3. Download https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-windows.zip
# - Extract it to "C:\Programs\phantomjs-2.1.1-windows"
# - Add "C:\Programs\phantomjs-2.1.1-windows\bin" to PATH
# 4. Open CMD as Administrator and run (without the quotes):
# - "rundll32 sysdm.cpl,EditEnvironmentVariables"
# - In the "system variables" section (at the bottom), click New and add the following environment-variables:
# - HOME=%USERPROFILE%
# - WORKON_HOME=%USERPROFILE%\.virtualenvs
# - Edit the PATH path variable by appending the following value (without the quotes): "%USERPROFILE%\bin"
# - Click OK to save the changes
# - Close CMD
# 5. Open CMD as Administrator and run (without the quotes):
# - "gpedit.msc"
# - The "Local Group Policy Editor" will be opened
# - Navigate to "Computer Configuration" > "Administrative Templates" > "System" > "Filesystem"
# - Double click the "Enable NTFS long paths" policy
# - Set the radio-button to "Enabled" , then click Apply and OK
# - Close the "Local Group Policy Editor"
# - Close CMD
# 6. Open CMD as Administrator and run (without the quotes):
# - "regedit.exe"
# - Navigate to "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem"
# - Double-click "LongPathsEnabled" > set the value to "1" (without quotes) and click OK
# - Close regedit
# - Close CMD
# - Reboot the PC
#
#
# =========================================================================
# Part II. "Install Python3.9+"
# -------------------------------------------------------------------------
#
# 1. Open CMD as Administrator and run (without the quotes):
# - "mkdir C:\python_install"
# - "cd /D C:\python_install"
# - "curl -O https://www.python.org/ftp/python/3.9.13/python-3.9.13-amd64.exe"
# - The installer will be downloaded to "C:\python_install\python-3.9.13-amd64.exe"
# - Close CMD
# 2. Create file "C:\python_install\unattend.xml" and paste-in the following contents:
# <Options>
# <Option Name="InstallAllUsers" Value="1" />
# <Option Name="AssociateFiles" Value="0" />
# <Option Name="CompileAll" Value="0" />
# <Option Name="PrependPath" Value="1" />
# <Option Name="Shortcuts" Value="1" />
# <Option Name="Include_doc" Value="1" />
# <Option Name="Include_debug" Value="1" />
# <Option Name="Include_dev" Value="1" />
# <Option Name="Include_exe" Value="1" />
# <Option Name="Include_launcher" Value="0" />
# <Option Name="Include_lib" Value="1" />
# <Option Name="Include_pip" Value="1" />
# <Option Name="Include_symbols" Value="0" />
# <Option Name="Include_tcltk" Value="1" />
# <Option Name="Include_test" Value="1" />
# <Option Name="Include_tools" Value="1" />
# </Options>
# - Remove the # from the beginning of each line, save the changes and close the file
# 3. Open CMD as Administrator and run (without the quotes):
# - "cd /D C:\python_install"
# - "python-3.9.13-amd64.exe /passive"
# - Wait for the installation to complete
# - If prompted, click "Disable Windows PATH limit"
# - Close CMD
# 4. Open CMD as Administrator and run (without the quotes):
# - "python -m pip install --upgrade pip"
# - Close CMD
# 5. Open CMD as Administrator and run (without the quotes):
# - "pip3 install --upgrade setuptools wheel build tzdata virtualenv pipenv"
# - Close CMD
# 6. Open CMD as Administrator and run (without the quotes):
# - "pip3 install --upgrade certifi brotli websockets mutagen pycryptodomex secretstorage pyinstaller py2exe"
# - "rmdir /Q /S C:\python_install"
# - Close CMD
#
#
# =========================================================================
# Part III. "Install yt-dlp"
# -------------------------------------------------------------------------
#
# 1. Open CMD as Administrator and run (without the quotes):
# - "pip3 install --upgrade yt-dlp"
# - Close CMD
# 2. Open CMD as normal user and run (without the quotes):
# - "echo %USERPROFILE%\yt-dlp.conf"
# - Location similar to "C:\User\YOUR_USERNAME_HERE\yt-dlp.conf" will be printed
# - Create the yt-dlp.conf file at the printed location
# - Paste-in the current file's contents, then save the changes and close the file
# 3. Confirm the file was saved correctly by running the following command in CMD (without the quotes):
# - "type %USERPROFILE%\yt-dlp.conf"
# - The file contents should be printed
# - Close CMD
# 4. Confirm you are able to download video files:
# - Open CMD as normal user and run (without the quotes): "yt-dlp https://www.youtube.com/watch?v=F_7baOCYg-Q"
# - The .MP4 file should be created in your Videos directory
# - Close CMD
# 5. Confirm you are able to download audio files:
# - Open CMD as normal user and run (without the quotes): "yt-dlp -x https://www.youtube.com/watch?v=WrjwGPb0Hvw"
# - The .MP3 file should be created in your Videos directory
# - Close CMD
# 6. (Optional) Create file "%USERPROFILE%\bin\dlv.cmd"
# - Paste-in the following contents (remove # from beginning of each line):
# @echo off
# yt-dlp -P "~/Videos" -o "%%(title)s.%%(ext)s" %*
# @echo on
# - Save the changes and close the file
# - Now if you want to download video files, open CMD and run "dlv LINK_TO_VIDEO"
# - The MP4 video file will be saved in your Videos directory
# 7. (Optional) Create file "%USERPROFILE%\bin\dla.cmd"
# - Paste-in the following contents (remove # from beginning of each line):
# @echo off
# yt-dlp --extract-audio -P "~/Music" -o "%%(title)s.%%(ext)s" %*
# @echo on
# - Save the changes and close the file
# - Now if you want to download audio files, open CMD and run "dla LINK_TO_VIDEO"
# - The MP3 audio file will be saved in your Music directory
#
# -------------------------------------------------------------------------
# For more info and detailed instructions: https://github.com/yt-dlp/yt-dlp
# -------------------------------------------------------------------------
# =============== yt-dlp configuration starts below this line ==================
#============================== Verbosity ======================================
# Show progress bar, even if in quiet mode
--progress
# Do not download the video and do not write anything to disk
# --simulate
# Print various debugging information
# --verbose
#=============================== Download ======================================
# Save all videos under you user's Videos directory
--output "~/Videos/%(title)s.%(ext)s"
# Set the output format.
# Details: https://github.com/yt-dlp/yt-dlp#format-selection
# Examples: https://github.com/yt-dlp/yt-dlp#format-selection-examples
--format bestvideo+bestaudio/best
# Download only the video, if the URL refers to a video and a playlist
--no-playlist
# Download the playlist, if the URL refers to a video and a playlist
# When using this, you also have to change the --output value accordingly
# For example: --output "~/Videos/%(playlist)s/%(title)s-%(id)s.%(ext)s"
# --yes-playlist
# Number of fragments of a dash/hlsnative video that should be downloaded concurrently (default is 1)
--concurrent-fragments 1
# Number of retries (default is 10), or "infinite"
--retries 20
# Number of times to retry on file access error (default is 3), or "infinite"
--file-access-retries 20
# Number of retries for a fragment (default is 10), or "infinite" (DASH, hlsnative and ISM)
--fragment-retries 20
# Number of retries for known extractor errors (default is 3), or "infinite"
--extractor-retries 20
# Size of download buffer, e.g. 1024 or 16K (default is 1024)
--buffer-size 32k
#============================= Post-Processing =================================
# Uncomment this or pass '-x' from the command line to exctract the audio and delete the video file afterwards
# Convert video files to audio-only files (requires ffmpeg and ffprobe)
# --extract-audio
# Format to convert the audio to when -x is used. (currently supported: best (default), aac, alac, flac, m4a, mp3, opus, vorbis, wav).
# You can specify multiple rules using similar syntax as --remux-video
--audio-format mp3
# Specify ffmpeg audio quality to use when converting the audio with -x.
# Insert a value between 0 (best) and 10 (worst) for VBR or a specific bitrate like 128K (default 5)
--audio-quality 0
# Uncomment to keep the intermediate video file on disk after post-processing when --extract-audio was passed
# --keep-video
# Containers that may be used when merging formats, separated by "/", e.g. "mp4/mkv".
# Ignored if no merge is required. (currently supported: avi, flv, mkv, mov, mp4, webm)
--merge-output-format mp4
# Remux the video into another container if necessary
# Currently supported: avi, flv, gif, mkv, mov, mp4, webm, aac, aiff, alac, flac, m4a, mka, mp3, ogg, opus, vorbis, wav).
# If target container does not support the video/audio codec, remuxing will fail. You can specify multiple rules;
# e.g. "aac>m4a/mov>mp4/mkv" will remux aac to m4a, mov to mp4 and anything else to mkv
# --remux-video mp4
# Re-encode the video into another format if necessary.
# The syntax and supported formats are the same as --remux-video
--recode-video mp4
# Add chapter markers to the video file (Alias: --add-chapters)
# --embed-chapters
# Embed metadata to the video file.
# Also embeds chapters/infojson if present unless --no-embed-chapters/--no-embed-info-json are used (Alias: --add-metadata)
# --embed-metadata
#================================ Netwrok ======================================
# Make all connections via IPv4
--force-ipv4
# Make all connections via IPv6
# --force-ipv6
# Enable file:// URLs. This is disabled by default for security reasons.
# --enable-file-urls
# Use the specified HTTP/HTTPS/SOCKS proxy.
# To enable SOCKS proxy, specify a proper scheme, e.g. socks5://user:[email protected]:1080/.
# Pass in an empty string (--proxy "") for direct connection
# --proxy URL
# Time to wait before giving up, in seconds
--socket-timeout 30
# Client-side IP address to bind to
# --source-address IP
# Netscape formatted file to read cookies from and dump cookie jar in
# --cookies /path/to/cookies/file.txt.
#### In order to extract cookies from browser use any conforming browser extension for exporting cookies.
#### For example:
#### 'Get cookies.txt' (for Chrome) https://chrome.google.com/webstore/detail/get-cookiestxt/bgaddhkoddajcdgocldbbfleckgcbcid/
#### 'cookies.txt' (for Firefox) https://addons.mozilla.org/en-US/firefox/addon/cookies-txt/
#### NOTE: the cookies file must be in Mozilla/Netscape format and
#### the first line of the cookies file must be either # HTTP Cookie File or # Netscape HTTP Cookie File.
#### Make sure you have correct newline format in the cookies file and convert newlines if necessary to correspond with your OS, namely
#### CRLF (\r\n) for Windows and LF (\n) for Unix and Unix-like systems (Linux, macOS, etc.).
#### HTTP Error 400: Bad Request when using --cookies is a good sign of invalid newline format.
#### How do I pass cookies to youtube-dl? use the--cookies option, for example
# The name of the browser to load cookies from.
# Currently supported browsers are: brave, chrome, chromium, edge, firefox, opera, safari, vivaldi.
# Optionally, the KEYRING used for decrypting Chromium cookies on Linux, the name/path of the PROFILE to load cookies from, and the CONTAINER name (if Firefox) ("none" for no container) can be given with their respective seperators.
# By default, all containers of the most recently accessed profile are used. Currently supported keyrings are: basictext, gnomekeyring, kwallet, kwallet5, kwallet6
# --cookies-from-browser BROWSER[+KEYRING][:PROFILE][::CONTAINER]
#============================== Filesystem =====================================
# File containing URLs to download ("-" for stdin), one URL per line.
# Lines starting with "#", ";" or "]" are considered as comments and ignored
# --batch-file FILE
# Do not use the Last-modified header to set the file modification time
--no-mtime
# Restrict filenames to only ASCII characters, and avoid "&" and spaces in filenames
--restrict-filenames
# Force filenames to be Windows-compatible
--windows-filenames
# Limit the filename length (excluding extension) to the specified number of characters
--trim-filenames 256
# Overwrite all video and metadata files. This option includes --no-continue
# --force-overwrites
# Write video description to a .description file
# --write-description
# Write video metadata to a .info.json file (this may contain personal information)
# --write-info-json
# Write playlist metadata in addition to the video metadata when using --write-info-json, --write-description etc. (default)
# --write-playlist-metafiles
# Retrieve video comments to be placed in the infojson.
# The comments are fetched even without this option if the extraction is known to be quick (Alias: --get-comments)
# --write-comments
# Location in the filesystem where yt-dlp can store some downloaded information (such as client ids and signatures) permanently.
# By default ${XDG_CACHE_HOME}/yt-dlp
# --cache-dir DIR
# Disable filesystem caching
# --no-cache-dir
# Delete all filesystem cache files
# --rm-cache-dir
#============================= Thumbnails ======================================
# Embed thumbnail in the video as cover art
--embed-thumbnail
# Write thumbnail image to disk
# --write-thumbnail
# Write all thumbnail image formats to disk
# --write-all-thumbnails
# Convert the thumbnails to another format (currently supported: jpg, png, webp).
# You can specify multiple rules using similar syntax as --remux-video
# --convert-thumbnails png
# List available thumbnails of each video. Simulate unless --no-simulate is used
# --list-thumbnails
#================================ Subs =========================================
# Write subtitle file
# --write-subs
# Write automatically generated subtitle file (Alias: --write-automatic-subs)
# --write-auto-subs
# Languages of the subtitles to download (can be regex) or "all" separated by commas, e.g. --sub-langs "en.*,ja".
# You can prefix the language code with a "-" to exclude it from the requested languages, e.g. --sub-langs all,-live_chat.
# Use --list-subs for a list of available language tags
# --sub-langs "bg.*,en"
# Subtitle format; accepts formats preference, e.g. "srt" or "ass/srt/best"
# --sub-format "srt/best"
# Convert the subtitles to another format (currently supported: ass, lrc, srt, vtt) (Alias: --convert-subtitles)
# --convert-subs srt
# Embed subtitles in the video (only for mp4, webm and mkv videos)
# --embed-subs
#============================ Authentication ===================================
# Login with this account ID
# --username USERNAME
# Account password. If this option is left out, yt-dlp will ask interactively
# --password PASSWORD
# Two-factor authentication code
# --twofactor TWOFACTOR
# Use .netrc authentication data
# --netrc
# Location of .netrc authentication data; either the path or its containing directory. Defaults to ~/.netrc
# --netrc-location PATH
# Command to execute to get the credentials for an extractor.
# --netrc-cmd NETRC_CMD
# Video password (vimeo, youku)
# --video-password PASSWORD
# Path to client certificate file in PEM format. May include the private key
# --client-certificate CERTFILE
# Path to private key file for client certificate
# --client-certificate-key KEYFILE
# Password for client certificate private key, if encrypted. If not provided, and the key is encrypted, yt-dlp will ask interactively
# --client-certificate-password PASSWORD
# Adobe Pass multiple-system operator (TV provider) identifier, use --ap-list-mso for a list of available MSOs
# --ap-mso MSO
# Multiple-system operator account login
# --ap-username USERNAME
# Multiple-system operator account password. If this option is left out, yt-dlp will ask interactively
# --ap-password PASSWORD
# List all supported multiple-system operators
# --ap-list-mso
# More info available at: https://github.com/yt-dlp/yt-dlp#authentication-options
#============================== Workarounds ====================================
# Explicitly allow HTTPS connection to servers that do not support RFC 5746 secure renegotiation
# --legacy-server-connect
#### Suppress HTTPS certificate validation
# --no-check-certificate
#### Use an unencrypted connection to retrieve information about the video. (Currently supported only for YouTube)
# --prefer-insecure
# Specify a custom HTTP header and its value, separated by a colon ":". You can use this option multiple times
# --add-headers FIELD:VALUE
# Work around terminals that lack bidirectional text support. Requires bidiv or fribidi executable in PATH
# --bidi-workaround
# Number of seconds to sleep between requests during data extraction
# --sleep-requests SECONDS
# Number of seconds to sleep before each download. This is the minimum time to sleep when used along with --max-sleep-interval (Alias: --min-sleep-interval)
# --sleep-interval SECONDS
# Maximum number of seconds to sleep. Can only be used along with --min-sleep-interval
# --max-sleep-interval SECONDS
# Number of seconds to sleep before each subtitle download
# --sleep-subtitles SECONDS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment