mirror of
https://github.com/mikf/gallery-dl.git
synced 2024-11-25 04:02:32 +01:00
use 'True if COND else False' for bool conversions
faster than 'bool(COND)', especially on older Pythons < 3.11
This commit is contained in:
parent
c148e200a4
commit
d68bb78f44
@ -74,8 +74,9 @@ def load_cookies_firefox(profile=None, container=None, domain=None):
|
|||||||
cookies = [
|
cookies = [
|
||||||
Cookie(
|
Cookie(
|
||||||
0, name, value, None, False,
|
0, name, value, None, False,
|
||||||
domain, bool(domain), domain.startswith("."),
|
domain, True if domain else False, domain.startswith("."),
|
||||||
path, bool(path), secure, expires, False, None, None, {},
|
path, True if path else False, secure, expires,
|
||||||
|
False, None, None, {},
|
||||||
)
|
)
|
||||||
for name, value, domain, path, secure, expires in db.execute(
|
for name, value, domain, path, secure, expires in db.execute(
|
||||||
sql, parameters)
|
sql, parameters)
|
||||||
@ -157,9 +158,9 @@ def load_cookies_chromium(browser_name, profile=None,
|
|||||||
|
|
||||||
cookies.append(Cookie(
|
cookies.append(Cookie(
|
||||||
0, name, value, None, False,
|
0, name, value, None, False,
|
||||||
domain, bool(domain), domain.startswith("."),
|
domain, True if domain else False, domain.startswith("."),
|
||||||
path, bool(path), secure, expires or None, False,
|
path, True if path else False, secure, expires or None,
|
||||||
None, None, {},
|
False, None, None, {},
|
||||||
))
|
))
|
||||||
|
|
||||||
if failed_cookies > 0:
|
if failed_cookies > 0:
|
||||||
@ -284,7 +285,7 @@ def _safari_parse_cookies_record(data, cookies, host=None):
|
|||||||
record_size = p.read_uint()
|
record_size = p.read_uint()
|
||||||
p.skip(4, "unknown record field 1")
|
p.skip(4, "unknown record field 1")
|
||||||
flags = p.read_uint()
|
flags = p.read_uint()
|
||||||
is_secure = bool(flags & 0x0001)
|
is_secure = True if (flags & 0x0001) else False
|
||||||
p.skip(4, "unknown record field 2")
|
p.skip(4, "unknown record field 2")
|
||||||
domain_offset = p.read_uint()
|
domain_offset = p.read_uint()
|
||||||
name_offset = p.read_uint()
|
name_offset = p.read_uint()
|
||||||
@ -322,9 +323,9 @@ def _safari_parse_cookies_record(data, cookies, host=None):
|
|||||||
|
|
||||||
cookies.append(Cookie(
|
cookies.append(Cookie(
|
||||||
0, name, value, None, False,
|
0, name, value, None, False,
|
||||||
domain, bool(domain), domain.startswith("."),
|
domain, True if domain else False, domain.startswith("."),
|
||||||
path, bool(path), is_secure, expiration_date, False,
|
path, True if path else False, is_secure, expiration_date,
|
||||||
None, None, {},
|
False, None, None, {},
|
||||||
))
|
))
|
||||||
|
|
||||||
return record_size
|
return record_size
|
||||||
|
@ -109,7 +109,7 @@ class CohostUserExtractor(CohostExtractor):
|
|||||||
"projectHandle": self.groups[0],
|
"projectHandle": self.groups[0],
|
||||||
"page": 0,
|
"page": 0,
|
||||||
"options": {
|
"options": {
|
||||||
"pinnedPostsAtTop" : bool(self.pinned),
|
"pinnedPostsAtTop" : True if self.pinned else False,
|
||||||
"hideReplies" : not self.replies,
|
"hideReplies" : not self.replies,
|
||||||
"hideShares" : not self.shares,
|
"hideShares" : not self.shares,
|
||||||
"hideAsks" : not self.asks,
|
"hideAsks" : not self.asks,
|
||||||
|
@ -1301,7 +1301,7 @@ class DeviantartOAuthAPI():
|
|||||||
|
|
||||||
metadata = extractor.config("metadata", False)
|
metadata = extractor.config("metadata", False)
|
||||||
if not metadata:
|
if not metadata:
|
||||||
metadata = bool(extractor.extra)
|
metadata = True if extractor.extra else False
|
||||||
if metadata:
|
if metadata:
|
||||||
self.metadata = True
|
self.metadata = True
|
||||||
|
|
||||||
|
@ -63,7 +63,8 @@ class NozomiExtractor(Extractor):
|
|||||||
yield Message.Directory, post
|
yield Message.Directory, post
|
||||||
for post["num"], image in enumerate(images, 1):
|
for post["num"], image in enumerate(images, 1):
|
||||||
post["filename"] = post["dataid"] = did = image["dataid"]
|
post["filename"] = post["dataid"] = did = image["dataid"]
|
||||||
post["is_video"] = video = bool(image.get("is_video"))
|
post["is_video"] = video = \
|
||||||
|
True if image.get("is_video") else False
|
||||||
|
|
||||||
ext = image["type"]
|
ext = image["type"]
|
||||||
if video:
|
if video:
|
||||||
|
Loading…
Reference in New Issue
Block a user