Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix a bug that conversion '!t' may not working #3747

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions gallery_dl/formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@ def __getitem__(key):
"s": str,
"r": repr,
"a": ascii,
"i": util.remove_invisible_chars_strip,
}
_FORMAT_SPECIFIERS = {
"?": _parse_optional,
Expand Down
7 changes: 7 additions & 0 deletions gallery_dl/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import functools
import itertools
import subprocess
import unicodedata
import urllib.parse
from http.cookiejar import Cookie
from email.utils import mktime_tz, parsedate_tz
Expand Down Expand Up @@ -210,6 +211,12 @@ def to_string(value):
return str(value)


def remove_invisible_chars_strip(text):
"""Remove all invisible characters from 'text' then strip"""
return "".join(c for c in text if unicodedata.category(c)[0] != "C")\
.strip()


def datetime_to_timestamp(dt):
"""Convert naive UTC datetime to timestamp"""
return (dt - EPOCH) / SECOND
Expand Down