60 Commits

Author SHA1 Message Date
Mike Fährmann
c978fe18d4 [text] add 'extract_urls()' helper 2026-02-07 21:47:17 +01:00
Mike Fährmann
0be3383110 [formatter] add 'q' & 'Q' conversions - URL-en/decode values 2026-02-03 17:35:05 +01:00
Mike Fährmann
25397903ce [formatter] combine '_apply_*' methods 2026-01-11 18:10:57 +01:00
Mike Fährmann
a79a945494 [formatter] overload '.' operator
implement generic access of
* list items        (L[1]   -> L.1)
* dict vslues       (D[key] -> D.key)
* object attributes (O.attr -> O.attr)
in standard format strings
2026-01-11 17:49:55 +01:00
Mike Fährmann
ff94002b44 [formatter] add 'I' format specifier - identity 2025-12-17 19:22:18 +01:00
Mike Fährmann
5591a16cd7 [formatter] add 'Lb' format specifier - 'L' for bytes 2025-11-03 13:36:55 +01:00
Mike Fährmann
91a5fd85db [formatter] add 'Xb' format specifier - 'X' for bytes (#6582)
https://github.com/mikf/gallery-dl/issues/6582#issuecomment-3479362186
2025-11-03 12:41:20 +01:00
Mike Fährmann
69f7cfdd0c [dt] replace 'datetime' imports 2025-10-16 11:42:42 +02:00
Mike Fährmann
0eb3c8a994 [dt] replace 'util' datetime functions 2025-10-15 21:30:38 +02:00
Mike Fährmann
11706d1e42 [formatter] improve error messages (#8369) 2025-10-12 09:33:00 +02:00
Mike Fährmann
99d5c521d1 use 'encoding="utf-8"' when opening files in text mode (#8376) 2025-10-09 09:54:18 +02:00
Mike Fährmann
9035b92230 [formatter] support negative indicies
for example '{items[-3]}'
2025-09-11 20:50:50 +02:00
Mike Fährmann
bcf4d579b0 [formatter] exclude '<>\' from '!R' URLs (#8180) 2025-09-11 08:25:23 +02:00
Mike Fährmann
9309204d9b [formatter] add 'R' conversion - extract URLs (#8125) 2025-08-26 16:44:22 +02:00
Mike Fährmann
ea61f432f2 [formatter/jinja] add support for options (#1390)
- custom filters
- custom tests
- policies
- Environment.__init__() arguments
2025-07-22 20:57:54 +02:00
Mike Fährmann
240f958707 [formatter] add 'W' conversion - sanitize whitespace (#6582)
https://github.com/mikf/gallery-dl/issues/6582#issuecomment-3090777073
2025-07-19 21:44:55 +02:00
Mike Fährmann
22fd866b73 [formatter] update format string type lookup
use a dict instead of if/elif/else
2025-07-16 23:24:21 +02:00
Mike Fährmann
f25c5f4b0c [formatter] add basic 'Jinja2' template support (#1390) 2025-07-16 23:23:58 +02:00
Mike Fährmann
2bcc2f2a17 [formatter] implement 'M' format specifier
Map a list of objects to a list of values

[
    {"name": "John Doe"      , "age": 42},
    {"name": "Jane Smith"    , "age": 24},
    {"name": "Max Mustermann", "age": null}
]

== :Mname =>

["John Doe", "Jane Smith", "Max Mustermann"]
2025-06-22 16:33:20 +02:00
Mike Fährmann
71461ceaba [formatter] add 'L' conversion
to map ISO 639-1 language codes to their full names
2025-06-22 14:01:58 +02:00
Mike Fährmann
5e0cdac337 [formatter] change 'L'/length conversion to 'n' 2025-06-22 13:54:57 +02:00
Mike Fährmann
e08ec7e083 update copyright notices 2025-06-13 00:03:41 +02:00
Mike Fährmann
811b665e33 remove @staticmethod decorators
There might have been a time when calling a static method was faster
than a regular method, but that is no longer the case. According to
micro-benchmarks, it is 70% slower in CPython 3.13 and it also makes
executing the code of a class definition slower.
2025-06-12 22:50:52 +02:00
Mike Fährmann
539ed8fef4 [formatter] add 'D' conversion 2025-05-29 20:09:26 +02:00
Mike Fährmann
9ce6de6ca0 [formatter] add 'i' and 'f' conversions (#6582)
https://github.com/mikf/gallery-dl/issues/6582#issuecomment-2792166608
2025-04-11 09:18:24 +02:00
Mike Fährmann
68bff76d90 [formatter] implement 'L' conversion 2024-09-19 13:50:52 +02:00
Mike Fährmann
b44f0cdab0 [formatter] allow accessing 'util.NONE' via global '_nul' 2024-09-19 13:28:59 +02:00
Mike Fährmann
78ae0ba9f7 [formatter] implement 'A' format specifier (#6036) 2024-08-16 20:34:23 +02:00
Mike Fährmann
8f50c04af2 [formatter] implement 'X' format specifier (#5770) 2024-06-21 20:56:19 +02:00
Mike Fährmann
1ce5de0290 [formatter] implement 'C' format specifier (#5647)
to apply a conversion after ':' or
to apply multiple conversions

for example {tags:CSl} or {tags:J - /Cl}
to convert list to string and lowercase it
2024-06-05 16:49:29 +02:00
Mike Fährmann
d0cead105b [formatter] allow dots etc in '…' literals (#5539)
don't parse fields starting with '

this disables the ability to directly apply […] to '…' literals,
but that's not really useful anyway and can still be done with _lit
2024-05-02 17:43:24 +02:00
Mike Fährmann
ddb2edfd32 [formatter] fix local DST datetime offsets for ':O'
'O' would get the *current* local UTC offset and apply it to all
'datetime' objects it gets applied to.
This would result in a wrong offset if the current offset includes
DST and the target 'datetime' does not or vice-versa.

'O' now determines the correct local UTC offset while respecting DST for
each individual 'datetime'.
2024-03-21 20:45:46 +01:00
Mike Fährmann
93a7a89cf6 [formatter] use value of last alternative (#4492)
fixes {fieldname|''} evaluating to the value of 'keywords-default'
instead of an empty string
2023-09-05 17:53:27 +02:00
Mike Fährmann
d8b21a97bf [formatter] use 'rpartition' for \fM format strings
fixes using absolute module paths like C:\path\module.py on Windows
2023-08-11 22:29:33 +02:00
Mike Fährmann
ce93c460a6 [formatter] implement 'H' conversion (#4164)
to remove HTML tags and unescape HTML entities
2023-06-15 13:07:51 +02:00
Mike Fährmann
69865dcc05 [formatter] implement slicing strings as bytes (#4087)
prefixing a slice '[10:30]' with a lowercase b '[b10:30]' encodes
the string to bytes in filesystem encoding before applying the slice
2023-05-22 18:30:45 +02:00
Mike Fährmann
fe41a2b159 [formatter] support putting keys in quotes
i.e. obj["key"] or obj['key']
as in f-strings
2023-03-21 22:06:54 +01:00
Mike Fährmann
46fdf46f21 [formatter] support loading an f-string from a template file
"\fTF ~/path/to/file.txt"
2023-03-20 22:05:33 +01:00
Mike Fährmann
1a4d4a799b [formatter] support filesystem paths for \fM 2023-03-20 22:01:33 +01:00
Mike Fährmann
11df3a021d [formatter] enclose f-strings with """ instead of ''' 2023-03-03 20:03:27 +01:00
Mike Fährmann
5503ac4d5e replace json.dumps with direct calls to JSONEncoder.encode 2023-02-09 15:51:40 +01:00
pi_allen
64902f518e [docs] Update links and fix field typo 2022-12-26 07:46:41 +01:00
Mike Fährmann
3082544fff misc fixes
- fix typo (#3399)
- remove double assignment
- [bunkr] update things I forgot in 6b6f886d
- [soundgasm] adjust 'archive_fmt' (#3388)
2022-12-14 13:30:27 +01:00
Mike Fährmann
ca4742200b use util.NONE as 'keyword-default' default value 2022-12-06 22:27:57 +01:00
Mike Fährmann
42481aed59 [formatter] implement 'S' format specifier (#3266)
to Sort lists
2022-11-21 21:44:42 +01:00
Mike Fährmann
67bad04dda [formatter] add 'g' conversion to sluGify a string (#2410) 2022-08-26 17:57:17 +02:00
Mike Fährmann
6990ad0ba8 [formatter] do NOT apply :J to strings (#2833) 2022-08-16 16:41:19 +02:00
Mike Fährmann
74865adae5 implement 'format-separator' option (#2737)
a global option, that servers as a workaround for shortcomings due to
lack of a proper format string parser
2022-07-10 13:31:43 +02:00
Mike Fährmann
90ae48c40c [formatter] implement 'O' format specifier (#2736)
to apply a UTC offset to 'date' values and other datetime objects
2022-07-08 12:51:03 +02:00
Mike Fährmann
04bed1eba3 [formatter] allow for custom "format" functions (#2721) 2022-07-05 12:22:01 +02:00