Open Drudoo opened 1 year ago
I've had issues with folder structure and series naming and when using Audiobookshelf and therefore I've started to use --filename-template, which is amazing.
Ha, I did not know that this is working and never even had the idea of doing that, you're a genius... Recently I reorganized my whole Filesystem structure just to make it fit for audiobookshelf and never thought of just reencoding my lib.
So, obviously the use of --filename-template
was never intended, this is why it does not work correctly. I remember, that I recently fixed something to make it work, but never thought about this possibility.
A side question, is it possible to have a single filename-template that doesn't output parts of the name if it doesn't exists?
You should be able to use the whole world of twig templates, that means:
{% if series %}{{seriesPart}} - {{title}}{% else %}{{title}}{% endif %}
It is kind of fiddly and I never tested this, but it should work.
Back to the main question: Ok, I know, what has to be done here. Since I'm busy as hell atm, I'll write some things down to remember how to fix that and I hope I can get to this possibility in the near future:
The core of this problem is, that the Tags already have to exist in order to rename the file via template, but the output file have to exist to determine the tags. So this is a bit of a chicken or the egg causality.
What I could do: Determine the tags, that are possible before having an output file (read from metadata files, input arguments, etc.) and build the filename via template before calling shouldSkip
(see below). Then apply the rest of the improvers, that only can be loaded on an existing output file (silence detector, chapter improvers). That would probably work in MOST cases... I'll have to investigate this, but this is not an easy Task.
shouldSkip
method decides, wether a file should be skipped, e.g. already existing files (https://github.com/sandreas/m4b-tool/blob/66b44bb3eecb3cf3901ed737c54487909d25a271/src/library/Command/MergeCommand.php#L423)optFilenameTemplate
is applied pretty much at the end of the whole process, so too late (https://github.com/sandreas/m4b-tool/blob/66b44bb3eecb3cf3901ed737c54487909d25a271/src/library/Command/MergeCommand.php#L539)
I've been using
--batch-pattern
for a long time, when converting my files. It is great as i can add new files to my input folder and if it has already been converted to the output folder, it will just be skipped.I've had issues with folder structure and series naming and when using Audiobookshelf and therefore I've started to use
--filename-template
, which is amazing.My current command looks like:
This is mainly a test to make sure books in a series are tagged correctly.
But it seems like m4b-tools first check if the output file (using standard batch-pattern) filename exists, then convert and moves the file using the filename-template. It should be checking if the file exists using the filename-template?
A side question, is it possible to have a single filename-template that doesn't output parts of the name if it doesn't exists?
Eg. if the book doesn't have a series, don't create the series folder (
{{seriesPart}} - {{title}}/
)? Some softwares you can do stuff like{{seriesPart - title/}}
.