This repository contains a plugin package that adds support for logging into YouTube with OAuth2 to yt-dlp's YouTube Extractors.
Please note: This is experimental and may break at any time!!.
Requires yt-dlp 2023.10.13
or above.
If yt-dlp is installed through pip
or pipx
, you can install the plugin with the following:
pip:
python3 -m pip install -U https://github.com/coletdjnz/yt-dlp-youtube-oauth2/archive/refs/heads/master.zip
pipx:
pipx inject yt-dlp https://github.com/coletdjnz/yt-dlp-youtube-oauth2/archive/refs/heads/master.zip
If you have not installed yt-dlp through pip or pipx, see installing yt-dlp plugins for the other methods this plugin package can be installed.
Enable logging in with OAuth2 with --username oauth2 --password ''
.
Alternatively, if you only want to apply this for the YouTube extractor, you can add the following to a .netrc file:
machine youtube login oauth2 password ""
On first run you will be prompted to authorize yt-dlp to access your YouTube account.
[youtube+oauth2] To give yt-dlp access to your account, go to https://www.google.com/device and enter code XXX-YYY-ZZZ
Open the link in your browser and enter the code. It will say the request is for YouTube on TV - this is normal, as we are using the YouTube on TV client for oauth ;)
The token data is saved in the yt-dlp cache.
Note: avoid running with YouTube cookies, as it may cause issues.