diff options
| author | 2020-10-25 17:59:22 -0400 | |
|---|---|---|
| committer | 2020-10-25 17:59:22 -0400 | |
| commit | 5dc7d6f5902ddaee5223d041d5c10060f0c72430 (patch) | |
| tree | 6ddd103a86ea7bbb0d695f5fdfa55e43f04756ca /gallery_dl/util.py | |
| parent | e0c914765184ebbf99cffdecfe8cdbe10f42486e (diff) | |
New upstream version 1.15.2.upstream/1.15.2
Diffstat (limited to 'gallery_dl/util.py')
| -rw-r--r-- | gallery_dl/util.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/gallery_dl/util.py b/gallery_dl/util.py index 3e91405..d85d2b3 100644 --- a/gallery_dl/util.py +++ b/gallery_dl/util.py @@ -13,6 +13,7 @@ import os import sys import json import time +import random import shutil import string import _string @@ -60,6 +61,10 @@ def raises(cls): return wrap +def generate_csrf_token(): + return random.getrandbits(128).to_bytes(16, "big").hex() + + def combine_dict(a, b): """Recursively combine the contents of 'b' into 'a'""" for key, value in b.items(): @@ -490,6 +495,7 @@ class Formatter(): - "u": calls str.upper - "c": calls str.capitalize - "C": calls string.capwords + - "t": calls str.strip - "U": calls urllib.parse.unquote - "S": calls util.to_string() - Example: {f!l} -> "example"; {f!u} -> "EXAMPLE" @@ -520,6 +526,7 @@ class Formatter(): "u": str.upper, "c": str.capitalize, "C": string.capwords, + "t": str.strip, "U": urllib.parse.unquote, "S": to_string, "s": str, |
