Ovear / kemono-dl

A simple kemono.party downloader using python.
109 stars 11 forks source link

"ERROR:401 UNAUTHORIZED | Bad cookie file" No matter what I do #8

Closed HHargrave closed 1 year ago

HHargrave commented 1 year ago

Version

Version: 2022.04.28

Your Command


python kemono-dl.py --dirname-pattern "Y:\Downloads\{service}\{username} [{user_id}]" --verbose --cookies "cookies.txt" --kemono-fav-users all

Description of bug

Can't download favourites, all the forks seem to be broken, unless Kemono changed something

How To Reproduce

Do anything (at least on my end)

Error messages and tracebacks


DEBUG:Getting creator json from https://kemono.party/api/creators/
DEBUG:Getting favorite json from https://kemono.party/api/favorites?type=artist
ERROR:401 UNAUTHORIZED | Bad cookie file

Additional comments

I've tried both chrome and firefox cookies.txt extensions, 3 different forks, logging out and back in countless times on both Chrome and Firefox.

debug.log

Ovear commented 1 year ago

I am unable to reproduce in my side. Please check the cookies file you are using.

The session and _pk_id in the cookies are required to perform this operation.

HHargrave commented 1 year ago

I go into storage on browser and all it's giving me is ddg1 and sessioncookies? How to force it to generate _pk_id?

Sorry if dumb question.

Ovear commented 1 year ago

_pk_id usually generated by cdn server of Kemono.

But I tried to reperform this operation by only with session cookie, it also works.

Adjusting uset-agent to the browser you are using may help?

HHargrave commented 1 year ago

_pk_id usually generated by cdn server of Kemono.

I went on a bunch of pages and opened images in full res trying to use the cdn server (If that's how that works) but still nothing except those two

Adjusting uset-agent to the browser you are using may help?

How do you mean?

Ovear commented 1 year ago

Oh, I forgot user-agent switch function has not been implemented yet.

Can you open https://kemono.party/api/favorites?type=artist in the browser that you are using to export cookies to see if still get 401 Unauthorized error?

HHargrave commented 1 year ago

That works, shows me the JSON contents

Ovear commented 1 year ago

Hmm, that's weried.

I have added an extra log that outputs the cookie that kemono-dl loaded. Please try https://github.com/ovear/kemono-dl/tree/cookie_log and see if all cookies, especially session, are loaded.

Please also make sure the loaded cookies are same as that in the file(and browser).

HHargrave commented 1 year ago

DEBUG:Cookie loaded: <MozillaCookieJar[]>
DEBUG:Getting creator json from https://kemono.party/api/creators/
DEBUG:Getting favorite json from https://kemono.party/api/favorites?type=artist
ERROR:401 UNAUTHORIZED | Bad cookie file

All it says with the Firefox "Cookies.txt" extension

The Chrome cookies are better


DEBUG:Cookie loaded: <MozillaCookieJar[<Cookie __ddg1_=notshowingmycookieslol for .kemono.party/>, <Cookie session=notshowingmycookiesagainlol for www.kemono.party/>]>
DEBUG:Getting creator json from https://kemono.party/api/creators/
DEBUG:Getting favorite json from https://kemono.party/api/favorites?type=artist
ERROR:401 UNAUTHORIZED | Bad cookie file

Session cookie value is identical to one shown on browser

HHargrave commented 1 year ago
# Netscape HTTP Cookie File
# http://curl.haxx.se/rfc/cookie_spec.html
# This is a generated file!  Do not edit.

.kemono.party   TRUE    /   FALSE   1716227850  __ddg1_ value
www.kemono.party    FALSE   /   FALSE   1687286671  session value

Also posting a censored copy of my cookies.txt in case something is just obviously wrong with the export

Ovear commented 1 year ago

Oh, gotcha. Please login kemono with https://kemono.party, not www one, and then export cookie again should work.

In this case, you may also edit cookies.txt to change www.kemono.party to kemono.party

HHargrave commented 1 year ago

Oh, my bad, works now. Sorry if it says somewhere to do that >.<

Thank you!

Ovear commented 12 months ago

This issue should be improved in the latest version. It will convert cookie domain automatically now.