diff --git a/docs/formatting.md b/docs/formatting.md
index 7adfee88..72cf0bed 100644
--- a/docs/formatting.md
+++ b/docs/formatting.md
@@ -375,6 +375,12 @@ Format specifiers can be used for advanced formatting by using the options provi
{date:Olocal/} |
2010-01-01 01:00:00 |
+
+ I |
+ Return the current value as is. Do not convert it to str |
+ {num:I} |
+ 1 |
+
diff --git a/gallery_dl/formatter.py b/gallery_dl/formatter.py
index 0f4f35ee..0787464a 100644
--- a/gallery_dl/formatter.py
+++ b/gallery_dl/formatter.py
@@ -430,6 +430,10 @@ def _parse_maxlen(format_spec, default):
return mlen
+def _parse_identity(format_spec, default):
+ return util.identity
+
+
def _parse_join(format_spec, default):
separator, _, format_spec = format_spec.partition(_SEPARATOR)
join = separator[1:].join
@@ -609,6 +613,7 @@ _FORMAT_SPECIFIERS = {
"A": _parse_arithmetic,
"C": _parse_conversion,
"D": _parse_datetime,
+ "I": _parse_identity,
"J": _parse_join,
"L": _parse_maxlen,
"M": _parse_map,
diff --git a/test/test_formatter.py b/test/test_formatter.py
index 0ad9461b..67df2790 100644
--- a/test/test_formatter.py
+++ b/test/test_formatter.py
@@ -369,6 +369,15 @@ class TestFormatter(unittest.TestCase):
with self.assertRaises(ValueError):
self._run_test("{t:Mname", "")
+ def test_specifier_identity(self):
+ self._run_test("{a:I}", self.kwdict["a"])
+ self._run_test("{i:I}", self.kwdict["i"])
+ self._run_test("{dt:I}", self.kwdict["dt"])
+
+ self._run_test("{t!D:I}", self.kwdict["dt"])
+ self._run_test("{t!D:I/O+01:30}", self.kwdict["dt"])
+ self._run_test("{i:A+1/I}", self.kwdict["i"]+1)
+
def test_chain_special(self):
# multiple replacements
self._run_test("{a:Rh/C/RE/e/RL/l/}", "Cello wOrld")