[options] add --truncate-filenames to trim paths#9079
Open
NecRaul wants to merge 7900 commits intomikf:masterfrom
Open
[options] add --truncate-filenames to trim paths#9079NecRaul wants to merge 7900 commits intomikf:masterfrom
NecRaul wants to merge 7900 commits intomikf:masterfrom
Conversation
* bilibili: add support for live photo downloads * fix: resolve flake8 linting errors (whitespace and line length) * fix: resolve flake8 E302 and W293 linting errors * fix: resolve flake8 W293 and E302 linting errors * simplify syntax * add 'livephoto' option * add tests
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
* fix gallery media metadata issues * retain group/gallery creator
use server invite link that will never expire mikf#8803 (comment)
to allow disabling the behavior introduced in commit a79a945
* adding site support for thefap.com * fixing typo in url tld * improve & simplify 'model' extractor * update 'post' extractor * update docs/supportedsites * add tests --------- Co-authored-by: Mike Fährmann <mike_faehrmann@web.de>
some instances respond with redirects when using these URLs as is
provide '{_path_unc}' and '{_directory_unc}' replacement fields
* feat: extractor for pholder.com
Closes mikf#2568
* feat[pholder]: support gallery_id properly and tags
* doc[text.nameext_from_name]: minor typo in docstring
* remove '__init__' & 'request' methods and 'json' import
* use 'text.nameext_from_url' to ensure a 'filename' value
* fix 'imgur' links by disabling auto-Referer
* fix 'data["id"].partition()' call
'partition' returns 3 elements
* use 'item["_source"]' data directly
* remove unused supportedsites overwrite
* catch all exceptions in '_thumb_resolution'
fixes "KeyError: 'width'"
* use 'author' name for user folders
---------
Co-authored-by: Mike Fährmann <mike_faehrmann@web.de>
- remove 'exception' imports - replace with 'self.exc'
prevents redirect on initial request
fixes regression introduced in 0fb5ce6
and prevent "KeyError: 'name'" when accessing the full username
fixes regression introduced in 53cdfaa
Introduce a new --truncate-filenames option to automatically truncate filenames so that the resulting paths stay within OS path-length limits. PathFormat now checks this option when building filenames and .part files, calling _truncate_filename with the directory, filename, extension, and optional suffix. - Add --truncate-filenames CLI flag using ConfigConstAction - Read "truncate-filenames" from config with default False - Update PathFormat.build_path and part_enable to apply truncation - Implement _truncate_filename for Windows and POSIX
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR introduces a new
--truncate-filenamesoption to automatically truncate filenames so that destination paths stay within OS path-length limits.PathFormatnow applies truncation when building filenames and .part files, ensuring compatibility across Windows and POSIX systems.Changes
--truncate-filenamesCLI argumenttruncate-filenamesfrom the config with default FalsePathFormat.build_pathandpart_enableto apply truncation_truncate_filenameto respect path and name length limits, usingos.pathconfon POSIX and fixed limits on WindowsNotes
_truncate_filenamecurrently uses character counts vialen(), which may differ from filesystem byte limits for multibyte filenames. Future improvements could make truncation byte-aware for full UTF-8/UTF-16 safety.