diff options
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, |
