Get Dub & Subs from filename?

Any questions? Need some help?
Post Reply
Elamania
Posts: 39
Joined: 07 Sep 2015, 23:00

Get Dub & Subs from filename?

Post by Elamania »

Hi, how can I get the spoken Language and Subtitles from Filenames?
I already have an format but it doesn´t work every time.

Code: Select all

{getSpokenFromAttribute = {Set<String> audios = audios.language; String res="";audios.contains('en') ? res+="Eng" : '';audios.contains('de') ? res+="Ger" : ''; audios.contains('ja') ? res+="Jap" : '';"["+res+"-Dub]";};null}
{getSubsFromAttribute ={Set<String> langs = texts.language;String result=""; langs.contains("en") ? result +="Eng" : ""; langs.contains("de") ? result+="Ger" :""; langs.contains("ja") ? result+="Jap" : "";"["+result +"-Sub]";};null}
{detectSubs={texts ? getSubsFromAttribute() : (fn.match(/(Ger|ger|eng|Eng)[ ._-]Sub|sub/)||fn.match(/GerSub/)) ? "[Ger-Sub]" : "fail"};null}
{detectSpoken={(!audios.language.equals(null)||!audios.language=="undefined"||!audios.language.equals("undefined")) ? getSpokenFromAttribute(): fn.match(/(jap|Jap)-Dub/) ? "[Jap-Dub]" : "fail"};null}
My output shall be:(if any)
[EngGerJap-Dub]
[EngGer-Sub]

my input can look like:
[eng sub]; [Eng Sub]; [Eng-sub]; [ENG]; eng-sub....etc

Currently sitting an hour at this, although it already worked lol
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Get Dub & Subs from filename?

Post by rednoah »

Note that some container formats (e.g. avi) simply don't contain the information you seek. MKV files are usually well tagged, so you usually do get language metadata for each audio or subtitle track.

Here's how I'd write it:

Code: Select all

{allOf
	{ [audioLanguages, 'Dub'] }
	{ [textLanguages,  'Sub'] }
	.collect{ 
		'[' + it[0].ISO3*.upperInitial().join() + '-' + it[1] + ']'
	}.join(' ')
}
:idea: Please read the FAQ and How to Request Help.
Elamania
Posts: 39
Joined: 07 Sep 2015, 23:00

Re: Get Dub & Subs from filename?

Post by Elamania »

Yeah i knew, thanks.
That´s why I am asking how I can get the data just form the Filename.

If I understand that pattern correctly you just take the audiolangugaes and behind that an Dub. Then you are adding an "-". However what will happen if I have more than one language ? I can´t see that. And what´s ISO3* ?

However it doesn´t seem to be working correctly.
All the files are untagged! They are all with Jap Dub and with or without Eng Sub. (checked with Mediainfo & VLC)

Code: Select all

Moviename [Eng sub] [8 -bit]   -> [Eng-Dub] [-Sub]
Showname - Showsubname - The Animation Vol.01 [Eng sub] [SubDesu] -> [-Dub][-Sub]
Showname - 01 [Subdesu] -> [-Dub][-Sub]
Would be nice if it would correctly map Sub and Dub and not show anything if it can´t read anything.
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Get Dub & Subs from filename?

Post by rednoah »

1.
You could parse the information from the filename. It's tricky and assumes that it's easy to parse.

2.
The format works as expected for files without audio/subtitle streams. What version of FileBot are you using?
:idea: Please read the FAQ and How to Request Help.
Elamania
Posts: 39
Joined: 07 Sep 2015, 23:00

Re: Get Dub & Subs from filename?

Post by Elamania »

1.) Yes, that´s exactly what I want. In the first post I have provided my pattern what works for some Files and for others it doesn´t. Any rec how to do it properly?
2.) Lol, just updated and it works better. And I just released that a lot of Episodes are completely wrongly tagged. So, I will definitely need to make it with the Filename´s information.

How can I change the output of your Snippet?
I get [Jpn-Dub] or [DeuEng-Sub] or [Expression yeields empty value]
How can I set the last one to " " and how can I tranlate Jpn -> Jap or Deu to Ger ?

And not alway the sub/dub is written in the filename but nearly always the Subgroup. Can I somehow prodive an List like Subdesu and if the pattern finds it but no sub information it adds eng-sub ?
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Get Dub & Subs from filename?

Post by rednoah »

1.
Anything is possible, but it's not always easy. I can't do it for you, but here's a small example for matching regex patterns from a String:

Code: Select all

'Avatar [eng]'.match(/\[\w+\]/)

2.
You could use the ISO3B property instead of the ISO3 property to get the bibliographic 3-letter codes.
:idea: Please read the FAQ and How to Request Help.
Post Reply