Genre and Audio not as expected

Support for Ubuntu and other Desktop Linux distributions
Post Reply
DasBen
Posts: 4
Joined: 25 Apr 2015, 17:20

Genre and Audio not as expected

Post by DasBen »

I hope someone can help me.
After a new pc setup, i've tried to code a new sorting mechanic.

I'm trying to:
* Sort German Animation to a separate dir
* Sort German Episodes to a separate dir
* Sort the Rest into an Englisch dir
* The rest of the code is working as expected so i've shortened it to "{primaryTitle}

My Setup:
* Ubuntu 16.04 VM
* Mediainfo is running and working

My current code:

Code: Select all

{ if(
( genres.contains("Animation|ANIMATION|animation") ) && 
(( audio.language =~ ("DE|DEU|DEUTSCH|GERMAN|de|deu|deutsch|german|De|Deu|Deutsch|German")) || ( file =~ ("DEUTSCH|GERMAN") ))
) "/media/media/Serien-Animation/" 
else if(
( file =~ ("DEUTSCH|GERMAN")) || ( audio.language =~ ("DE|DEU|DEUTSCH|GERMAN|de|deu|deutsch|german|De|Deu|Deutsch|German"))
) "/media/media/Serie/" 
else "/media/media/Serien-Englisch/" }
{ primaryTitle}
My problem:
* If genre and audio.language is filled then everything is fine
* If genre or audio.language or both are undefined the code is not working, so filebot tries to rename into the current folder instead of my wanted path...

I've already tried for many hours... How can i prevent this?
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Genre and Audio not as expected

Post by rednoah »

You're mixing up a few concepts. List.contains(Object) checks if a List contains an Object. A|B|C|D is a regular expression which is used to check if certain text patterns appear in a given piece of text (e.g. 'XYZ' =~ /X/ ? true : false).

e.g. genres is a List of String values, but it's more easy to just treat it as a single String and use the =~ operator to find a regex pattern:

Code: Select all

genres =~ /Animation/ ? 'Animation' : 'Not an Animation'
e.g. audioLanguages will give you normalized language codes:

Code: Select all

audioLanguages =~ /jpn/ ? 'Japanese' : 'Not Japanese'
i.e.

Code: Select all

genres =~ /Animation/ ? audioLanguages =~ /jpn/ ? 'Japanese Animation' : 'Any Animation' : 'Any Genre'

I highly recommend using the Format Editor to rapidly prototype format expressions:
Image
:idea: Please read the FAQ and How to Request Help.
DasBen
Posts: 4
Joined: 25 Apr 2015, 17:20

Re: Genre and Audio not as expected

Post by DasBen »

It works if the binding is filled, but not if undefined:

Result:
Image
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Genre and Audio not as expected

Post by rednoah »

You can catch the undefined case like this:

Code: Select all

any{audioLanguages =~ /jpn/ ? 'Japanese' : 'Not Japanese'}{'Undefined Language'}
@see viewtopic.php?f=5&t=1895
:idea: Please read the FAQ and How to Request Help.
Post Reply