Page 1 of 1

Title based on language either in metadata or in dir/filename?

Posted: 05 Aug 2020, 13:13
by abandonow
Bad title, but not sure how to word it.

I have a few languages I can read/write, and if a media language in one of those languages, I would prefer use the original title in the name (the rest would be in english).

What is the best practice to do this?

Should you look for language in the meta data, and decide from there? Or should you go with language tag in the directory and/or filename (most releases is tagged with language)?

Appreciate all input. :)

(I've tried reading existing posts, but not getting that much smarter)

Re: Title based on language either in metadata or in dir/filename?

Posted: 05 Aug 2020, 13:31
by rednoah
You might be able to make it work with the {localize} dynamic localization binding:
viewtopic.php?t=3761

Re: Title based on language either in metadata or in dir/filename?

Posted: 05 Aug 2020, 22:48
by abandonow
Thank you, appreciate your pointers! :)

Could you please explain how you select which language(s) to use on the first example in the link? I can't see any references to any language.

Re: Title based on language either in metadata or in dir/filename?

Posted: 06 Aug 2020, 03:50
by rednoah
rednoah wrote: 12 May 2016, 13:21 Use primary spoken language (as per TheMovieDB) for dynamic localization:

Code: Select all

{localize[languages[0]].n}
If the media file contains a Japanese audio stream (as per MediaInfo), then localize series name to Japanese, otherwise use default name:

Code: Select all

{audio.language =~ /ja/ ? localize.ja.n : n}


1. Language of the first Audio Stream:

Code: Select all

audio[0].language
2. Name in Japanese:

Code: Select all

localize['ja'].n
1+2=3. Name in Language of the first Audio Stream

Code: Select all

localize[audio[0].language].n


Copy & Paste Solution:

Code: Select all

{
	def a = audio[0].language
	if (a =~ /en|de|ja/)
		localize[a].n
	else
		n
}

Re: Title based on language either in metadata or in dir/filename?

Posted: 06 Aug 2020, 09:07
by abandonow
Thank you for the explanation! I think I get it now. I'll test it out. :)

Re: Title based on language either in metadata or in dir/filename?

Posted: 06 Aug 2020, 09:53
by abandonow
Any way to use plex.derive instead of n?

Re: Title based on language either in metadata or in dir/filename?

Posted: 06 Aug 2020, 10:13
by rednoah
Yes:

Code: Select all

{
	def a = audio[0].language
	if (a =~ /en|de|ja/)
		localize[a].plex
	else
		plex
}

Re: Title based on language either in metadata or in dir/filename?

Posted: 06 Aug 2020, 11:16
by abandonow
Thanks!

I sort of got it to work on movies, but I had to repeat the naming scheme. How would you go about to avoid repeating all the naming schemes for a cleaner file (and only needing to edit one place)?

Code: Select all

movies/{
    def a = audio[0].language
    if (a =~ /no|nn|nb|da|sv/)
        localize[a].plex.derive
        {" " + tags} 
    {" " + [fn.match(/(?i)nordic|norwegian|danish|swedish/).upper()]} 
    {" " + [allOf 
        {allOf 
            {vf} 
            {hdr}
            .join(" ")
        } 
        {source} 
        {allOf 
            {ac} 
            {channels}
            .join(" ")
        } 
        {allOf
            {vc} 
            {if (bitdepth == 10)"10bit"}
            .join(" ")
        }
        .join(" - ")]
  }
  .tail
    else
        plex.derive
    {" " + tags} 
    {" " + [fn.match(/(?i)nordic|norwegian|danish|swedish/).upper()]} 
    {" " + [allOf 
        {allOf 
            {vf} 
            {hdr}
            .join(" ")
        } 
        {source} 
        {allOf 
            {ac} 
            {channels}
            .join(" ")
        } 
        {allOf
            {vc} 
            {if (bitdepth == 10)"10bit"}
            .join(" ")
        }
        .join(" - ")]
  }
  .tail
}
and trying the same on series gives me noname files on the non-english ones.

Log (Peppa Pig = English version, Peppa gris = norwegian version):

Code: Select all

Parameter: seriesFormat = series/{
    def a = audio[0].language
    if (a =~ /no|nn|nb|da|sv/)
        localize[a].plex.derive
    {" " + tags}
    {" " + [fn.match(/(?i)nordic|norwegian|danish|swedish/).upper()]}
    {" " + [allOf
        {allOf
            {vf}
            {hdr}
            .join(" ")
        }
        {source}
        {allOf
            {ac}
            {channels}
            .join(" ")
        }
        {allOf
            {vc}
            {if (bitdepth == 10)"10bit"}
            .join(" ")
        }
        .join(" - ")]
  }
  .tail
   else
   plex.derive
    {" " + tags}
    {" " + [fn.match(/(?i)nordic|norwegian|danish|swedish/).upper()]}
    {" " + [allOf
        {allOf
            {vf}
            {hdr}
            .join(" ")
        }
        {source}
        {allOf
            {ac}
            {channels}
            .join(" ")
        }
        {allOf
            {vc}
            {if (bitdepth == 10)"10bit"}
            .join(" ")
        }
        .join(" - ")]
  }
  .tail
}
Argument[0]: /mnt/<server>/test/filebot/testmedia/series
Input: /mnt/<server>/test/filebot/testmedia/series/Peppa.Gris.S01E01.720p.WEB-DL.x264-NRKCap.mkv
Input: /mnt/<server>/test/filebot/testmedia/series/Peppa.Gris.S01E02.720p.WEB-DL.x264-NRKCap.mkv
Input: /mnt/<server>/test/filebot/testmedia/series/Peppa.Pig.S01E01.Muddy.Puddles.1080p.Web.x265.10bit.Tigole-QxR/Peppa.Pig.S01E01.Muddy.Puddles.1080p.Web.x265.10bit.Tigole-QxR.mkv
Input: /mnt/<server>/test/filebot/testmedia/series/Peppa.Pig.S01E02.Mr.Dinosaur.Is.Lost.1080p.Web.x265.10bit.Tigole-QxR/Peppa.Pig.S01E02.Mr.Dinosaur.Is.Lost.1080p.Web.x265.10bit.Tigole-QxR.mkv
Input: /mnt/<server>/test/filebot/testmedia/series/Peppa.Pig.S01E03.Best.Friend.1080p.Web.x265.10bit.Tigole-QxR/Peppa.Pig.S01E03.Best.Friend.1080p.Web.x265.10bit.Tigole-QxR.mkv
Group: {Series=peppa gris} => [Peppa.Gris.S01E01.720p.WEB-DL.x264-NRKCap.mkv, Peppa.Gris.S01E02.720p.WEB-DL.x264-NRKCap.mkv]
Group: {Series=peppa pig} => [Peppa.Pig.S01E01.Muddy.Puddles.1080p.Web.x265.10bit.Tigole-QxR.mkv, Peppa.Pig.S01E02.Mr.Dinosaur.Is.Lost.1080p.Web.x265.10bit.Tigole-QxR.mkv, Peppa.Pig.S01E03.Best.Friend.1080p.Web.x265.10bit.Tigole-QxR.mkv]
Rename episodes using [TheTVDB] with [Airdate Order]
Auto-detected query: [Peppa Gris]
Fetching episode data for [Peppa Pig]
[SYMLINK] from [/mnt/<server>/test/filebot/testmedia/series/Peppa.Gris.S01E01.720p.WEB-DL.x264-NRKCap.mkv] to [/mnt/<server>/test/filebot/fb/series/.mkv]
Skipped [/mnt/<server>/test/filebot/testmedia/series/Peppa.Gris.S01E02.720p.WEB-DL.x264-NRKCap.mkv] because [/mnt/<server>/test/filebot/fb/series/.mkv] already exists
Processed 1 file
Rename episodes using [TheTVDB] with [Airdate Order]
Auto-detected query: [Peppa Pig]
Fetching episode data for [Peppa Pig]
[SYMLINK] from [/mnt/<server>/test/filebot/testmedia/series/Peppa.Pig.S01E01.Muddy.Puddles.1080p.Web.x265.10bit.Tigole-QxR/Peppa.Pig.S01E01.Muddy.Puddles.1080p.Web.x265.10bit.Tigole-QxR.mkv] to [/mnt/<server>/test/filebot/fb/series/Peppa Pig/Season 01/Peppa Pig - S01E01 - Muddy Puddles [1080p - Web - AAC 2.0 - x265 10bit].mkv]
[SYMLINK] from [/mnt/<server>/test/filebot/testmedia/series/Peppa.Pig.S01E02.Mr.Dinosaur.Is.Lost.1080p.Web.x265.10bit.Tigole-QxR/Peppa.Pig.S01E02.Mr.Dinosaur.Is.Lost.1080p.Web.x265.10bit.Tigole-QxR.mkv] to [/mnt/<server>/test/filebot/fb/series/Peppa Pig/Season 01/Peppa Pig - S01E02 - Mr Dinosaur is Lost [1080p - Web - AAC 2.0 - x265 10bit].mkv]
[SYMLINK] from [/mnt/<server>/test/filebot/testmedia/series/Peppa.Pig.S01E03.Best.Friend.1080p.Web.x265.10bit.Tigole-QxR/Peppa.Pig.S01E03.Best.Friend.1080p.Web.x265.10bit.Tigole-QxR.mkv] to [/mnt/<server>/test/filebot/fb/series/Peppa Pig/Season 01/Peppa Pig - S01E03 - Best Friend [1080p - Web - AAC 2.0 - x265 10bit].mkv]
Processed 3 files
Done ヾ(@⌒ー⌒@)ノ

Re: Title based on language either in metadata or in dir/filename?

Posted: 06 Aug 2020, 11:32
by rednoah
e.g.

Code: Select all

{
	def a = audio[0].language
	(a =~ (/en|de|ja/) ? localize[a].plex : plex)
	.derive
		{" by $director"}
		{" [$vf, $vc, $ac]"}
}

Re: Title based on language either in metadata or in dir/filename?

Posted: 06 Aug 2020, 12:19
by abandonow
Thanks, works on movies, but not on series – it still gives me noname files on the non-english ones:

Logfile:

Code: Select all

Run script [fn:amc] at [Thu Aug 06 14:09:16 CEST 2020]
Parameter: minLengthMS = 1
Parameter: minFileSize = 1
Parameter: seriesFormat = series/{
  def a = audio[0].language
    (a =~ (/no|nn|nb|da|sv/) ? localize[a].plex : plex)
    .derive 
    {" " + tags} 
    {" " + [fn.match(/(?i)nordic|norwegian|danish|swedish/).upper()]} 
    {" " + [allOf 
        {allOf 
            {vf} 
            {hdr}
            .join(" ")
        } 
        {source} 
        {allOf 
            {ac} 
            {channels}
            .join(" ")
        } 
        {allOf
            {vc} 
            {if (bitdepth == 10)"10bit"}
            .join(" ")
        }
        .join(" - ")]
  }
  .tail
}
Argument[0]: /mnt/<server>/test/filebot/testmedia/series/
Input: /mnt/<server>/test/filebot/testmedia/series/Peppa.Gris.S01E01.720p.WEB-DL.x264-NRKCap.mkv
Input: /mnt/<server>/test/filebot/testmedia/series/Peppa.Gris.S01E02.720p.WEB-DL.x264-NRKCap.mkv
Input: /mnt/<server>/test/filebot/testmedia/series/Peppa.Pig.S01E01.Muddy.Puddles.1080p.Web.x265.10bit.Tigole-QxR/Peppa.Pig.S01E01.Muddy.Puddles.1080p.Web.x265.10bit.Tigole-QxR.mkv
Input: /mnt/<server>/test/filebot/testmedia/series/Peppa.Pig.S01E02.Mr.Dinosaur.Is.Lost.1080p.Web.x265.10bit.Tigole-QxR/Peppa.Pig.S01E02.Mr.Dinosaur.Is.Lost.1080p.Web.x265.10bit.Tigole-QxR.mkv
Input: /mnt/<server>/test/filebot/testmedia/series/Peppa.Pig.S01E03.Best.Friend.1080p.Web.x265.10bit.Tigole-QxR/Peppa.Pig.S01E03.Best.Friend.1080p.Web.x265.10bit.Tigole-QxR.mkv
Group: {Series=peppa gris} => [Peppa.Gris.S01E01.720p.WEB-DL.x264-NRKCap.mkv, Peppa.Gris.S01E02.720p.WEB-DL.x264-NRKCap.mkv]
Group: {Series=peppa pig} => [Peppa.Pig.S01E01.Muddy.Puddles.1080p.Web.x265.10bit.Tigole-QxR.mkv, Peppa.Pig.S01E02.Mr.Dinosaur.Is.Lost.1080p.Web.x265.10bit.Tigole-QxR.mkv, Peppa.Pig.S01E03.Best.Friend.1080p.Web.x265.10bit.Tigole-QxR.mkv]
Rename episodes using [TheTVDB] with [Airdate Order]
Auto-detected query: [Peppa Gris]
Fetching episode data for [Peppa Pig]
[SYMLINK] from [/mnt/<server>/test/filebot/testmedia/series/Peppa.Gris.S01E01.720p.WEB-DL.x264-NRKCap.mkv] to [/mnt/<server>/test/filebot/fb/series/.mkv]
Skipped [/mnt/<server>/test/filebot/testmedia/series/Peppa.Gris.S01E02.720p.WEB-DL.x264-NRKCap.mkv] because [/mnt/<server>/test/filebot/fb/series/.mkv] already exists
Processed 1 file
Rename episodes using [TheTVDB] with [Airdate Order]
Auto-detected query: [Peppa Pig]
Fetching episode data for [Peppa Pig]
[SYMLINK] from [/mnt/<server>/test/filebot/testmedia/series/Peppa.Pig.S01E01.Muddy.Puddles.1080p.Web.x265.10bit.Tigole-QxR/Peppa.Pig.S01E01.Muddy.Puddles.1080p.Web.x265.10bit.Tigole-QxR.mkv] to [/mnt/<server>/test/filebot/fb/series/Peppa Pig/Season 01/Peppa Pig - S01E01 - Muddy Puddles [1080p - Web - AAC 2.0 - x265 10bit].mkv]
[SYMLINK] from [/mnt/<server>/test/filebot/testmedia/series/Peppa.Pig.S01E02.Mr.Dinosaur.Is.Lost.1080p.Web.x265.10bit.Tigole-QxR/Peppa.Pig.S01E02.Mr.Dinosaur.Is.Lost.1080p.Web.x265.10bit.Tigole-QxR.mkv] to [/mnt/<server>/test/filebot/fb/series/Peppa Pig/Season 01/Peppa Pig - S01E02 - Mr Dinosaur is Lost [1080p - Web - AAC 2.0 - x265 10bit].mkv]
[SYMLINK] from [/mnt/<server>/test/filebot/testmedia/series/Peppa.Pig.S01E03.Best.Friend.1080p.Web.x265.10bit.Tigole-QxR/Peppa.Pig.S01E03.Best.Friend.1080p.Web.x265.10bit.Tigole-QxR.mkv] to [/mnt/<server>/test/filebot/fb/series/Peppa Pig/Season 01/Peppa Pig - S01E03 - Best Friend [1080p - Web - AAC 2.0 - x265 10bit].mkv]
Processed 3 files
Done ヾ(@⌒ー⌒@)ノ

Re: Title based on language either in metadata or in dir/filename?

Posted: 06 Aug 2020, 13:26
by rednoah
Open the Format Editor and then test your format element by element until you find the element that is not working as expected. The command-line won't show format element warnings, so debugging will be unnecessarily difficult if we just look at the console output.


:idea: Match files as usual, and then Double-Click the New Names item and then Edit Format to open a Format Editor with for a File / Episode match so that you can prototype things on your specific files rather than generic sample data.

Re: Title based on language either in metadata or in dir/filename?

Posted: 06 Aug 2020, 13:35
by abandonow
Will do that. The strange thing is that it's the exact same as the movies – so it should work afaik.

Can I use multiline input in the format editor?

Re: Title based on language either in metadata or in dir/filename?

Posted: 06 Aug 2020, 13:59
by rednoah
:idea: localize fails because nn is an unsupported language code.

Image

Re: Title based on language either in metadata or in dir/filename?

Posted: 06 Aug 2020, 14:11
by abandonow
But why does it not fail on Movies too, since that also has nn?

And nn should be a language code: https://www.wikiwand.com/en/List_of_ISO_639-1_codes (norwegian nynorsk)

Re: Title based on language either in metadata or in dir/filename?

Posted: 06 Aug 2020, 15:07
by rednoah
abandonow wrote: 06 Aug 2020, 14:11 But why does it not fail on Movies too, since that also has nn?
If audio[0].language is nn then it will fail. If audio[0].language is no then it will work. Your movie file just so happens to fall into the latter category.



abandonow wrote: 06 Aug 2020, 14:11 And nn should be a language code: https://www.wikiwand.com/en/List_of_ISO_639-1_codes (norwegian nynorsk)
FileBot / TheTVDB / TheMovieDB only support a small set of relatively common languages.

If you want the Norwegian language data for any Norwegian-ish language, then you can do the appropriate mapping like so:

Code: Select all

def a = audio[0].language
a = a.replace('nn':'no', 'nb':'no')

Re: Title based on language either in metadata or in dir/filename?

Posted: 06 Aug 2020, 21:42
by kim
themoviedb does support no, nb and nn, but looks like people are bad at adding info + I think it default back to NO if no info in the others
https://developers.themoviedb.org/3/get ... /languages

always use NO on themoviedb... I have never seen the need to use nb or nn

Re: Title based on language either in metadata or in dir/filename?

Posted: 07 Aug 2020, 02:48
by rednoah
Unfortunately, localize can only work for languages explicitly supported by FileBot.


You can run {localize} in the Format Editor to see the full list of available language keys:

Code: Select all

{localize}
Image

Re: Title based on language either in metadata or in dir/filename?

Posted: 07 Aug 2020, 18:30
by abandonow
Thanks for the info.

@kim – have your shared your setup? Would be interesting to see if what you use? :)

Re: Title based on language either in metadata or in dir/filename?

Posted: 08 Aug 2020, 02:14
by kim
don't use NO, but I have this (I neeeed full control ;) ):
viewtopic.php?f=4&t=10642#p43214