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

Handle cookies with an expiry of 0 #586

Closed
wants to merge 1 commit into from
Closed

Handle cookies with an expiry of 0 #586

wants to merge 1 commit into from

Conversation

ImportTaste
Copy link
Contributor

@ImportTaste ImportTaste commented Jan 20, 2020

I could not figure out why gallery-dl would not recognize my DA cookie. After a lot of debugging, I discovered that auth and auth_secure were being discarded because Python's http.cookiejar library considers an expiry of 0 to mean the cookie is expired.

My solution was to pass ignore_expires=True to both the loading and saving of the cookiejar, and simply discarded expired cookies (that don't have an expiry of 0) with a for loop after the load.

@ImportTaste
Copy link
Contributor Author

That apparently didn't fix DeviantArt not being able to snag original images, I just thought it did because it was checking against my download-archive file. I'm getting 404 errors on the download token. Back to the drawing board.

@ImportTaste
Copy link
Contributor Author

ImportTaste commented Jan 20, 2020

Maybe that's a separate issue. I notice that it keeps updating the userinfo field of my cookies file, but not auth and auth_secure. They've always been tied together, so that would invalidate them. For some reason the username of the userinfo cookie in particular is edited out, not sure why.

I'll leave this open for now...

@ImportTaste ImportTaste reopened this Jan 20, 2020
@mikf
Copy link
Owner

mikf commented Jan 20, 2020

There are some more issues concerning Python's MozillaCookiejar's ability to parse cookies.txt files. For example lines beginning with #HttpOnly_ are considered a comment and therefore ignored. I think it'd generally be better to create a subclass of MozillaCookiejar and implement more forgiving load/store operations similar to what youtube-dl has done.

Concerning the whole DeviantArt cookies thing: it's probably best to just create a cookies.txt file yourself (#547 (comment)), fill in the proper values, and maybe increase the expiration timestamps.

@ImportTaste
Copy link
Contributor Author

There are some more issues concerning Python's MozillaCookiejar's ability to parse cookies.txt files. For example lines beginning with #HttpOnly_ are considered a comment and therefore ignored. I think it'd generally be better to create a subclass of MozillaCookiejar and implement more forgiving load/store operations similar to what youtube-dl has done.

Concerning the whole DeviantArt cookies thing: it's probably best to just create a cookies.txt file yourself (#547 (comment)), fill in the proper values, and maybe increase the expiration timestamps.

That is unfortunately beyond my ability. No reason not to merge this in the meantime, though. A lot of cookie exporting plugins for Chrome/Firefox will not export the #Http lines. The main issue with people creating their own cookie file is people won't know what that column means, I had to look it up myself to learn it's an expiry.

On the other hand, until 'basic' authentication is (re?)implemented for DeviantArt, there's no way to actually get valid auth and auth_secure tokens through gallery-dl, thus right now it is basically impossible to download original files.

@mikf mikf closed this in c1a6862 Jan 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants