diff options
| author | 2022-08-29 02:17:16 -0400 | |
|---|---|---|
| committer | 2022-08-29 02:17:16 -0400 | |
| commit | a768930761f7f20587ae40a8cacca0e55c85290a (patch) | |
| tree | 5a4163db912b93fc45f717e5e43fd5be3e66f16c /gallery_dl/text.py | |
| parent | ae2a0f5622beaa6f402526f8a7b939419283a090 (diff) | |
New upstream version 1.23.0.upstream/1.23.0
Diffstat (limited to 'gallery_dl/text.py')
| -rw-r--r-- | gallery_dl/text.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/gallery_dl/text.py b/gallery_dl/text.py index 97ef3ac..79cf016 100644 --- a/gallery_dl/text.py +++ b/gallery_dl/text.py @@ -39,6 +39,16 @@ def split_html(txt): return [] +def slugify(value): + """Convert a string to a URL slug + + Adapted from: + https://github.com/django/django/blob/master/django/utils/text.py + """ + value = re.sub(r"[^\w\s-]", "", str(value).lower()) + return re.sub(r"[-\s]+", "-", value).strip("-_") + + def ensure_http_scheme(url, scheme="https://"): """Prepend 'scheme' to 'url' if it doesn't have one""" if url and not url.startswith(("https://", "http://")): |
