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

Using --filename-template with --batch-pattern does not skip existing files #238

Open
Drudoo opened this issue Apr 28, 2023 · 1 comment

Comments

@Drudoo
Copy link

Drudoo commented Apr 28, 2023

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:

php m4b-tool.phar merge -vvv -n --jobs=4 --output-file="Plex/" --batch-pattern="input/%a/%s/%p - %n/" --batch-pattern="input/%a/%n/" --filename-template="{{outputPath}}{{\"%02d\"|format(seriesPart)}} - {{title}}/{{artist}} - [{{series}} - {{\"%02d\"|format(seriesPart)}}] - {{title}}" --equate=name,album "input/"

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/}}.

@sandreas
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants