aboutsummaryrefslogtreecommitdiffstats
path: root/gallery_dl/cloudflare.py
diff options
context:
space:
mode:
authorLibravatarUnit 193 <unit193@gmail.com>2020-05-03 00:06:41 -0400
committerLibravatarUnit 193 <unit193@gmail.com>2020-05-03 00:06:41 -0400
commitf5a2f273c0ccfac264ddfd45384dadfe25d9d7a5 (patch)
tree92f4a00290fc49d27badcde094910f7a5bb8f783 /gallery_dl/cloudflare.py
parent6979a952d58bb018e3636276f141ae28c4599143 (diff)
parent90e50db2e3c38f523bb5195d295290b06e5cedb0 (diff)
Update upstream source from tag 'upstream/1.13.6'
Update to upstream version '1.13.6' with Debian dir 56019140fd27c135929da929f616e2bc3456deb9
Diffstat (limited to 'gallery_dl/cloudflare.py')
-rw-r--r--gallery_dl/cloudflare.py24
1 files changed, 15 insertions, 9 deletions
diff --git a/gallery_dl/cloudflare.py b/gallery_dl/cloudflare.py
index e3ebd1a..43ccdeb 100644
--- a/gallery_dl/cloudflare.py
+++ b/gallery_dl/cloudflare.py
@@ -144,11 +144,15 @@ def evaluate_expression(expr, page, netloc, *,
# evaluate them,
# and accumulate their values in 'result'
result = ""
- for subexpr in split_re.findall(expr) or (expr,):
- result += str(sum(
- VALUES[part]
- for part in subexpr.split("[]")
- ))
+ for subexpr in expr.strip("+()").split(")+("):
+ value = 0
+ for part in subexpr.split("+"):
+ if "-" in part:
+ p1, _, p2 = part.partition("-")
+ value += VALUES[p1] - VALUES[p2]
+ else:
+ value += VALUES[part]
+ result += str(value)
return int(result)
@@ -158,12 +162,14 @@ OPERATORS = {
"*": operator.mul,
}
+
VALUES = {
"": 0,
- "+": 0,
- "!+": 1,
- "!!": 1,
- "+!!": 1,
+ "!": 1,
+ "[]": 0,
+ "!![]": 1,
+ "(!![]": 1,
+ "(!![])": 1,
}