Commit Graph

48 Commits

Author SHA1 Message Date
Mike Fährmann
c3d8602418 [path] implement dynamic length directories (#1350)
append directory segments for each item of a list (or general non-string
iterable), which can be returned with the 'I' specifier
2025-12-18 09:53:26 +01:00
Mike Fährmann
218dbdb3ca [path] combine 'build_*' & 'build_*_conditional' 2025-12-17 19:45:38 +01:00
Mike Fährmann
4e2987e007 [path] implement conditional 'part-directory' (#8329) 2025-12-03 11:19:44 +01:00
Mike Fährmann
3848a912dc [path] treat broken symlinks as existing files (#8490) 2025-11-01 10:01:45 +01:00
Mike Fährmann
a3734e2e56 [path] improve 'exists()' performance
call 'os.stat()' directly
2025-11-01 10:01:06 +01:00
Mike Fährmann
c723eefcf5 [path] implement conditional 'base-directory' 2025-10-08 21:10:15 +02:00
Mike Fährmann
2d49d3d843 [path] add '__str__()' method 2025-08-16 15:50:08 +02:00
Mike Fährmann
682e29a535 [path] implement 'path-convert' option (#493 #6582) 2025-08-14 19:33:24 +02:00
Mike Fährmann
55977e2be3 more f-string usage (#7671) 2025-08-03 11:36:28 +02:00
Mike Fährmann
a097a373a9 simplify if statements by using walrus operators (#7671) 2025-07-22 20:57:54 +02:00
Mike Fährmann
3810555bbd do not use 'append = list.append' 2025-06-30 11:42:44 +02:00
Mike Fährmann
434bf3b1f3 use 'util.re()' in more places
continuation of b5c88b3d3e
2025-06-23 20:31:45 +02:00
Mike Fährmann
9e56d81292 fix Last-Modified mtime overwriting post processor mtime (#7529)
https://github.com/mikf/gallery-dl/issues/7529#issuecomment-2989955455

- split '_mtime' into '_mtime_http' and '_mtime_meta'
- add PathFormat.set_mtime() method
2025-06-20 16:19:37 +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
e0a961047c [dl:http] fix potential FileExistsError when '.part' file moved (#5385)
when the downloader detects a '.part' file and attempts to resume its
download, a FileExistsError was raised while trying to create an assumed
missing directory path when said '.part' file was (re)moved during the
time it was detected and the downloader attempted to open it in 'a+b' mode.
2025-06-12 16:44:41 +02:00
Mike Fährmann
5b60c66e0f [path] support multiple characters in path-restrict objects (#1707) 2025-06-12 15:29:13 +02:00
Mike Fährmann
8eb365d4b6 [pp:metadata] fix handling of empty directory paths (#7296) 2025-04-08 17:03:27 +02:00
Mike Fährmann
105c027411 [path] handle exception when using --rename-to --no-download (#6861)
Catch a possible FileExistsError exception when attempting to create a
new directory during handling of a FileNotFoundError exception.
FileNotFoundError may also occur when the file at self.temppath is
missing because it hasn't been downloaded due to --no-download.
2025-01-20 20:50:31 +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
eef5beb841 [pp:metadata] fix using '..' in directories on Windows (#5942, #6094) 2024-08-27 14:38:40 +02:00
Mike Fährmann
1bdb0f7a49 [path] leave '..' segments as is (#5728) 2024-08-01 13:35:42 +02:00
Mike Fährmann
1656c9287d [pp:metadata] fix 'directory' when file directory has conditions (#5728) 2024-07-06 22:07:17 +02:00
Mike Fährmann
ba51c1a8e4 [path] fix 1ca2cf51 2024-06-29 02:41:56 +02:00
AyluinReymaer
de61b3b546 Update path.py 2024-06-29 00:58:03 +01:00
AyluinReymaer
91a989a172 path.py - fix system cannot move file to different drive
This fixes the below error message:

OSError(18, 'The system cannot move the file to a different disk drive')
2024-06-29 00:08:53 +01:00
blankie
909830f8ea fix filename formatting silently failing under certain circumstances 2024-02-10 21:18:57 +11:00
Mike Fährmann
9d67655397 add "ascii+" as a special 'path-restrict' value (#4371) 2023-08-01 19:33:53 +02:00
Mike Fährmann
1aae72773f put argument init on separate lines 2023-02-10 17:05:20 +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
6afb3cc766 restore paths for archived files (#3362) 2022-12-06 22:01:37 +01:00
Mike Fährmann
d0b160461a terrible workaround for errors with 'http-metadata' (#3334) 2022-12-04 19:36:21 +01:00
Mike Fährmann
374f14c28c fix repeating paths for skipped files (#3203)
fixing the fix from e3260293
2022-11-13 19:34:59 +01:00
Mike Fährmann
e326029355 build path when skipping archived files
fixes bug from 8124c16a
2022-11-09 10:33:09 +01:00
Mike Fährmann
8124c16a50 split 'build_path' from 'set_filename' and 'set_extension'
Do not automatically build a new path
when setting file metadata or updating its extension.
2022-11-08 17:03:24 +01:00
Mike Fährmann
7f30a0d7a7 add 'path-extended' option (#3021) 2022-10-08 15:41:39 +02:00
Mike Fährmann
d1bb7fae2d remove 'exist_ok=True' argument from several os.makedirs calls
makedirs in those places is only meant to create missing directories,
anything should be considered an error
2022-05-11 15:04:47 +02:00
Mike Fährmann
9c8647a4fd fix 'part-directory' (#2576)
bug introduced in 99cb2872
2022-05-10 15:55:39 +02:00
Mike Fährmann
99cb28724f delay directory creation (#2461, #2474)
Only call os.makedirs() when an open() call
fails with a FileNotFoundError

Might cause errors with some post processors etc,
but for now I was unable to find any.
2022-05-04 17:42:53 +02:00
Mike Fährmann
7958995398 [postprocessor:metadata] implement 'mtime' option (#2307) 2022-02-22 23:02:13 +01:00
Mike Fährmann
3b7c7daa76 improve UNC path handling (#2126)
always call 'abspath()' on the directory path to handle cases when the
current working directory is UNC and 'base-directory' is relative.
2021-12-30 22:22:19 +01:00
Mike Fährmann
ac80474371 handle UNC paths (#2113) 2021-12-19 04:52:00 +01:00
Mike Fährmann
cad85640de move 'util.PathFormat' into its own 'path' module
to prevent circular imports between 'formatter' and 'util'
2021-09-27 21:29:37 +02:00
Mike Fährmann
841fd50242 move code into util.py 2017-03-28 13:12:44 +02:00
Mike Fährmann
e87e6fbc67 change some config keys
directory_fmt     -> directory
filename_fmt      -> filename
download-original -> original
2017-02-21 22:11:02 +01:00
Mike Fährmann
4f123b8513 code adjustments according to pep8 2017-01-30 19:40:15 +01:00
Mike Fährmann
14237142d8 use 'format_map()' 2016-10-02 13:51:54 +02:00
Mike Fährmann
29692c5784 get extension from Content-Type header if not provided 2016-09-30 12:32:48 +02:00