summaryrefslogtreecommitdiffstats
path: root/gallery_dl/cloudflare.py
diff options
context:
space:
mode:
authorLibravatarUnit 193 <unit193@gmail.com>2020-05-03 00:06:40 -0400
committerLibravatarUnit 193 <unit193@gmail.com>2020-05-03 00:06:40 -0400
commit90e50db2e3c38f523bb5195d295290b06e5cedb0 (patch)
tree4759dc0faea79f83fa5074e2d0bd82b18a9caaea /gallery_dl/cloudflare.py
parentd5b96ce44b7809f5ae01e3e9d70a1d58fe21ccf5 (diff)
New upstream version 1.13.6upstream/1.13.6
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,
}