Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't donwload files if title or subtitle is too long #215

Open
vcalv opened this issue Dec 9, 2024 · 4 comments · May be fixed by #216
Open

Can't donwload files if title or subtitle is too long #215

vcalv opened this issue Dec 9, 2024 · 4 comments · May be fixed by #216
Labels
enhancement New feature or request

Comments

@vcalv
Copy link

vcalv commented Dec 9, 2024

I've just come across an audiobook where the filename for the aaxc file is well over the usual limit (256 bytes).

Most filesystems, and the linux internals, usually have a maximum length for a filename (full path).

The limit is usually 256 bytes.

Apparently it's not difficult for the automatically generated filename to exceed that.

Once that happens, every file operations fails with [Errno 36] File name too long.

This is a very low level error, not easy to circumvent.

two options here:

  • Truncate automatic filenames to a specifiable maximum length
  • Allow the user to specify the filename or template, either on the command line or config

As it stands there are definitely audiobooks not downloadable as of now.

Thank you.

@devvythelopper
Copy link

devvythelopper commented Dec 14, 2024

my pull request (#216) implements truncating the base-filename at 230 bytes and adds --filename-mode asin_only which allows the user to use only the asin as the base-filename.

@mkb79
Copy link
Owner

mkb79 commented Dec 14, 2024

@devvythelopper
Thank you for your pr. It looks fine, but I will try it out first for drawbacks. My planned solution was to check the maximum name length like this solution. Now I have to decide, which way is the best.

@devvythelopper
Copy link

devvythelopper commented Dec 15, 2024

The problem with the other solution is, that it might cut off the suffixes -annotations.json (and you'd have to code around that). Also depending on how you implemented writing to files, you might have to touch a multitude of places in your code.

The problem with my solution is, that it does not check for actual filesystem limits. I suppose one should add os.statvfs(file_parent_path).f_namemax to my solution and substract some 25 bytes (UTF-8 characters can take up to 4 bytes and most filesystems limit to number of bytes, not to number of characters).

@mkb79 mkb79 added the enhancement New feature or request label Dec 15, 2024
@devvythelopper
Copy link

there is one drawback I've thought of btw:

say a user successfully has downloaded an audiobook that has a very long filename, say 235 bytes. Adding your extensions the filenames may be between 240 and 250 bytes. if we cut the filenames off now at 230, this audiobook will be redownloaded if the user specifies --all. What you could do to mitigate this is to not use 230 bytes but actually look at all your suffixes, and look which is the longest. Then take os.statvfs(file_parent_path).f_namemax - max_suffix_length as the byte length limit. Any book already successfully downloaded does not have a filename longer than this.

Or you leave it as it is now for simplicity's sake, and you'll be safe if in the future some longer suffixes might be added. I personally would leave it as it is now. It's good enough and users will adjust.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
3 participants