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

Some optimizations #1052

Merged
merged 4 commits into from
Nov 22, 2021
Merged

Some optimizations #1052

merged 4 commits into from
Nov 22, 2021

Conversation

bluerthanever
Copy link
Contributor

For details please refer to each commits.

1. Added method `stringNotEmpty` to replace lambdas in `ConfigItem`s' `restrictions` with
2. Made `proxy` a property, in which `proxyAddress` would be checked (adding scheme, returning None if not legal, etc.)
Added lines to set `proxy` and `verify` of `PixivOAuthBrowser` with given parameters when initializing `PixivOAuth` objects.
1. Added a global variable `session` for requests
2. Added methods `set_proxy` and `set_verify` to set `proxies` and `verify` of the `session`
3. Changed requests made with `requests` to `session`
@bluerthanever
Copy link
Contributor Author

I didn't put cases where a user uses proxies with domains instead of ips into consideration...
so if a user uses proxies with domains, the regular expression pattern needs to be changed.

PixivConfig.py Outdated
value = getattr(self, "proxyAddress", None)
if not value:
return None
match = re.match(r"^(?:(http|socks[45])://)?(\d+\.\d+\.\d+\.\d+):(\d+)$", value)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe can use this pattern ^(https|http|socks[45])://[\w.]+(:?\d*)$
image

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated to allow - = ^(https|http|socks[45])://[\w.-]+(:?\d*)$
image

@Nandaka Nandaka merged commit d09bf5f into Nandaka:master Nov 22, 2021
@PatrickL546 PatrickL546 mentioned this pull request Nov 23, 2021
3 tasks
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.

2 participants