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

Cookie import fails with "validated: undefined" #22

Closed
EpicLPer opened this issue Aug 14, 2023 · 16 comments
Closed

Cookie import fails with "validated: undefined" #22

EpicLPer opened this issue Aug 14, 2023 · 16 comments
Labels
help wanted Extra attention is needed

Comments

@EpicLPer
Copy link

Heya,

I just tried importing my cookies and I'm getting the following error inside the browser extension:
image

In the Inspect tab I get the message {"message":{"cookie_import":"fail","cookie_validated":false}}, the network tab tells me a 400 Bad Request occured.

Not sure if I'm doing something wrong (again) tho :)

Thanks already!

@bbilly1
Copy link
Member

bbilly1 commented Aug 17, 2023

Impossible to say without logs what's happening. Probably means invalid cookie? Sometimes doing this from a blank browser can help, where there has always only been one google account used. Or you can also use the manual import.

@bbilly1 bbilly1 added the question Further information is requested label Aug 17, 2023
@DutchEllie
Copy link

I have the same issue, have been having it since forever and always just manually added the cookie, very annoying.
This is the log from when I tried to add the cookie using the extension:

cookie preview:

# Netscape HTTP Cookie File
# https://curl.haxx.se/rfc/cookie_spec.html
# This is a generated file! Do not edit.

.youtube.com    TRUE    /       FALSE   1719579328      SOCS    [REDACTED]
.youtube.com    TRUE    /       TRUE    0       YSC     [REDACTED]
.youtube.com    TRUE    /       FALSE   1720011328      CONSENT [REDACTED]
.youtube.com    TRUE    /       TRUE    1725
cookie: activated and stored in Redis
validating cookie
cookie file is invalid
cookie validation failed, exiting...
cookie: revoked
cookie: {'cookie_import': 'fail', 'cookie_validated': False}
[pid: 44|app: 0|req: 1359/1359] 10.0.0.38 () {64 vars in 1070 bytes} [Thu Aug 17 14:16:03 2023] PUT /api/cookie/ => generated 61 bytes in 101 msecs (HTTP/1.1 400) 9 headers in 357 bytes (1 switches on core 0)

It seems to just send bad data, not actually the full cookies file like it needs.

@bbilly1
Copy link
Member

bbilly1 commented Aug 17, 2023

A cookie is valid, if TA can access your liked videos playlist, e.g. https://www.youtube.com/playlist?list=LL. If it can't access that, it's invalid and revoked as you can see in your output.

One of these cases of works on my machine. If it doesn't work for you, please provide a fix.

@bbilly1 bbilly1 added help wanted Extra attention is needed and removed question Further information is requested labels Aug 17, 2023
@bbilly1
Copy link
Member

bbilly1 commented Aug 17, 2023

very annoying

Please be nice.

@grantterra
Copy link

grantterra commented Sep 3, 2023

I had the same issue.

screenshot1

I compared the original cookies stored in the browser, and it seems that TubeArchivist did not receive the last 54 characters in the cookie value.

image

@3urobeat
Copy link

3urobeat commented Oct 8, 2023

I'm also experiencing this issue for months now.
It did work as expected back in June and then suddenly failed.
Tubearchivist on my server, as well as the browser extension, are on the newest versions.
I have deleted all my YouTube cookies, did a fresh login - also no success.

I'm using LibreWolf Firefox 118.0.1-1 on Linux 6.5.5-arch1-1

Edit: I can confirm the observation by grantterra, the cookie extracted by the extension is too short. After exporting the cookie manually, placing it in the import directory, enabling cookies and reindexing, my playlist it is active again.

@clb92
Copy link

clb92 commented Oct 14, 2023

I'm experiencing this in Chrome, but not in Firefox.

@bbilly1
Copy link
Member

bbilly1 commented Oct 19, 2023

It seems to just send bad data, not actually the full cookies file like it needs.

and

I compared the original cookies stored in the browser, and it seems that TubeArchivist did not receive the last 54 characters in the cookie value.

as well as

I can confirm the observation by grantterra, the cookie extracted by the extension is too short.

you'll see in your log output cookie preview. so what is logged is only the first 200 characters (I think) from the complete cookie. as that is sensitive data, so this shouldn't be logged completely somewhere...

cookie building happens in background.js here: https://github.com/tubearchivist/browser-extension/blob/master/extension/background.js#L209

if anybody wants to investigate further.

@bbilly1
Copy link
Member

bbilly1 commented Nov 10, 2023

Some investigation on the live stream could point towards that we limit our domain selection too much, and that www.youtube.com will get excluded.

notes: https://github.com/Rob--W/cookie-manager/issues/26

some traceback:

/usr/local/lib/python3.11/http/cookiejar.py:2083: UserWarning: http.cookiejar bug!
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/http/cookiejar.py", line 2056, in _really_load
    assert domain_specified == initial_dot
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError

  _warn_unhandled_exception()

@Gentoli
Copy link

Gentoli commented Mar 1, 2024

For me, looks like the extension included a cookie from the subdomain payments.youtube.com and yt-dlp is not happy with that. Removing it from the POST /api/cookie/ works.

Because the validation is done by yt-dlp, before tubearchivist/tubearchivist#669 which would log the error in the console, you could try capturing the cookie file sent by the extension from the extension developer console, then testing it with downloading any youtube video with a noop arg like -F, then it would give error like:

http.cookiejar.LoadError: invalid Netscape format cookies file 'C:\\Users\\<user>\\Desktop\\cookies.txt': 'payments.youtube.com\tTRUE\t/\tFALSE\t1711779732\tOTZ\t<some-value>'

@bbilly1
Copy link
Member

bbilly1 commented Mar 10, 2024

Interesting, would make sense that I can't reproduce this, I probably won't have any payment subdomain cookies if I didn't make any payments on YT. Will ignoring all subdomains work? Or does this need some other processing?

@Gentoli
Copy link

Gentoli commented Mar 10, 2024

Given yt-dlp is rejecting cookies from the subdomains, I think it's safe to remove all subdomains.

@CommanderRedYT
Copy link

I do not have any cookies on subdomains but it still fails. Both on firefox and chrome and with different accounts

@wolrah
Copy link

wolrah commented Mar 27, 2024

I can confirm that removing the payments.youtube.com cookie solved the problem for me.

bbilly1 added a commit that referenced this issue May 1, 2024
@bbilly1
Copy link
Member

bbilly1 commented May 1, 2024

Can somebody who can reproduce this check if the linked commit on the https://github.com/tubearchivist/browser-extension/tree/fix-cookie-domain branch fixes that?

This still syncs the cookie correctly for me.

bbilly1 added a commit that referenced this issue May 11, 2024
@bbilly1
Copy link
Member

bbilly1 commented May 11, 2024

assuming this has been fixed, update to v0.3.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

10 participants