updated README

This commit is contained in:
Matthew Broadway 2021-07-11 16:34:20 +01:00
parent 135aab91b2
commit 0b87e6e7e3
No known key found for this signature in database
GPG Key ID: DDC0B82B6896B381

View File

@ -276,6 +276,13 @@ Alternatively, refer to the [developer instructions](#developer-instructions) fo
info-json" option) info-json" option)
--cookies FILE File to read cookies from and dump --cookies FILE File to read cookies from and dump
cookie jar in cookie jar in
--cookies-from-browser BROWSER Load cookies from a user profile of the
given web browser: brave, chrome,
chromium, edgefirefox, opera, safari,
vivaldi. You can specify an alternative
user profile name or directory using
"BROWSER:PROFILE_NAME" or
"BROWSER:PROFILE_PATH"
--cache-dir DIR Location in the filesystem where --cache-dir DIR Location in the filesystem where
youtube-dl can store some downloaded youtube-dl can store some downloaded
information permanently. By default information permanently. By default
@ -916,14 +923,19 @@ Either prepend `https://www.youtube.com/watch?v=` or separate the ID from the op
### How do I pass cookies to youtube-dl? ### How do I pass cookies to youtube-dl?
Use the `--cookies` option, for example `--cookies /path/to/cookies/file.txt`. If you have access to a web browser, simply log into youtube in the browser and pass `--cookies-from-browser <BROWSER_NAME>` to youtube-dl (see `youtube-dl --help` for supported browsers).
In order to extract cookies from browser use any conforming browser extension for exporting cookies. For example, [Get cookies.txt](https://chrome.google.com/webstore/detail/get-cookiestxt/bgaddhkoddajcdgocldbbfleckgcbcid/) (for Chrome) or [cookies.txt](https://addons.mozilla.org/en-US/firefox/addon/cookies-txt/) (for Firefox).
Note that 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](https://en.wikipedia.org/wiki/Newline) 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.
Passing cookies to youtube-dl is a good way to workaround login when a particular extractor does not implement it explicitly. Another use case is working around [CAPTCHA](https://en.wikipedia.org/wiki/CAPTCHA) some websites require you to solve in particular cases in order to get access (e.g. YouTube, CloudFlare). Passing cookies to youtube-dl is a good way to workaround login when a particular extractor does not implement it explicitly. Another use case is working around [CAPTCHA](https://en.wikipedia.org/wiki/CAPTCHA) some websites require you to solve in particular cases in order to get access (e.g. YouTube, CloudFlare).
#### Passing cookies without a web browser
Warning: be careful with your cookies file as it can be used to gain access to any accounts you are logged into!
If you do not have access to a web browser (e.g. if running headless) then manually extract cookies to a file from a web browser on another machine. There are browser extensions that can do this such as [Get cookies.txt](https://chrome.google.com/webstore/detail/get-cookiestxt/bgaddhkoddajcdgocldbbfleckgcbcid/) (for Chrome) or [cookies.txt](https://addons.mozilla.org/en-US/firefox/addon/cookies-txt/) (for Firefox).
Note that 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](https://en.wikipedia.org/wiki/Newline) 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.
After you have extracted a cookies file, pass it to youtube-dl using the option: `--cookies <path_to_cookies>`
### How do I stream directly to media player? ### How do I stream directly to media player?
You will first need to tell youtube-dl to stream media to stdout with `-o -`, and also tell your media player to read from stdin (it must be capable of this for streaming) and then pipe former to latter. For example, streaming to [vlc](https://www.videolan.org/) can be achieved with: You will first need to tell youtube-dl to stream media to stdout with `-o -`, and also tell your media player to read from stdin (it must be capable of this for streaming) and then pipe former to latter. For example, streaming to [vlc](https://www.videolan.org/) can be achieved with: