Nandaka / PixivUtil2

Download images from Pixiv and more!
http://nandaka.devnull.zone/
BSD 2-Clause "Simplified" License
2.4k stars 254 forks source link

Login/Download Issues see here (Oct-20) #814

Open NHOrus opened 4 years ago

NHOrus commented 4 years ago

Edited by @Nandaka: Please follow this step first

https://github.com/Nandaka/PixivUtil2/wiki#pixiv-login-using-cookie

https://github.com/Nandaka/PixivUtil2/wiki#fanbox-login-using-cookie

Prerequisites

Description

Trying to start PixivUtil to get pictures, connection fails

Steps to Reproduce

Start up configured PixivUtil2

Expected behavior:

Program starts normally, downloads work

Actual behavior:

Cannot Login! press enter to exit

2020-10-14 09:01:16,420 - PixivUtil20201009-beta1 - INFO - ###############################################################
2020-10-14 09:01:16,420 - PixivUtil20201009-beta1 - INFO - Starting with argument: [E:\conf\pixiv\pixivutil\PixivUtil2.exe].
2020-10-14 09:01:16,423 - PixivUtil20201009-beta1 - INFO - Setting log level to: DEBUG
2020-10-14 09:01:16,423 - PixivUtil20201009-beta1 - INFO - No default cookie jar available, creating... 
2020-10-14 09:01:16,565 - PixivUtil20201009-beta1 - INFO - Using default DB Path: E:\conf\pixiv\pixivutil\db.sqlite
2020-10-14 09:01:16,567 - PixivUtil20201009-beta1 - INFO - Using Username: nhorus
2020-10-14 09:01:16,567 - PixivUtil20201009-beta1 - INFO - Trying to log in with saved cookie
2020-10-14 09:01:16,765 - PixivUtil20201009-beta1 - ERROR - Error at doLogin(): (<class 'mechanize._response.get_seek_wrapper_class.<locals>.httperror_seek_wrapper'>, <httperror_seek_wrapper (urllib.error.HTTPError instance) at 0x41b9fa0 whose wrapped object = <HTTPError 403: 'Forbidden'>>, <traceback object at 0x041E3148>)
2020-10-14 09:01:16,767 - PixivUtil20201009-beta1 - ERROR - Traceback (most recent call last):
  File "PixivUtil2.py", line 1077, in doLogin
    last_image_id = -1
  File "PixivBrowserFactory.pyc", line 317, in loginUsingCookie
  File "PixivBrowserFactory.pyc", line 206, in open_with_retry
  File "mechanize\_mechanize.pyc", line 253, in open
  File "mechanize\_mechanize.pyc", line 309, in _mech_open
mechanize._response.get_seek_wrapper_class.<locals>.httperror_seek_wrapper: HTTP Error 403: Forbidden

2020-10-14 09:01:16,767 - PixivUtil20201009-beta1 - ERROR - Cannot Login!
2020-10-14 09:01:16,768 - PixivUtil20201009-beta1 - ERROR - Traceback (most recent call last):
  File "PixivUtil2.py", line 1077, in doLogin
    last_image_id = -1
  File "PixivBrowserFactory.pyc", line 317, in loginUsingCookie
  File "PixivBrowserFactory.pyc", line 206, in open_with_retry
  File "mechanize\_mechanize.pyc", line 253, in open
  File "mechanize\_mechanize.pyc", line 309, in _mech_open
mechanize._response.get_seek_wrapper_class.<locals>.httperror_seek_wrapper: HTTP Error 403: Forbidden

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "PixivUtil2.py", line 1278, in main
    parsed_page = BeautifulSoup(page.read().decode("utf-8"), features="html5lib")
  File "PixivUtil2.py", line 1084, in doLogin
    raise
PixivException.PixivException: 0 Cannot Login!, hasDumpPage=N, pageData=None

Versions

You can get this information from executing PixivUtil2.py --help. Latest version available in https://github.com/Nandaka/PixivUtil2/releases

RighteousAnger commented 4 years ago

I just got this recently also, from the latest PixivDownloader

Error at doLogin(): (<class 'mechanize._response.get_seek_wrapper_class..httperror_seek_wrapper'>, <httperror_seek_wrapper (urllib.error.HTTPError instance) at 0x4282d60 whose wrapped object = <HTTPError 403: 'Forbidden'>>, <traceback object at 0x04292A68>) Cannot Login!

gnarf1975 commented 4 years ago

I have the same problem

Error at doLogin(): (<class 'mechanize._response.get_seek_wrapper_class..httperror_seek_wrapper'>, <httperror_seek_wrapper (urllib.error.HTTPError instance) at 0x3835bb0 whose wrapped object = <HTTPError 403: 'Forbidden'>>, <traceback object at 0x03864968>) Cannot Login!

kody180 commented 4 years ago

Same problem here too.

Error at doLogin(): (<class 'mechanize._response.get_seek_wrapper_class..httperror_seek_wrapper'>, <httperror_seek_wrapper (urllib.error.HTTPError instance) at 0x3b60778 whose wrapped object = <HTTPError 403: 'Forbidden'>>, <traceback object at 0x03B6F0C8>) Cannot Login!

Nandaka commented 4 years ago

Maybe because of this, Pixiv want you to change your password? image

Also, update your cookie again, looks like the format changed.

Works fine after changing my password and updating the cookie. image

polujm9 commented 4 years ago

Same problem.

I had tried change PHPSESSID and not working.

Nandaka commented 4 years ago

@polujm9 try to update your password in pixiv website and try to match the useragent value with your browser.

jwshields commented 4 years ago

Changing my password on the website and updating my config with the new PW, PHPSESSID, and UA appear to have fixed this for me. Edit: FWIW, I did not receive anything from Pixiv that would have prompted me/suggested that I should change my password.

polujm9 commented 4 years ago

Changing Password works for me.

Tarried commented 4 years ago

Changing password, changing session, none of that worked for me. I ended up creating a new account, and that worked just fine.

Interestingly the new session ID was shorter since it wasn't preceded by '10XXXXXX_'.

todesschnitzel commented 4 years ago

Same error here too. I changed my PW, PHPSESSID and User Agent, but i still get the error:

Error at doLogin(): (<class 'mechanize._response.get_seek_wrapper_class..httperror_seek_wrapper'>, <httperror_seek_wrapper (urllib.error.HTTPError instance) at 0x3bf03d0 whose wrapped object = <HTTPError 403: 'Forbidden'>>, <traceback object at 0x03BE95C8>) Cannot Login!

I also gone through this: https://github.com/Nandaka/PixivUtil2/issues/505

Anything else i can try?

skyvory commented 4 years ago

I logged in and the prompt to change password appears, so I changed with that and updated the cookie (which formatted differently) and it works again. Maybe try to logout and login back and see if the prompt appears. Perhaps a simple password change if you're already logged in wouldn't work. Can't guarantee though as I didn't try it myself.

pxssy commented 4 years ago

Did not get prompt to change password. Changed nonetheless, new cookie, does not work. :(

ItaloKnox commented 4 years ago

Didn't get the prompt, but changing the password worked. Added the new cookie and password to the config and it worked just as always. Back to pulling from multiple instances at once with no issues.

fanboy01 commented 4 years ago

I have the same problem like everyone above.

From the looks of it, it seems the solutions seem to be hit or miss,

Unfortunately, none of the solutions worked for me.

Tried changing password and updating the cookie and user agent - no luck

Hell, I tried making a new account and that didn't work either.

Hamuko commented 4 years ago

I also got it to work by changing my Pixiv password and then updating my configuration with the new password, new cookie and current user agent.

Baramanga commented 4 years ago

I got the same problem: Error at doLogin(): (<class 'mechanize._response.get_seek_wrapper_class.<locals>.httperror_seek_wrapper'>, <httperror_seek_wrapper (urllib.error.HTTPError instance) at 0x3e7b3d0 whose wrapped object = <HTTPError 403: 'Forbidden'>>, <traceback object at 0x03E81AC8>) Cannot Login! and changing password doesn't work

ee092884 commented 4 years ago

I currently test out a way to download in full mode normally When you change the password and play this screen, use F12 to directly view the new PHPSESSID Can change the same password Don’t go to the pixiv homepage to check the PHPSESSID Will not display the number of ID "XXXXXXX" but only the command line after EDIT: also check your browser user-agent to match with config.ini image

Current solution

viravera commented 4 years ago

Same issue. I've done the following:

logged out and back in. No prompt to change password. Updated cookie/useragent Changed password Updated cookie/useragent again no luck; problem persists.

The error I get is the same as the others: Error at doLogin(): (<class 'mechanize._response.get_seek_wrapper_class.<locals>.httperror_seek_wrapper'>, <httperror_seek_wrapper (urllib.error.HTTPError instance) at 0x7f8fa3adae18 whose wrapped object = <HTTPError 403: 'Forbidden'>>, <traceback object at 0x7f8fa3929348>) Cannot Login!

DisasterInbound commented 4 years ago

I'm adding my comment here with the same issue and the previous steps didn't work:

-Logged out and back in (I was not prompted to make any password change)

i don't want to create a new account so I didn't do that.

Error code: 'Error at doLogin(): (<class 'mechanize._response.get_seek_wrapper_class..httperror_seek_wrapper'>, <httperror_seek_wrapper (urllib.error.HTTPError instance) at 0x3717a48 whose wrapped object = <HTTPError 403: 'Forbidden'>>, <traceback object at 0x03734768>) Cannot Login!'

bluerthanever commented 4 years ago

20201015014409 I managed to save the page retrieved in doLogin and it turns out to be as the picture above shows. Looks like they put more effort in anti-scraping.

bluerthanever commented 4 years ago

it seems to be cloudflare.... geez. I hate cloudflare.

aksskl commented 4 years ago

@polujm9 try to update your password in pixiv website and try to match the useragent value with your browser.

Worked for me using v20201009-beta1 and I used Chrome 86.0.4240.75 to get my PHPSESSID value

First I changed my password and PHPSESSID cookie value to see if that alone would work. It did not.

Then used this site (https://www.whatismybrowser.com/detect/what-is-my-user-agent) to detect my useragent and replaced whatever was in the config.ini WORKED

RighteousAnger commented 4 years ago

@polujm9 try to update your password in pixiv website and try to match the useragent value with your browser.

Worked for me using v20201009-beta1 and I used Chrome 86.0.4240.75 to get my PHPSESSID value

First I changed my password and PHPSESSID cookie value to see if that alone would work. It did not.

Then used this site (https://www.whatismybrowser.com/detect/what-is-my-user-agent) to detect my useragent and replaced whatever was in the config.ini WORKED

Hit or miss for sure... using v20201009-beta1 and I used Chrome 86.0.4240.75 (Latest) I go to Pixiv website to change password with no prompt encountered Put in my new password along with the new cookie using Chrome in the config and logged out Headed over to detected my useragent and copy what was there and replaced in the config Open up the downloader and still same error results...I also tried on two different accounts, no avail. (Giving me the same error) Something must've changed recently no...?

Kotters commented 4 years ago

I managed to get it working again. I had no prompt to change my password, but doing so provided me with a new PHPSESSID that is in a new format. The old format had 6 digits and an underscore prepended (######_RestOfID). The new format does not.

Note that I had previously attempted setting a matching useragent and logging out and in to generate a new PHPSESSID. Before I changed my password, it simply gave me a new PHPSESSID in the old format, which did not work.

maxiy01 commented 4 years ago

Changed password, updated cookie, logged out. Problem persists.

AgentThirteen commented 4 years ago

Keeping the SESSID unique auth token (the part that is after the underscore) and removing your user ID as well as the underscore will allow you to log in just fine, for now at least. You'll still have to manually provide your user ID to PixivUtil for this to work. I suspect this is part of #807 as user IDs classify as trackable information but @bluerthanever raised a valid concern with the verification process. pixiv probably didn't even think ahead nor test it at all as usual.

I cannot guarantee this will help solve the issue as I tried both a rather old release and the latest one, both run into #817 when trying to download something. Nothing seems to generate the new format or any prompt for that matter, no matter the browser, method or password complexity so for now stuck with this like everyone else encountering it.

If someone manages to grab a link to the password change prompt, maybe that would also force reformat the stored cookie instead of pushing the ID to force a manual check which is what seems to be happening.

bluerthanever commented 4 years ago

Ok. I didn't do any test yesterday. But here is what I did, and I have no problem for now.

  1. Deleted all cookie in browser with extension, not logging out (not sure if there are any differences)
  2. Logged in again in browser, somehow this time they asked for recaptcha, and password update.
  3. Updated the new PHPSESSID in config.in and viola.

Edit: Didn't try out any of the menu items yet. And the new PHPSESSID seems to be in new format as well.

walrus263 commented 4 years ago

Changed password and re-login Updated the new PHPSESSID in config.in Updated user agent Problem persists.

Nandaka commented 4 years ago

try to login in incognito mode? ensure the new cookie value doesn't have _ in it (e.g. 189000_abcdefghijkalmnoxxxx <- old version)

todesschnitzel commented 4 years ago

I can't get it to work. Tried to export the cookie through different browsers, even android but still get one with an underscore (e.g. 189000abcdefghijkalmnoxxxx). If i remove the "189000" from the cookie i get

Trying to log in with saved cookie Login successful. Unable to get User Id, please check your cookie.

Also changed the User Agent, but it doesn't seem to matter, at least on my side... I already changed my PW, didn't get me a "good" cookie.

DisasterInbound commented 4 years ago

try to login in incognito mode? ensure the new cookie value doesn't have _ in it (e.g. 189000_abcdefghijkalmnoxxxx <- old version)

I managed to make it work. I tried to log in with another browser and instead of getting the old "xxxxx_xxxxxxxxx" format, I got a new one "xxxxxxxxxxxxxx".

I pasted it and it was able to log in.

maxiy01 commented 4 years ago

try to login in incognito mode? ensure the new cookie value doesn't have _ in it (e.g. 189000_abcdefghijkalmnoxxxx <- old version)

Logged in incognito mode. New cookie still contains numbers with _ .

walrus263 commented 4 years ago

Changed password and re-login Updated the new PHPSESSID in config.in Updated user agent Problem persists.

Changed password and re-login Updated the new PHPSESSID in config.in Updated user agent Problem persists.

Don't know why, but suddenly my browser shows rightful cookie which I tried to get but couldn't and problem solved

Nandaka commented 4 years ago

@maxiy01 do you also change your password?

maxiy01 commented 4 years ago

@maxiy01 do you also change your password?

I did.

Nandaka commented 4 years ago

weird, then I can only suggest to keep on retrying until you get the new cookie....

Lesmiscore commented 4 years ago

Changing password and re-login worked for me. Probably Pixiv is doing A/B tests?

fanboy01 commented 4 years ago

Maybe I got lucky but when I changed my password again, the PHPSESSID value was in the new format! (didn't have 100000_ at the start)

I updated the new PHPSESSID in config.ini and now everything is working fine for me.

Hope some of you guys can get this thing working again. Good luck.

AgentThirteen commented 4 years ago

@fanboy01, @nao20010128nao, @Nandaka Nailed it, that does look like A/B tests. Changed password again and again with more and more entropy and complexity, disabled all extensions just to make sure and it eventually gave me a properly formatted cookie (for the main domain) without the user ID in incognito mode. Unfortunately, even after forcing a relog, FANBOX still has the old format (different domains) so this will likely ask for a captcha verification behind the scenes, fail it and pass a 403.

No prompt whatsoever, did not touch the default PixivUtil user agent. I guess you literally have to keep changing passwords and make sure you wipe the pixiv security alerts from new, unknown logins. Pixiv, what are you doing this time, trying to cause massive information leaks while pretending to abide to privacy regulations? :facepalm:

edit: You can keep the old format (with the user ID and the underscore) for FANBOX, just make sure you properly relog using a persistent session.

Flandre5carlet commented 4 years ago

Tried a whole lot of things (changing password, using another browser, updating the user agent, so on so forth). Was always given an old format cookie that wouldn't work at all and gave me the error.

In the end I managed to make it work by just manually removing the numbers and underscore at the start of the PHPSESSID for the Pixiv cookie, and leaving the FANBOX cookie as is. Both Pixiv and FANBOX downloads work.

todesschnitzel commented 4 years ago

Just like @AgentThirteen said, it seems that a really complex password will give you a "good" cookie. At least it also worked for me.

OniiGokko commented 4 years ago

Tried it with a super complex password and still no good ,still got the old cookieformat... Oh well back to the drawing board..

Flandre5carlet commented 4 years ago

Follow-up to my previous comment: FANBOX downloads work flawlessly, Pixiv downloads worked twice but now give me a JSONDecodeError similar to issue #816 when trying to parse the artist's page. Logging in still works perfectly fine though.

ee092884 commented 4 years ago

2020/11/04 has changed back to the old format of cookies

I currently test out a way to download in full mode normally When you change the password and play this screen, use F12 to directly view the new PHPSESSID Can change the same password Don’t go to the pixiv homepage to check the PHPSESSID Will not display the number of ID "XXXXXXX" but only the command line after EDIT: also check your browser user-agent to match with config.ini

image

AgentThirteen commented 4 years ago

@todesschnitzel @OniiGokko @ee092884 Oh wow. Thanks for the input. Don't bother with user agent or changing other settings in PixivUtil (older versions work fine), this literally is all hit or miss upon cookie reset. I was even wondering if a password change had anything to do with it at all at this point and spamming login/logout until it generates a proper cookie would work as well. Do they really want to cause a CloudShadowFlare with that kind of approach?

@FlandreScarlet I guess that's because PixivUtil cannot detect your user ID if you use that approach for the main domain - you should be getting Unable to detect user ID instead of My user ID: *. FANBOX still uses the old format, at least at the moment, and for some unknown reason, so it isn't affected when bypassing this way. Everything will work fine if you manage to reset the main cookie as well.

somepasta commented 4 years ago

Can confirm that @ee092884 method works. You basically get a new PHPSESSID the moment you change your password. However, I could check for the new cookie value on any page from pixiv, including the homepage. It remains the same as long as you stay logged in after the password change.

But an annoying problem still persists; if you log out for some reason and attempt to log in again, the PHPSESSID will revert back to the old format, requiring you to change your password again every time you try to access your account.

Flandre5carlet commented 4 years ago

Can confirm it works as well - also, this might be important for people who are reluctant to update their password: you don't have to actually CHANGE your password. You can literally set your current password as a new password, and the password "change" will go through and you will get a proper PHPSESSID cookie as indicated by @ee092884's method.

If I log out from the website and log back in, my cookie reverts to the old format and PixivUtil doesn't manage to detect my user ID anymore. However, if I don't log out, then the cookie remains in the proper format even on the main website, and PixivUtil detects my user ID properly. This does include fully closing the browser if you have persistent session enabled; a full restart of my computer and the cookie was still good on the website and PixivUtil was fine. The only thing that broke it was a full log out.

MaronayruJyugo commented 4 years ago

I had 2 of the exact same issues described here. However I came here because I had my own, though much less feature rich and written in C++, tool to handle my pixiv downloads etc. I use libcurl but don't do any logging in, my only login feature is using the PHPSESSID by grabbing it directly from the browser cookie database. The error that started showing up yesterday was the "Verification required" captcha failure posted by @bluerthanever above.

Upon despair I stumbled my way here and tried out PixivUtil2, also getting the same error "Error at doLogin(): (<class 'mechanize._response.get_seek_wrapper_class..httperror_seek_wrapper'> ...." as posted by others above.

Thanks a lot for finding out that updated cookie! I already tried everything from deleting the whole cookie database of my browser, to creating a new account while using a VPN to make sure there are no problems with my account / IP. Nothing worked. However, after changing my password I found the new PHPSESSID format on the "password changed confirmation page" and my tool also works again with this. Hopefully there won't be more changes .. manually using pixiv without tools is some order of magnitudes more timewaste with all the lag and nested pages, I pray I never have to go back to that.

Note my password before changing was already very complex, i.e. more than 20 digits using lowercase, uppercase, alphanumerics and symbols, so I can't confirma "weak" password being the trigger. I also never got any prompts to change it. I had however not changed it in years.

maxiy01 commented 4 years ago

Yay! Changing password to "super complex" one did the trick.

willyer commented 4 years ago

I currently test out a way to download in full mode normally When you change the password and play this screen, use F12 to directly view the new PHPSESSID Don’t go to the pixiv homepage to check the PHPSESSID Will not display the number of ID "XXXXXXX" but only the command line after

It's working! Thanks ^^