Nandaka / PixivUtil2

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

Fanbox can't use proxy #996

Closed photonometric closed 2 years ago

photonometric commented 3 years ago

I recently have played with setups from VPN back to a SSL socks proxy, and discovered that the fanbox options don't connect when useproxy = True and a socks5 proxy is enabled (and the core pixivutil2 functions work fine).

Here's the screen output:

Input: f2 Artist/Creator IDs = <> End page = Member IDs: ['<>'] Reading C:\Programs\pixivutil20210702\config.ini ... Configuration loaded. Trying to log in FANBOX with saved cookie

1 2 3 4 1 2 3 4 1 2 3 4 Error at open_with_retry(): (, URLError(GeneralProxyError()), ) Not logged in to FANBOX, trying to update FANBOX cookie... 1 2 3 4

and the pixivutil.log output:

2021-08-07 11:36:02,868 - PixivUtil20210702 - INFO - Logging in, return url: https://www.pixiv.net/en/ 2021-08-07 11:36:02,869 - PixivUtil20210702 - INFO - Login successful. 2021-08-07 11:36:02,870 - PixivUtil20210702 - INFO - Logged in using cookie 2021-08-07 11:36:02,871 - PixivUtil20210702 - INFO - My User Id: <>. 2021-08-07 11:36:02,871 - PixivUtil20210702 - INFO - Premium User: True. 2021-08-07 11:36:02,871 - PixivUtil20210702 - INFO - Locale = /en 2021-08-07 11:36:04,427 - PixivUtil20210702 - INFO - Download FANBOX by Artist or Creator ID mode (f2). 2021-08-07 11:36:08,448 - PixivUtil20210702 - INFO - Member IDs: ['<>'] 2021-08-07 11:36:08,467 - PixivUtil20210702 - INFO - Trying to log in FANBOX with saved cookie 2021-08-07 11:46:54,321 - PixivUtil20210702 - ERROR - Error at open_with_retry(): (<class 'urllib.error.URLError'>, URLError(GeneralProxyError()), <traceback object at 0x036C8648>) 2021-08-07 11:46:54,323 - PixivUtil20210702 - ERROR - Traceback (most recent call last): File "socks.pyc", line 809, in connect File "socks.pyc", line 443, in _negotiate_SOCKS5 File "socks.pyc", line 524, in _SOCKS5_request File "socks.pyc", line 278, in _readall socks.GeneralProxyError: Connection closed unexpectedly

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "mechanize_urllib2_fork.pyc", line 1229, in do_open File "http\client.pyc", line 1257, in request File "http\client.pyc", line 1303, in _send_request File "http\client.pyc", line 1252, in endheaders File "http\client.pyc", line 1012, in _send_output File "http\client.pyc", line 952, in send File "http\client.pyc", line 1419, in connect File "http\client.pyc", line 923, in connect File "socket.pyc", line 843, in create_connection File "socket.pyc", line 831, in create_connection File "socks.pyc", line 47, in wrapper File "socks.pyc", line 814, in connect socks.GeneralProxyError: Socket error: Connection closed unexpectedly

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "PixivBrowserFactory.pyc", line 206, in open_with_retry File "mechanize_mechanize.pyc", line 257, in open File "mechanize_mechanize.pyc", line 287, in _mech_open File "mechanize_opener.pyc", line 193, in open File "mechanize_urllib2_fork.pyc", line 425, in _open File "mechanize_urllib2_fork.pyc", line 414, in _call_chain File "mechanize_urllib2_fork.pyc", line 1276, in https_open File "mechanize_urllib2_fork.pyc", line 1233, in do_open urllib.error.URLError:

2021-08-07 11:46:54,323 - PixivUtil20210702 - ERROR - Error at fanboxLoginUsingCookie(): (<class 'PixivException.PixivException'>, PixivException('Failed to get page: <Request for https://www.fanbox.cc>, please check your internet connection/firewall/antivirus.'), <traceback object at 0x037137E8>) 2021-08-07 11:46:54,324 - PixivUtil20210702 - INFO - Not logged in to FANBOX, trying to update FANBOX cookie...

I guess the proxy function is probably not used by a ton of people, but is useful if you want to use some kind of proxy but don't/can't use it for every single internet program (like some banking or commercial sites will block or flag as fraud, depending on what kind of proxy is used).

bluerthanever commented 3 years ago

looks similar to #993 should be fixed in next release? or you can fill in the cookiefanbox in configuration manually and give it another try. edit: sorry i was just looking at the last part....

not sure if it's universal but sock5 proxy doesn't go with python on my side. try using http proxies?

photonometric commented 3 years ago

not sure if it's universal but sock5 proxy doesn't go with python on my side. try using http proxies?

Hmm not sure what this means. I've used the socks5 capability of pixivutil off and on for about 8 years now (through a local port SSH tunneled to a remote proxy server or VPS). Just confirmed it works perfectly with the newest version and latest updated python on windows 10. So I'm not sure what about python would not be working with socks5 for you? And in general it's a very old standard and would definitely be a capibility of any serious programming language.

Again, not a programmer, but my assumption would be that your fanbox code would access the internet "through" the larger PixivUtil2 program, since it operates within its general settings and obviously while it's running etc. But it seems like it is perhaps trying to access the internet directly, while the wider PixivUtil (with useproxy = True) is only allowing access through the proxy it is configured for? And thus an error. Just a clumsy guess, but seems obvious something of that sort is happening with only the Fanbox internet connections.

bluerthanever commented 3 years ago

Hmm not sure what this means. I've used the socks5 capability of pixivutil off and on for about 8 years now (through local port SSH tunnel to remote proxy server or VPS). Just confirmed it works perfectly with the newest version and latest updated python on windows 10. So I'm not sure what about python would not be working with socks5 for you?

actually i have used proxy5 with pixivutil2 for some time as well. but i forgot if it's after i had changed my vpn vendor or that pixivutil2 had changed from python2.x to 3.x, it stopped working so well. maybe it's a server thing, cuz i think most of the time if i want to use socks5 proxies with pixivutil2 i need to open Simple DNSCrypt, but in browsers it's totally fine without, no error had ever happened whatsoever.

not sure, maybe your assumption is correct. but i am using v2rayN which provides a http port which works fine.... so...

also, maybe try Simple DNSCrypt?