How can i use "if" whith Filebot for choosing right title?

All about user-defined episode / movie / file name format expressions
Post Reply
SergeiAK
Posts: 13
Joined: 23 Jul 2024, 12:49

How can i use "if" whith Filebot for choosing right title?

Post by SergeiAK »

Hello!
I'm interested how can i use "if" whith Filebot for choosing right title.
The case is that:
1. My native language is not English
2. My movies and series library are in my native language
3. In my library i have many movies and series from different countries and often they has original title in hieroglyphs.
In general, I want to have file names whith title in my native language. But if TMDB and TVDB has not titles in my native language i prefer to have titles in English.
I want to use Filebot to rename my files whith this rule.
How can i do this?
User avatar
rednoah
The Source
Posts: 23347
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: How can i use "if" whith Filebot for choosing right title?

Post by rednoah »

:?: Do you have a specific example? Which movie? Which non-English language?


e.g. Pan's Labyrinth (2006) in Spanish

Format: Select all

{
	language =~ /spa/ ? primaryTitle : n
}

Code: Select all

El laberinto del fauno

:arrow: Conditional Structures (if-then-else)
:idea: Please read the FAQ and How to Request Help.
SergeiAK
Posts: 13
Joined: 23 Jul 2024, 12:49

Re: How can i use "if" whith Filebot for choosing right title?

Post by SergeiAK »

For example, the series "Squid Game". This name is in English. Original title "오징어 게임".
If tvdb contains title in my native language, i prefer it. If not, i prefer english title instead Korean.
SergeiAK
Posts: 13
Joined: 23 Jul 2024, 12:49

Re: How can i use "if" whith Filebot for choosing right title?

Post by SergeiAK »

In you example - what does it mean "language"? Original language of movie? It not suited for me
User avatar
rednoah
The Source
Posts: 23347
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: How can i use "if" whith Filebot for choosing right title?

Post by rednoah »

:idea: {language} is the spoken language as per your selected database and series at hand, e.g. {language} is kor for Squid Game.


e.g. Squid Game on TheTVDB

Format: Select all

{
	language =~ /kor/ ? primaryTitle : n
}

Code: Select all

오징어 게임



:idea: Alternatively, you can also check if {primaryTitle} contains any Korean characters like so:

Format: Select all

{
	primaryTitle =~ /\p{script=Hangul}/ ? primaryTitle : n
}
:idea: Please read the FAQ and How to Request Help.
SergeiAK
Posts: 13
Joined: 23 Jul 2024, 12:49

Re: How can i use "if" whith Filebot for choosing right title?

Post by SergeiAK »

Thanks for you advice, it will be usefull for one ore several movies.
But i want universal way to rename all my movies and series.
I have a lot of French, Spanish, Danish, Swedish, Korean and othes movies and series. Some of them have russian (my native language) titles in TMDB ore TVDB, other have not.
How to tell Filebot that if the title is not in Russian, it should be used in English?
User avatar
rednoah
The Source
Posts: 23347
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: How can i use "if" whith Filebot for choosing right title?

Post by rednoah »

The concepts illustrated above are pretty universal. That said, I don't fully understand what you're trying to do if the code above doesn't already do that.


:?: Perhaps you could give us a list of movies with corresponding desired file name for each movie, one for each corner case at the very least, so that we can then help you prototype a single custom format that gives you the desired file name for each movie.





EDIT:

If you configure FileBot to use Russian in the Preferences, then you will get Russian movie names / series names / episode titles in Russian if available:

Screenshot
:idea: Please read the FAQ and How to Request Help.
SergeiAK
Posts: 13
Joined: 23 Jul 2024, 12:49

Re: How can i use "if" whith Filebot for choosing right title?

Post by SergeiAK »

rednoah wrote: 01 Aug 2024, 15:40 If you configure FileBot to use Russian in the Preferences, then you will get Russian movie names / series names / episode titles in Russian if available:
Of course i did it.
I talk about cases if names in my language is not available.
I'll try to explain again.
I prefer to have a titles in Russian, but if it is not available in TMDB i prefer English instead original title.
For example this Italian movie: Gli ultimi giorni di Pompei (1959). TMDB has not Russian titles.
I understand how Conditional Structures works, but my question is how to set condition: if title in Russian is not found in TMDB or TVDB......
User avatar
rednoah
The Source
Posts: 23347
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: How can i use "if" whith Filebot for choosing right title?

Post by rednoah »

:!: Note that we have switched from talking about TV Shows / TheTVDB (e.g. Squid Game) to Movies / TheMovieDB (e.g. The Last Days of Pompeii). The database does make a difference. I can confirm that TheMovieDB defaults to the original title if the title in the preferred language is unavailable. That makes things tricky because we don't actually know if the value we get is the Russian title or the original title in another language which itself could be Russian.
:idea: Please read the FAQ and How to Request Help.
SergeiAK
Posts: 13
Joined: 23 Jul 2024, 12:49

Re: How can i use "if" whith Filebot for choosing right title?

Post by SergeiAK »

As far as I understand, TVDB does the same
Try Banjjakineun witeomellon (2023) TVDB-428247 for example
User avatar
rednoah
The Source
Posts: 23347
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: How can i use "if" whith Filebot for choosing right title?

Post by rednoah »

TheMovieDB / Movie Mode

e.g. Avatar and The Last Days of Pompeii (assuming Russian is set as preferred language; because {n} is in preferred language)

Format: Select all

{
	n =~ /\p{script=Cyrillic}/ ? n : localize.en.n
}

Code: Select all

Аватар
Gli ultimi giorni di Pompei
:idea: How do I use the {localize} dynamic localization binding? is helpful here. The code above notably checks for Cyrillic characters to check if the value at hand is actually "Russian". This code will treat all Cyrillic languages as "Russian" which may or may not be what you want.




TheTVDB / Series Mode

e.g. Twinkling Watermelon (assuming Russian is set as preferred language)

Format: Select all

{
	n =~ /\p{script=Cyrillic}/ ? plex : localize.en.plex
}

Code: Select all

TV Shows/Мерцающий арбуз/Season 01/Мерцающий арбуз - S01E01 - Эпизод 1
** Note that the test case for "series without Russian translation" is missing here because I couldn't find one. Feel free to provide additional test cases if you have additional corner cases at hand.





EDIT:

Here's another way to check:
(1) Check if the translated title is not the primary title (i.e. Russian preference worked)
(2) Check if the movie is Russian, because in this case the translated title is the primary title and what we want
(3) Otherwise use the English title (which may default to the primary title if no English translation is available)

Format: Select all

{
	n != primaryTitle || language =~ /rus/ ? plex : localize.en.plex
}
:idea: Please read the FAQ and How to Request Help.
SergeiAK
Posts: 13
Joined: 23 Jul 2024, 12:49

Re: How can i use "if" whith Filebot for choosing right title?

Post by SergeiAK »

I thought about this option, but Cyrillic is used not only in Russian, but also in Belarusian, Ukrainian and many others, including European. So it’s not perfect.
Can Filebot somehow get information in which language TMDB or TVDB returned the title?

Edited:

Format: Select all

{ n != primaryTitle || language =~ /rus/ ? plex : localize.en.plex }
It seems to work. I’ll test it further.
Thank you so much!
Post Reply