Swiss german not recognized in Audiolanguagelist

All about user-defined episode / movie / file name format expressions
Post Reply
Snafu
Posts: 2
Joined: 14 Jan 2021, 03:21

Swiss german not recognized in Audiolanguagelist

Post by Snafu »

Hi,

I have trouble renaming a Movie in swissgerman (Language 'gsw') with the naming scheme:

Code: Select all

Movies/{plex.name} - {audioLanguages}/{plex.name} {"{imdb-$imdbid}"} {audioLanguages} {"[$vf, $vc, $ac]"}
Image

The MKV in question has one Audiotrack set to 'gsw' and I would expect a name like

Code: Select all

Movies/Heidi (2015) -[gsw]/Heidi (2015) {imdb-tt3700392} - [gsw] [1080p, AVC, DTS].mkv
but instead the name Filebot is generated is

Code: Select all

Movies/Heidi (2015) -/Heidi (2015) {imdb-tt3700392} [1080p, AVC, DTS].mkv
Image

"mkvmerge -i" shows:

Code: Select all

$ mkvmerge -i --identification-format json Heidi\ \(2015\)\ \{imdb-tt3700392\}\ \[1080p\,\ AVC\,\ DTS\].mkv  | jq '.tracks[] | select(.type == "audio")'
{
  "codec": "DTS-HD Master Audio",
  "id": 1,
  "properties": {
    "audio_channels": 6,
    "audio_sampling_frequency": 48000,
    "codec_id": "A_DTS",
    "codec_private_length": 0,
    "default_duration": 10666667,
    "default_track": true,
    "enabled_track": true,
    "forced_track": false,
    "language": "gsw",
    "minimum_timestamp": 0,
    "number": 2,
    "track_name": "Schweizerdeutsch",
    "uid": 8253282054307142000
  },
  "type": "audio"
}

System Information:

Code: Select all

FileBot 4.9.2 (r8046)
JNA Native: 6.1.0
MediaInfo: 20.08
7-Zip-JBinding: 16.02
Tools: fpcalc/1.5.0 mkvpropedit/37.0.0
Extended Attributes: OK
Unicode Filesystem: OK
GVFS: PlatformGVFS [/run/user/1000/gvfs]
Script Bundle: 2020-12-01 (r724)
Groovy: 3.0.6
JRE: OpenJDK Runtime Environment 15
JFX: OpenJFX 15+9
JVM: 64-bit OpenJDK 64-Bit Server VM
CPU/MEM: 8 Core / 4.2 GB Max Memory / 759 MB Used Memory
OS: Linux (amd64)
HW: Linux andor 5.3.0-64-generic #58-Ubuntu SMP Fri Jul 10 19:33:51 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
CPU/MEM: Intel(R) Core(TM) i7-9700K CPU @ 3.60GHz [MemTotal: 16 GB | MemFree: 3.3 GB | MemAvailable: 7 GB | SwapCached: 393 MB | SwapTotal: 1.0 GB | SwapFree: 345 MB]
STORAGE: ext4 [/] @ 134 GB | ext4 [/home] @ 373 GB 
DATA: /home/snafu/.filebot
Package: DEB
License: FileBot License P21916810 (Valid-Until: 2022-01-12)
Error Log:
No Errors

Any idea why the Language is not added properly?

Cheers,

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

Re: Swiss german not recognized in Audiolanguagelist

Post by rednoah »

audioLanguages only works for standard languages, and filters out everything else.


:idea: You can use audio.language to retrieve the raw String values:
viewtopic.php?t=4285
:idea: Please read the FAQ and How to Request Help.
Snafu
Posts: 2
Joined: 14 Jan 2021, 03:21

Re: Swiss german not recognized in Audiolanguagelist

Post by Snafu »

Oh, cool. Thanks rednoah.

Unfortunately, now some other files have issues.

audioLanguages printed unique languages, while audio.language will print them all.
If there are multiple streams with the same language the list will be "interesting" (reformatted for better comparison):

Code: Select all

[...]
[Return of the Jedi (1983) {imdb-tt0086190} - Despecialized Edition [eng, ces, deu] [720p, x264, AC3].mkv] to
[Return of the Jedi (1983) {imdb-tt0086190} [en, en, en, cs, de] [720p, x264, AC3].mkv]
[...]
or even fail completely (without error) if there are to many streams (this works with "audioLanguages"):

Code: Select all

[...]
[Star Wars (1977) {imdb-tt0076759} - Despecialized Edition [eng, deu, fra, spa, por, jpn, ita, pol, ces, hun] [720p, x264, DTS].mkv] to
[Star Wars (1977) {imdb-tt0076759} [720p, x264, DTS].mkv]
[...]
(As the code for the filebot-call and media info is to long, I posted it to https://hackmd.okfn.de/G1oyjWXoSVmbf1wemnO-rg?view)

Can filebot deduplicate the language list and can I increase the handling limit for the audio streams?

Cheers and thanks for the help,

Sna "Yes I am trying to find a one-size-fits-all format :D " fu
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Swiss german not recognized in Audiolanguagelist

Post by rednoah »

The audioLanguages built-in does lots of things, while audio.language does not. If audioLanguages does too much, then your only option is audio.language and then recreating the behaviour audioLanguages with your custom code, e.g. taking care of null values, duplicate values, etc, depending on what you're working with.


e.g. untested pseudo code:

Code: Select all

audio.findResults{ a -> any{ a.language.toLowerCase() }{ null } }.unique().take(3).toSorted()
:idea: Please read the FAQ and How to Request Help.
HellPhantom
Posts: 49
Joined: 15 Apr 2020, 10:45

Re: Swiss german not recognized in Audiolanguagelist

Post by HellPhantom »

e.g. untested pseudo code:

Code: Select all

audio.findResults{ a -> any{ a.language.toLowerCase() }{ null } }.unique().take(3).toSorted()
[/quote]

Thanks for this bit of code i have found it very helpfull.

I had to also move away from audiolanguages because it does not contain all the languages and now use audio.language instead. I was missing languages like AFR or afrikaans and a few more.
I wish audio.language also used 3 letter language codes ISO 2 instead of ISO 1. I preferred the 3 letter codes.
kim
Power User
Posts: 1251
Joined: 15 May 2014, 16:17

Re: Swiss german not recognized in Audiolanguagelist

Post by kim »

use languageString3

Code: Select all

{audio.findResults{ a -> any{ a.languageString3.toLowerCase() }{ null } }.unique().take(3).toSorted()}
HellPhantom
Posts: 49
Joined: 15 Apr 2020, 10:45

Re: Swiss german not recognized in Audiolanguagelist

Post by HellPhantom »

Thanks for the help
I see languageString3 brings the Iso 2 codes but it cuts the unknown or null languages.
I have been struggling to get what I want and i am so close but none of my solutions is 100%

This is the output that I would like. [afr, ita, rus, eng, Unknown].[Multi Audio-7] or [None]
This Example has 7 Audio Tracks. There is 2 eng and 2 Unknown tracks but they are only shown once each because the list is distinct but the count is not.
Also when there is no audio at all it should say [None], the count only shows when there is more than 1 audio.Also using ISO 2 or 3 Letter language codes.

1. This is what I was using for a long time. It threw away some languages, like the afr and some others. It also did not handle unknown well, it showed unknown when all was unknown.

Code: Select all

{any{audioLanguages}{'[Unknown]'}{audioLanguages}}{audio.Language.size() > 1 ? '.[Multi Audio-'+audio.language.size()+']' : null}
It gave me this output [ita, rus, eng].[Multi Audio-7] afr and Unknown was missing.

2. I changed it, to no longer drop certain languages, and this one worked very well except it showed null for undefined languages instead of Unknown and Iso-1 codes.

Code: Select all

{any{audio.language.unique()}{'[None]'}}{audio.language.size() > 1 ? '.[Multi Audio-'+audio.language.size()+']' : null}
it gave me this output [af, it, ru, en, null].[Multi Audio-7] and the [None] worked.
I have tried doing a replace of null or even just eng but I cant get the replaceAll('eng','Unknown') to work on audio.language field at all. Its probably not a string and an array.

3. I have Tried this statement

Code: Select all

{audio.findResults{ a -> any{ a.languageString3.toLowerCase() }{ null } }.unique()}{audio.Language.size() > 1 ? '.[Multi Audio-'+audio.language.size()+']' : null}
it gave me this output [afr, ita, rus, eng].[Multi Audio-7] It uses ISo-2 but it omits the unknown records and I could not get the none to work.
I have spend quite a bit of time on this one but I have not made any real improvement. I have a bunch of test cases and as this statement currently is it fails on many of them.

I can really use some help. Option 2 sounds easiest to fix if you know how to replace inside audio.language then I can probably live with Iso-1.
kim
Power User
Posts: 1251
Joined: 15 May 2014, 16:17

Re: Swiss german not recognized in Audiolanguagelist

Post by kim »

try this:

Code: Select all

{
	def languages = []
	any{audio.collect{ au -> languages << any{ au.'LanguageString3' }{'Unknown'}	}
	languages.unique() }{'[None]'}
}
one line

Code: Select all

{def languages = []; any{audio.collect{ au -> languages << any{ au.'LanguageString3' }{'Unknown'} }; languages.unique() }{'[None]'}}
with Multi Audio

Code: Select all

{def languages = []; any{audio.collect{ au -> languages << any{ au.'LanguageString3' }{'Unknown'} }; allOf{languages.unique()}{audio.Language.size() > 1 ? '.[Multi Audio-'+audio.language.size()+']' : null}.join() }{'[None]'}}
HellPhantom
Posts: 49
Joined: 15 Apr 2020, 10:45

Re: Swiss german not recognized in Audiolanguagelist

Post by HellPhantom »

Wonderful !!!, Thanks for taking the time to help me. It works on all my test cases.

No way I would come to this on my own. I am not that groovy with groovy.
Post Reply