Ovear / kemono-dl

A simple kemono.party downloader using python.
109 stars 11 forks source link

Add option to shorten names of files and directories if too long. #10

Open 0fbcb238c0 opened 12 months ago

0fbcb238c0 commented 12 months ago

Description

One of the artists I am currently downloading has a few posts, whose filenames surpasses the limit of 255 characters. Please add an option to shorten filenames to a certain length if they are too long. I am aware of the option to change the filename template but this is not a solution for me, as this would lead to inconsistency between new and already downloaded files.

Thank you

Ovear commented 12 months ago

Hi,

The windows limit not only file name length but also full path length. It's a bit tricky to make sure it won't hit the limit as the path of parent directory may hit that limit already, which means it will extremely limit the length file name.

The approach that limits file name only may not handle this well, but let me check what I can do here...

But for your question, python provide a powerful string format mini language, which may help. Please refer https://docs.python.org/3/library/string.html#formatspec

0fbcb238c0 commented 11 months ago

I am actually using a Linux filesystem, which has no such limit on absolute path length, every directory in a directory tree can be 255 characters long, including the files. The absolute path length is therefore of no concern, only a filename or directory name may not be longer than those 255 characters.