Mike Fährmann
c23beee57c
[util] use functions for predicates
...
more lightweight and faster than classes
2026-01-18 20:32:36 +01:00
Mike Fährmann
826b557f6d
[util] support integer values for '…-range' options ( #8604 )
2025-12-08 10:32:46 +01:00
Mike Fährmann
d0f5d4e0d3
[tests/dt] add tests
2025-10-15 09:45:30 +02:00
Mike Fährmann
a16238edda
[util] add __enter__ & __exit__ methods to NullResponse ( #8227 )
2025-09-17 09:09:08 +02:00
Mike Fährmann
b9429de774
[tests] use f-strings (##7671)
2025-08-14 10:22:42 +02:00
Mike Fährmann
c08833aed9
[util] move 're' functions to text.py
2025-06-23 20:05:20 +02:00
Mike Fährmann
ce4d78e8e3
[util] make NONE compare equal to the native None
2025-06-22 19:50:21 +02:00
Mike Fährmann
dd299b3dad
[tests/util] add LazyPrompt test
2025-06-17 21:47:21 +02:00
Mike Fährmann
acd5cb0cf0
[tests/util] add HTTPBasicAuth tests
2025-06-17 20:28:16 +02:00
Mike Fährmann
f1343894cb
[tests/util] move 'datetime' tests into a separate TestCase class
2025-06-17 20:14:43 +02:00
Mike Fährmann
6d928f3805
remove some pre-3.8 workarounds ( #7671 )
2025-06-17 12:56:47 +02:00
Mike Fährmann
40dedd7ce0
[util] restore stdlib 're' module in filter expressions ( #7665 )
...
fixes regression introduced in 4fc719bb10
2025-06-13 20:52:33 +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
e84df260c0
[util] generalize 'build_duration_func'
2025-06-08 20:01:16 +02:00
Mike Fährmann
e1f03a5a93
[util] allow 'noop()' to accept one optional argument
...
fixes 'NullResponse.close()'
2025-06-05 20:08:24 +02:00
Mike Fährmann
4fc719bb10
[util] add 're' helper
2025-06-04 07:56:43 +02:00
Mike Fährmann
002c25d417
[util] add 'NullResponse' class
2025-05-29 20:27:40 +02:00
Mike Fährmann
17b2910938
[util] implement 'to_datetime()'
2025-05-28 20:10:18 +02:00
Mike Fährmann
770f41eb4a
[util] support not splitting "contains" value ( #6773 )
...
by passing any "false" value as 'separator' argument except None
2025-01-06 13:47:32 +01:00
Mike Fährmann
bced143750
[tests] add workaround for compile_expression_defaultdict in pypy3
2024-11-16 19:35:28 +01:00
Mike Fährmann
5bc3657c59
[util] implement 'compile_filter()' ( #5262 )
...
https://github.com/mikf/gallery-dl/issues/5262#issuecomment-2477029728
allow (theoretically*) all filter expression statements
to be a list of individual filters
(*) except for 'filename' and 'directory' conditionals,
as dict keys cannot be lists
2024-11-14 22:47:36 +01:00
Mike Fährmann
0b99d9e6b9
[util] add "defaultdict" filters-environment
...
allows accessing undefined values without raising an exception,
but preserves other errors like TypeError, AttributeError, etc
2024-11-14 22:47:25 +01:00
Mike Fährmann
4667833195
[util] add 'std' object to global eval namespace ( #6330 )
...
allows accessing standard library modules (and other external modules)
in a more straightforward manner than '__import__(...)'
* std.os.getcwd()
* std["os"].getcwd()
2024-10-17 21:08:07 +02:00
Mike Fährmann
3946fe5ac4
[cookies] return loaded cookies as list
...
don't set_cookie() them immediately into a CookieJar
also, give some more consistent names to chrome/chromium functions
2024-10-14 14:24:27 +02:00
Mike Fährmann
2c7a0c3ca8
add alternatives for deprecated utc datetime functions
2024-09-19 20:47:05 +02:00
Mike Fährmann
01e8433889
fix tests & syntax for older Python versions
2024-08-15 18:16:55 +02:00
Mike Fährmann
5208c0d28a
[util] extend CustomNone with an __index__ method ( #6009 )
...
- Make it compatible with functions expecting integer arguments
- Simplify and reuse some method definitions
2024-08-13 16:05:54 +02:00
Mike Fährmann
ad73789256
[util] extend CustomNone with arithmetic operators ( #6007 )
2024-08-13 09:41:12 +02:00
Mike Fährmann
d7a2c73274
[util] let a CustomNone instance be equal to itself
2024-07-26 20:56:01 +02:00
Mike Fährmann
f7383a56f8
wrap filters/conditionals in a try-except block
...
allows accessing undefined fields without exception or locals().get(…)
but hides mistakes/typos/etc by evaluating to False without feedback
performance loss compared to the previous version without try-except
is negligible (~20ns for me)
2024-07-12 22:51:11 +02:00
Mike Fährmann
7614bc458e
[util] extend CustomNone with comparison operators
2024-06-05 16:49:30 +02:00
Mike Fährmann
ba062712ad
[tests] '__main__' -> "__main__"
2024-02-27 02:10:05 +01:00
Mike Fährmann
72b18d701f
represent util.NONE as 'null' in JSON output
...
was '"None"' before
2023-11-02 15:23:28 +01:00
Mike Fährmann
d788e6c60c
implement 'globals' option
2023-02-28 18:18:55 +01:00
Mike Fährmann
56039d2456
add 'hash_md5' and 'hash_sha1' functions ( #3679 )
...
... to global eval namespace
2023-02-22 10:58:44 +01:00
Mike Fährmann
d651d45239
implement specifying ranges in slice notation ( #918 , #2865 )
...
e.g.
- '1:101' or ':101' or ':101:' for files 1 to 100
- '1::2' or '::2' for every second file
- '1:101:5' or ':101:5' for files 1, 6, 11, ..., 91, 96
(the second argument specifies the first index NOT included)
2022-12-27 18:21:12 +01:00
Mike Fährmann
3616adfc75
implement '--range' with Python ranges
2022-12-26 18:32:34 +01:00
Mike Fährmann
1800bd7d14
allow '*-filter' options to be a list of expressions
2022-12-23 22:20:21 +01:00
Mike Fährmann
43c211f1a7
extend and rename util.CustomNone
2022-12-06 22:08:51 +01:00
Mike Fährmann
c0051d7d4c
fix test
2022-08-01 21:40:35 +02:00
Mike Fährmann
dd3a6a9fd1
make 'enumerate_reversed()' work with generators ( #2795 )
2022-08-01 14:08:44 +02:00
Mike Fährmann
c4b9f7bab8
update functions working with cookies.txt files
...
- rename
- load_cookiestxt -> cookiestxt_load
- save_cookiestxt -< cookiestxt_store
- in cookiestxt_load, add cookies directly to a cookie jar
instead of storing them in a list first
- other unnoticeable performance increases
2022-05-06 13:21:29 +02:00
Mike Fährmann
ca3a364db7
fix build_duration_func() ( #2533 )
...
for extractors with request_interval_min > 0
2022-04-27 20:28:14 +02:00
Mike Fährmann
7fe54bab2a
attempt to fix some issues with 'contains()' ( #2446 )
...
add a third argument that gets used
when the values o search are given as a string
2022-04-08 14:40:26 +02:00
Mike Fährmann
d78a2c7163
re.escape() arguments for 'contains()' ( #2446 )
2022-04-07 15:35:54 +02:00
Mike Fährmann
413b77757b
implement 'contains()' ( #2446 )
...
and add it to globals() in compiled expressions for --filter etc
2022-03-30 16:18:33 +02:00
Mike Fährmann
29db716a63
implement 'datetime_to_timestamp()'
...
and rename 'to_timestamp()'
to the more descriptive 'datetime_to_timestamp_string()'
2022-03-23 22:36:01 +01:00
Mike Fährmann
8295bc6d97
fix loading/storing cookies without domain
2022-03-19 15:14:55 +01:00
Mike Fährmann
64cf26eaf4
allow specifying sleep-* options as string
...
either as single value or as range: "3.5", "2.1 - 5.0"
2021-12-18 23:28:56 +01:00