diff options
| author | 2024-09-28 20:01:25 -0400 | |
|---|---|---|
| committer | 2024-09-28 20:01:25 -0400 | |
| commit | 1a457ed68769880ab7760e0746f0cbbd9ca00487 (patch) | |
| tree | a5e2f36fa6537e24a7a8851dab900ea03efdbd00 /gallery_dl/cookies.py | |
| parent | 1f3ffe32342852fd9ea9e7704022488f3a1222bd (diff) | |
New upstream version 1.27.5.upstream/1.27.5
Diffstat (limited to 'gallery_dl/cookies.py')
| -rw-r--r-- | gallery_dl/cookies.py | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/gallery_dl/cookies.py b/gallery_dl/cookies.py index deb7c7b..0ffd29a 100644 --- a/gallery_dl/cookies.py +++ b/gallery_dl/cookies.py @@ -50,21 +50,27 @@ def load_cookies_firefox(cookiejar, profile=None, container=None, domain=None): sql = ("SELECT name, value, host, path, isSecure, expiry " "FROM moz_cookies") - parameters = () + conditions = [] + parameters = [] if container_id is False: - sql += " WHERE NOT INSTR(originAttributes,'userContextId=')" + conditions.append("NOT INSTR(originAttributes,'userContextId=')") elif container_id: - sql += " WHERE originAttributes LIKE ? OR originAttributes LIKE ?" + conditions.append( + "originAttributes LIKE ? OR originAttributes LIKE ?") uid = "%userContextId={}".format(container_id) - parameters = (uid, uid + "&%") - elif domain: + parameters += (uid, uid + "&%") + + if domain: if domain[0] == ".": - sql += " WHERE host == ? OR host LIKE ?" - parameters = (domain[1:], "%" + domain) + conditions.append("host == ? OR host LIKE ?") + parameters += (domain[1:], "%" + domain) else: - sql += " WHERE host == ? OR host == ?" - parameters = (domain, "." + domain) + conditions.append("host == ? OR host == ?") + parameters += (domain, "." + domain) + + if conditions: + sql = "{} WHERE ( {} )".format(sql, " ) AND ( ".join(conditions)) set_cookie = cookiejar.set_cookie for name, value, domain, path, secure, expires in db.execute( |
