Conditional titles using {localize} based on unique audio tracks

All about user-defined episode / movie / file name format expressions
Post Reply
ye62dzec
Posts: 10
Joined: 09 Jan 2025, 16:24

Conditional titles using {localize} based on unique audio tracks

Post by ye62dzec »

Hi everyone,

I'm working with a mixed-language movie collection and want to implement smart title localization. Current format:

Code: Select all

{collection + '/'}{plex.name} - {audioLanguages.ISO2.joining(', ', '[', ']').upper()} {allOf{vf}{vc}{hdr.replace("Dolby Vision":"DV")}.joining(' ', ' [', ']')}/{plex.name} - {audioLanguages.ISO2.joining(', ', '[', ']').upper()} {allOf{vf}{vc}{hdr.replace("Dolby Vision":"DV")}.joining(' ', ' [', ']')}
What I want to achieve:
- For movies with only German audio: Use German title
- For movies with multiple audio tracks: Use English title

I know I can use the {localize} binding for German titles, but I'm not sure how to combine this with a check of unique {audioLanguages} to make it conditional. Can you help me modify my format to implement this logic?

Currently getting:
[deu]/[DE] → Should use German title
anything else → Should keep English title

Thanks for any help with this!
User avatar
rednoah
The Source
Posts: 23936
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Conditional titles using {localize} based on unique audio tracks

Post by rednoah »

e.g.

Format: Select all

{ audio.language =~ /de/ ? localize.de.n : n }
:idea: Please read the FAQ and How to Request Help.
ye62dzec
Posts: 10
Joined: 09 Jan 2025, 16:24

Re: Conditional titles using {localize} based on unique audio tracks

Post by ye62dzec »

This works almost perfectly. Is there a way to check whether it's the only languague?

This movie is not correctly renamed:

Code: Select all

N:\Filme\Flüstern des Meeres - Ocean Waves (1994) - [DE, JA] [1080p x264] [5.1GB]\Flüstern des Meeres - Ocean Waves (1994) - [DE, JA] [1080p x264] [5.1GB].mkv
User avatar
rednoah
The Source
Posts: 23936
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Conditional titles using {localize} based on unique audio tracks

Post by rednoah »

:arrow: I think you mean to name files based on the original language according to the database, and not the audio stream language:

Format: Select all

{ language ==~ /deu/ ? localize.de.n : n }

:arrow: Checking if the file only contains German language audio streams is of course possible too:

Format: Select all

{ audioLanguages.ISO3 == [/deu/] ? localize.de.n : n }
:idea: Please read the FAQ and How to Request Help.
Post Reply