overwrites my cookie file... and also tells me that I need to sign in? #27017

Open
opened 2026-02-21 14:36:04 -05:00 by deekerman · 6 comments
Owner

Originally created by @mesozoic-technology on GitHub (Dec 24, 2024).

Checklist

  • I'm reporting a broken site support issue
  • I've verified that I'm running youtube-dl version 2021.12.17
  • I've checked that all provided URLs are alive and playable in a browser
  • I've checked that all URLs and arguments with special characters are properly quoted or escaped
  • I've searched the bugtracker for similar bug reports including closed ones
  • I've read bugs section in FAQ

Verbose log

ERROR: [youtube] a07qXFXjEDI: Sign in to confirm you’re not a bot. Use --cookies-from-browser or --cookies for the authentication. See  https://github.com/yt-dlp/yt-dlp/wiki/FAQ#how-do-i-pass-cookies-to-yt-dlp  for how to manually pass cookies. Also see  https://github.com/yt-dlp/yt-dlp/wiki/Extractors#exporting-youtube-cookies  for tips on effectively exporting YouTube cookies

Description

I know this may look like broken site support, but it also overwrites my cookie file, which seems like a bug. I start with a cookie file I take from my browser that has quite a lot in it, but after I run it, the cookie file is completely different and very small.
Here is my code

    url = f"https://www.youtube.com/watch?v={video_id}"
    options = { 
        'quiet': True,
         cookiefile': "cookies.txt"
    }
    try:
        with YoutubeDL(options) as ydl:

            info_dict = ydl.extract_info(url, download=False)
            print("info_dict", info_dict)

    except Exception as e:
        print("Error", e)
        return jsonify({"status": "error", "message": str(e)}), 500
Originally created by @mesozoic-technology on GitHub (Dec 24, 2024). <!-- ###################################################################### WARNING! IGNORING THE FOLLOWING TEMPLATE WILL RESULT IN ISSUE CLOSED AS INCOMPLETE ###################################################################### --> ## Checklist <!-- Carefully read and work through this check list in order to prevent the most common mistakes and misuse of youtube-dl: - First of, make sure you are using the latest version of youtube-dl. Run `youtube-dl --version` and ensure your version is 2021.12.17. If it's not, see https://yt-dl.org/update on how to update. Issues with outdated version will be REJECTED. - Make sure that all provided video/audio/playlist URLs (if any) are alive and playable in a browser. - Make sure that all URLs and arguments with special characters are properly quoted or escaped as explained in http://yt-dl.org/escape. - Search the bugtracker for similar issues: http://yt-dl.org/search-issues. DO NOT post duplicates. - Read bugs section in FAQ: http://yt-dl.org/reporting - Finally, put x into all relevant boxes (like this [x]) --> - [x] I'm reporting a broken site support issue - [x] I've verified that I'm running youtube-dl version **2021.12.17** - [x] I've checked that all provided URLs are alive and playable in a browser - [x] I've checked that all URLs and arguments with special characters are properly quoted or escaped - [ ] I've searched the bugtracker for similar bug reports including closed ones - [ ] I've read bugs section in FAQ ## Verbose log ``` ERROR: [youtube] a07qXFXjEDI: Sign in to confirm you’re not a bot. Use --cookies-from-browser or --cookies for the authentication. See https://github.com/yt-dlp/yt-dlp/wiki/FAQ#how-do-i-pass-cookies-to-yt-dlp for how to manually pass cookies. Also see https://github.com/yt-dlp/yt-dlp/wiki/Extractors#exporting-youtube-cookies for tips on effectively exporting YouTube cookies ``` ## Description I know this may look like broken site support, but it also overwrites my cookie file, which seems like a bug. I start with a cookie file I take from my browser that has quite a lot in it, but after I run it, the cookie file is completely different and very small. Here is my code ``` url = f"https://www.youtube.com/watch?v={video_id}" options = { 'quiet': True, cookiefile': "cookies.txt" } try: with YoutubeDL(options) as ydl: info_dict = ydl.extract_info(url, download=False) print("info_dict", info_dict) except Exception as e: print("Error", e) return jsonify({"status": "error", "message": str(e)}), 500 ```
Author
Owner

@dirkf commented on GitHub (Dec 25, 2024):

#22069: yt-dl treats the cookie file like a browser would, refreshing the cookie store. You can keep a copy of the original exported cookie file (but cookies won't be refreshed, so more likely to be expired on next use). Setting the file as read-only provokes an error.

For the bot-ty part of the issue see #32960.

@dirkf commented on GitHub (Dec 25, 2024): #22069: _yt-dl_ treats the cookie file like a browser would, refreshing the cookie store. You can keep a copy of the original exported cookie file (but cookies won't be refreshed, so more likely to be expired on next use). Setting the file as read-only provokes an error. For the bot-ty part of the issue see #32960.
Author
Owner

@dirkf commented on GitHub (Dec 25, 2024):

Also, please use the latest nightly release per #30839.

@dirkf commented on GitHub (Dec 25, 2024): Also, please use the latest nightly release per #30839.
Author
Owner

@mesozoic-technology commented on GitHub (Dec 25, 2024):

Are you saying it is refreshing the cookie store because youtube is invalidating the cookies on request? Then I suppose they have updated their policy, because this was working about a month and a half ago and is no longer.

@mesozoic-technology commented on GitHub (Dec 25, 2024): Are you saying it is refreshing the cookie store because youtube is invalidating the cookies on request? Then I suppose they have updated their policy, because this was working about a month and a half ago and is no longer.
Author
Owner

@dirkf commented on GitHub (Dec 25, 2024):

If the site sends new cookies or the existing ones expire, those changes are reflected in the cookie file. We don't do anything to make this happen or not, other than .load the file initially into a specialised MozillaCookieJar (from the Python library) and .save it on exit.

It's entirely possible that YT has changed cookie policies since there seems to be a lot of other breakage. The #32960 part of the issue may be connected: the bot-detection bot could be seeing your cookies and invalidating them as part of the message to force you into the app or website.

@dirkf commented on GitHub (Dec 25, 2024): If the site sends new cookies or the existing ones expire, those changes are reflected in the cookie file. We don't do anything to make this happen or not, other than `.load` the file initially into a specialised `MozillaCookieJar` (from the Python library) and `.save` it on exit. It's entirely possible that YT has changed cookie policies since there seems to be a lot of other breakage. The #32960 part of the issue may be connected: the bot-detection bot could be seeing your cookies and invalidating them as part of the message to force you into the app or website.
Author
Owner

@wellsyw commented on GitHub (Dec 26, 2024):

Admittedly I was also taken aback by the behaviour, that it updates/overwrites my cookie file. It seems like a very unnatural thing to do, that it should have a specific option to allow overwriting, but at this point it's probably impossible to change.

Basically I crafted a cookie file with expiry dates far into the future only to find them cut to a tiny fraction of what they were...

@wellsyw commented on GitHub (Dec 26, 2024): Admittedly I was also taken aback by the behaviour, that it updates/overwrites my cookie file. It seems like a very unnatural thing to do, that it should have a specific option to allow overwriting, but at this point it's probably impossible to change. Basically I crafted a cookie file with expiry dates far into the future only to find them cut to a tiny fraction of what they were...
Author
Owner

@dirkf commented on GitHub (Dec 26, 2024):

An exact case where stashing a copy of the custom file before using it would have helped ...

The #22069 behaviour may not have seemed surprising to the original authors, but it could perhaps be noted in the documentation.

@dirkf commented on GitHub (Dec 26, 2024): An exact case where stashing a copy of the custom file before using it would have helped ... The #22069 behaviour may not have seemed surprising to the original authors, but it could perhaps be noted in the documentation.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/youtube-dl-ytdl-org#27017
No description provided.