Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
4 of 6 tasks
mesozoic-technology opened this issue Dec 24, 2024 · 6 comments
Open
4 of 6 tasks

Comments

@mesozoic-technology
Copy link

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
@dirkf
Copy link
Contributor

dirkf commented 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
Copy link
Contributor

dirkf commented Dec 25, 2024

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

@mesozoic-technology
Copy link
Author

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.

@dirkf
Copy link
Contributor

dirkf commented 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.

@wellsyw
Copy link

wellsyw commented 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...

@dirkf
Copy link
Contributor

dirkf commented 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 up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants