Repository navigation
Passing Youtube cookies doesn't seem to work; cookies are being invalidated quickly #8227
Description
Activity
This has also happened to me. It usually happens when I download a member-only video of a certain channel, and the cookies of yt-dlp often expire, and it will prompt that member permissions are required.
Like this
ERROR: [youtube] IIqoefSX61U: This video is available to this channel's members on level: Lifeano Premium (or any higher level). Join this channel to get access to members-only content and other exclusive perks.- addedsite-bugIssue with a specific websiteIssue with a specific websiteneeds-investigatingNeeds research, information is welcomeNeeds research, information is welcomeand removedquestionQuestionQuestion
on Nov 3, 2023 I'm noticing this too. Will need some investigation.
I suspect there might have been a change where active requests in the browser are causing cookies to be replemised.
I'm noticing this too. Will need some investigation.
I suspect there might have been a change where active requests in the browser are causing cookies to be replemised.
I first tried to export cookies and use --cookies "%~dp0\cookies.txt" to specify cookies, but after a few minutes, it became invalid. When I downloaded member-only videos, it prompted me to need a higher level. permission.
Later, I used the --cookies-from-browser firefox parameter and logged in to YouTube in the browser. Everything worked fine at first, but after a few minutes to dozens of minutes, the same cookie failure occurred.
Reacted by SCZwangxiao and EnverexI'm noticing this too. Will need some investigation.
I suspect there might have been a change where active requests in the browser are causing cookies to be replemised.
I also tried adding a plug-in to firefox to automatically refresh the page, but it also didn't work.
If this is a new mechanism added by YouTube, then maybe a function needs to be added,
For example, re-obtain cookies from the browser when downloading each playlist and video.Reacted by César M. Freites and Richard WintersFrom a quick look: the browser appears to be calling
https://accounts.youtube.com/RotateCookiesPage?origin=https://www.youtube.com&yt_pid=1. This runs another javascript rube goldberg machine to transform a value akin to nsig. It then callshttps://accounts.youtube.com/RotateCookieswith that transformed value which refreshes the cookies.I'm guessing this is required or else the cookies are invalidated by YouTube if they are not refreshed.
We could attempt to implement this, but, I don't think its really feasible or worthwhile to maintain.
Probably better off spending that time implementing oauth support for YouTube.
Reacted by Andrew Gibson and rayanamukamiReacted by Fuan- addedhelp-wantedExtra attention is neededExtra attention is neededaccount-neededAccount details are needed to test/fix thisAccount details are needed to test/fix this
on Nov 4, 2023 From a quick look: the browser appears to be calling
https://accounts.youtube.com/RotateCookiesPage?origin=https://www.youtube.com&yt_pid=1. This runs another javascript rube goldberg machine to transform a value akin to nsig. It then callshttps://accounts.youtube.com/RotateCookieswith that transformed value which refreshes the cookies.I'm guessing this is required or else the cookies are invalidated by YouTube if they are not refreshed.
We could attempt to implement this, but, I don't think its really feasible or worthwhile to maintain.
Probably better off spending that time implementing oauth support for YouTube.
A simple workaround would be to generate the cookies file in an incognito window, where the cookies are never used again in browser and therefore will never be rotated.
A few weeks ago, I saw this workaround somewhere (without knowing why) and tried it out. And my cookies file is still valid until now.
Reacted by coletdjnz, Nao Nakashima, Disfinder Root, rayanamukami, Pavel, UFO Sightings App: Reports & Map, Doan Tran and piman31422 remaining items
I found a very strange bug, I have two accounts. Both have exported the cookie from private mode as instructed above. But one of them is very durable, I've been using it for almost two months, and did a lot of downloads without invalidating. However, the other account only downloaded a few videos, and it was invalid within a few hours. I want to know if it's because the durable cookie was exported from Chrome, and I also usually log in to this YouTube account on Chrome, whereas the other not durable one is because, although I also exported the cookie from Chrome, I usually use the Opera browser for that YouTube account.
Reacted by FuanI used to rely on cookie files that worked for months after export, but then cookies were expiring within an hour or less of exporting them recently
Right now, I'm dumping metadata from channels and it gives me the "Sign in" error minutes after (also because I was downloading anonymously just before and getting rate limited)- linked a pull request that will close this issue[ie/youtube] Add support for logging in with OAuth2 #11001
on Sep 14, 2024 I don't know if NVidia scandal is related to it. YouTube service might do this to limit such downloads. Also it's possible that YouTube has some kind of server side heuristic to give a cookie appropriate expiration time. I don't know if yt-dlp might to do anything with it.
I'd guess that this cookie rotation is actually intended to protect their users from cookie stealing
Reacted by Eir Nym- changed the title
[-]Youtube cookies expire within hours[/-][+]Passing Youtube cookies seems to not be working; cookies are being invalidated within hours/minutes/seconds[/+]on Oct 22, 2024 - changed the title
[-]Passing Youtube cookies seems to not be working; cookies are being invalidated within hours/minutes/seconds[/-][+]Passing Youtube cookies seems to not be working; cookies are being invalidated within minutes[/+]on Oct 22, 2024 - changed the title
[-]Passing Youtube cookies seems to not be working; cookies are being invalidated within minutes[/-][+]Passing Youtube cookies seems to not be working; cookies are being invalidated quickly[/+]on Oct 22, 2024 - changed the title
[-]Passing Youtube cookies seems to not be working; cookies are being invalidated quickly[/-][+]Passing Youtube cookies doesn't seem to work; cookies are being invalidated quickly[/+]on Oct 24, 2024 Since logging in with OAuth2 is gone, and cookies extracted from an incognito session still expire after a certain period of time, would implementing Cookie rotation now be the reliable way to prolong the login state?
Reacted by Justin Stanley, Chris Francy, mouarflenoob, Jared Burrows, Ivashka37, Uma Nandyala and d0verennyThe issue persists to this day... Can't downloads vids without cookies -- and cookies keep rotating like crazy. It's not even an hour passes till they expire...
Please, consider reopenning the issue.
The issue persists to this day... Can't downloads vids without cookies -- and cookies keep rotating like crazy. It's not even an hour passes till they expire...
Please, consider reopenning the issue.
See https://github.com/yt-dlp/yt-dlp/wiki/Extractors#exporting-youtube-cookies
- locked and limited conversation to collaborators
on Dec 28, 2024
DO NOT REMOVE OR SKIP THE ISSUE TEMPLATE
Checklist
Please make sure the question is worded well enough to be understood
I have been used to youtube coookies lasting a couple of weeks. But since a few weeks I have to update the cookies for yt-dlp daily.
Does anyone know what is happening here?
My guess is that youtube change its policies. If that is the case, is there a way to automate the process?
My current "workflow":
Provide verbose output that clearly demonstrates the problem
yt-dlp -vU <your command line>)'verbose': TruetoYoutubeDLparams instead[debug] Command-line config) and insert it belowComplete Verbose Output
[debug] Command-line config: ['-vU'] [debug] Encodings: locale UTF-8, fs utf-8, pref UTF-8, out utf-8, error utf-8, screen utf-8 [debug] yt-dlp version stable@2023.09.24 [088add956] (pip) [debug] Python 3.11.5 (CPython armv7l 32bit) - Linux-5.10.63-v7+-armv7l-with-glibc2.28 (OpenSSL 1.1.1n 15 Mar 2022, glibc 2.28) [debug] exe versions: ffmpeg 4.1.11-0, ffprobe 4.1.11-0 [debug] Optional libraries: Cryptodome-3.19.0, brotli-1.1.0, certifi-2023.07.22, mutagen-1.47.0, sqlite3-3.27.2, websockets-11.0.3 [debug] Proxy map: {} [debug] Loaded 1886 extractors [debug] Fetching release info: https://api.github.com/repos/yt-dlp/yt-dlp/releases/latest Available version: stable@2023.09.24, Current version: stable@2023.09.24 yt-dlp is up to date (stable@2023.09.24)