[Release] Language Preference Manager

  Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
Ace Offline
Team-Kodi Member
Posts: 374
Joined: Aug 2012
Reputation: 11
Location: Germany
Post: #1
This service Add-on automatically sets the audio and/or subtitle according to your language preferences.

Features
  • changes the audio track to the first matching language preference
  • changes the subtitle track to the first matching language preference
  • changes the subtitle track to the first matching language preference depending on the selected audio language
  • changes the audio and/or subtitle track according to the file name

Screenshots

[Image: 6wtdotn.jpg]

[Image: qjW7780.jpg]

Settings

The addon is listed under programs.
  • Delay: switching an audio track to early after playback has started leads to a restart of the video. If you encouter this, try raising that value.
  • Preference categories: each category can be turn on/off individually. The evaluation order is: audio -> subtitle -> conditional subtitle.
  • Try to set the audio and/or subtitle track from the filename first: the number of the first track is 0!
    This feature works as follows:
    • only audio, only subtitle or both are possible.
    • If the audio track is set successfully the audio preference evaluation is skipped.
    • If the subtitle track is set successfully the subtitle and conditional subtitle preference evaluation is skipped.
    • If nothing is specified in the file name or the track(s) can't be set, the other preferences are evaluated.

    Code:
    The regex is "audiostream[_|.|-]*\d+|subtitle[_|.|-]*\d+"

    For example:

    matrix.audiostream_1.subtitle_2.avi
    or matrix.audiostream.1.subtitle_2.avi
    or matrix.audiostream_1.subtitle-2.avi

    will result in audio track 1 (cf. remark above) and subtitle track 2 (cf. remark above).
  • Custom audio/subtitle preference: you can specify more than 3 languages.
    The syntax is
    Code:
    lang1>lang2>lang3>... for audio and subtitles and lang1:lang2>lang3:lang4>... for conditinal subs.

    Example:
    jpn>eng>ger>fin for the audio language or jpn:eng>eng:ger>fin:jpn for the conditional subtitle
  • Custom per genre/tag audio/subtitle preference.If no genre/tag# part is provided the pref gets evaluated for any genre/tag. The syntax is
    Code:
    tag/genre1,tag/genre2...#(custom pref; see above)|tag/genre3,tag/genre4...#(custom pref; see above)

    Example:
    kids,comic#jpn>eng>ger>fin|eng>ger for the audio or sub language or kids,comic#jpn:eng|horro#eng:ger>fin:jpn|eng:non for the conditional subtitle

Current version for Gotham: 0.0.5
Current version for Frodo: 0.0.4

Sources: github repo

Changelog
Code:
--- Version 0.0.5

- Added support for multiple 3 digit codes per language (thanks to waven!)

--- Version 0.0.4

- Added a language called "None". If set as a conditinal subtitle language
subtitles get disabled if the audio language matches.

- Added support for per genre/tag custom preferences. Syntax is
tag/genre1,tag/genre2...#(custom pref; see below)|tag/genre3,tag/genre4...#(custom pref; see below)
If no genre/tag# part is provided the pref gets evaluated for any genre/tag

--- Version 0.0.3

- Custom preferences. Syntax is lang1>lang2>lang3>... for audio and sub
                            and lang1:lang2>lang3:lang4>... for cond. subs
- Wanilton's Portuguese (Brazil) translation, thanks!
- schumi2004's Dutch translation, thanks!



Problems and bugs

The addon is in an early stage of development. In order to improve it, I need your Debug log file if you encounter a bug.

Some ideas for future versions
  • production language with preferred subtitle
  • Advanced preferences using text fields
    • more than 3 languages (done)
    • own preferences per video genre (done)
  • Advanced preferences using a gui
  • Support preferences w.r.t. channels
  • Support preferences w.r.t. codecs
(This post was last modified: 2014-08-11 13:37 by Ace.)
find quote
Ned Scott Offline
Team-Kodi Wiki Guy
Posts: 21,883
Joined: Jan 2011
Reputation: 289
Location: Arizona, USA
Post: #2
If audio is Japanese then use English subtitles... dude, this is great :D

At first I wasn't sure what the point was, but the conditional subtitle feature alone is worth downloading this for. Thanks for the great add-on!

You can make easy links to the XBMC wiki using double brackets around common XBMC words: [[debug log]] = debug log, [[Video library]] = Video library, [[SMB]] = SMB , [[userdata]] = userdata, etc
find quote
rd1979 Offline
Senior Member
Posts: 243
Joined: Jul 2008
Reputation: 1
Post: #3
Thanks, this really should be a part of XBMC, thats how fundamental this functionality is.
find quote
sialivi Offline
Posting Freak
Posts: 1,162
Joined: Dec 2008
Reputation: 9
Location: Sweden
Post: #4
Great work, and as rd1979 said; It really ought to be part of XBMC.

What happens if there are multiple audio tracks with the same language but different formats?
find quote
Ace Offline
Team-Kodi Member
Posts: 374
Joined: Aug 2012
Reputation: 11
Location: Germany
Post: #5
The first matching track gets chosen at the moment. I already have something in my mind, maybe in the next version Wink
find quote
sialivi Offline
Posting Freak
Posts: 1,162
Joined: Dec 2008
Reputation: 9
Location: Sweden
Post: #6
-deleted-
(This post was last modified: 2013-01-30 16:26 by sialivi.)
find quote
Wimpie Offline
Junior Member
Posts: 28
Joined: Nov 2012
Reputation: 0
Post: #7
Hi,

Really love this...

A suggestion/feature request:

I would like to be able to select on a per movie basis another audiotrack/subtitlelanguage

This could be done in the following way.

I would name my videofiles as follows;
Annie (1982).BluRay.Audiostream_12.Subtitle_23.iso

The Language Preference Manager (LPM) would parse the filename and look for "Audiostream_x" and "Subtitle_x" strings. It would select these then.


Why in this way? Several reasons:
- Sometimes I get blu-ray images where some audiotrack has no language. I can select this adiotrack in this way (track number "x")

[Image: 36286207.png]

- I like to see a movie in it's original audio language. Subtitles are for me always dutch (unless audio is also dutch). I live in Belgium and the blurays have here sometimes 15 audiotracks (only 1 or 2 commentary tracks and thus 13 different language tracks). This gives following problems ( "Audio preferences" are prim: eng; sec; jap: third: chinese):

------ a native english movie would be correct with dutch subtitles
-------a native japanese movie would still have an english audiotrack, I would like this movie with the japanese audiotrack
------ a native chinese movie would still have an englisch audiotrack, I would like this movie with the chinese audiotrack
Putting japanese and chinese before english is also no good solution. First movies are also made in other languages (french/german/italian/....), second, most movies have a japanese/german/french/... audiotrack (dubbed) while the original language could be any language.

- My wife is from russia and we raise our children bi-lingual. Some movies for the kids/wife need to be with the russian audiotrack, even if there are english/dutch/other languages.

- I have some original russian movies (eg "9 ротa" ) that are no kids movies, I would like here dutch subtitles.

- Sometimes there are 2 correct dutch audiotracks with a movie. This is usually only with kids movies. One is the dubbed "dutch dutch" track, the other is the dubbed "flemisch dutch" track (is a little bit like US english and UK english (trunk or boot)). Flemish is not always a menu-choice, sometimes those audiotracks are both called "dutch".



If this would be implemented, then it would need to override the "audio preferences" and "subtitle preferences".
If no "Audiostream_x" and "Subtitle_x" are found in the filename, then the "audio preferences" and "subtitle preferences" select the correct language.
If only a "Audiostream_x" is found in the filename, then the subtittlelanguage could be selected with "subtitle preferences".
If only a "Subtitle_x" is found in the filename, then the audiolanguage could be selected with "Audio preferences".
If the file is named "Annie (1982).BluRay.Audiostream_12.Subtitle_23.iso" and there are only 4 audio/subtitlestreams (thus: user error), then it would fall back to the "audio preferences" and "subtitle preferences".


I would probably always put both "Audiostream_x" and "Subtitle_x" in the filename.




This could also be implemeted with the "Audiostream_x" and "Subtitle_x" as video library tags, but the wiki seems to imply that the addon would not be able to access those yet. So this would be for XBMC v13...

Probably some work, but this would make XBMC complete and perfect for me...

Thanks
find quote
N3MIS15 Offline
Donor
Posts: 504
Joined: Jul 2010
Reputation: 13
Location: Melbourne, VIC
Post: #8
The conditional subtitles intrigues me. I have all my 1:1 BR rips with subs included, but only need subs when watching foreign films. I have enable subs disabled by default and enable when needed. Will conditional subs override XBMC's "enable subtitles" feature?

[Image: all-fanart.jpg]
find quote
Ace Offline
Team-Kodi Member
Posts: 374
Joined: Aug 2012
Reputation: 11
Location: Germany
Post: #9
@Wimpie: Thanks for your comments! I have to think about it and the best way to do so, if possible.

Quote:Sometimes I get blu-ray images where some audiotrack has no language

Could be a bug/misbehaviour, I'm working on that (#2162) but haven't tested blurays yet.

Quote:------ a native english movie would be correct with dutch subtitles ...

I already thought about a language "production language", but afaik xbmc does not store this info. Maybe I can use a hand-made map like "USA - English".

Quote:Some movies for the kids/wife need to be with the russian audiotrack, even if there are english/dutch/other languages.

Here I already thought about per genre preferences.

Quote:I would like to be able to select on a per movie basis another audiotrack/subtitlelanguage

How does you know which number your preferred audio/subtitle has? If you tested/found it via xbmc isn't it saved for that movie (in xbmc's db)?












(2013-02-05 12:53)N3MIS15 Wrote:  The conditional subtitles intrigues me. I have all my 1:1 BR rips with subs included, but only need subs when watching foreign films. I have enable subs disabled by default and enable when needed. Will conditional subs override XBMC's "enable subtitles" feature?

At the moment there is no overriding. I will add a switch in the next version.
(This post was last modified: 2013-02-05 15:42 by Ace.)
find quote
Wimpie Offline
Junior Member
Posts: 28
Joined: Nov 2012
Reputation: 0
Post: #10
(2013-02-05 15:40)ace20022 Wrote:  @Wimpie: Thanks for your comments! I have to think about it and the best way to do so, if possible.

Quote:Sometimes I get blu-ray images where some audiotrack has no language

Could be a bug/misbehaviour, I'm working on that (#2162) but haven't tested blurays yet.


It's a XBMC bug. Not a Language Preference Manager bug.



(2013-02-05 15:40)ace20022 Wrote:  
Quote:------ a native english movie would be correct with dutch subtitles ...

I already thought about a language "production language", but afaik xbmc does not store this info. Maybe I can use a hand-made map like "USA - English".

I have already sorted in directories, by other criteria, my movies. It's (nearly) impossible to re-arrange them for "production language".

If you mean you would like to make a map/list with movienames/production languages, then I would preffer to tag the filename with a "Audiostream_x" tag. Can not get lost and is always for the correct movie (different version of the same movie (uncut/ dir cut/....)).


(2013-02-05 15:40)ace20022 Wrote:  
Quote:I would like to be able to select on a per movie basis another audiotrack/subtitlelanguage

How does you know which number your preferred audio/subtitle has? If you tested/found it via xbmc isn't it saved for that movie (in xbmc's db)?

I have a seperate computer with a stock XBMC to rip my blu-ray iso's. My HTPC is another computer/XBMC. I don't have a central SQL database.

The ripping is done with AnyDVD HD, to generate a full rip iso. After the rip, the iso file is put in its own directory "movie (year)" so I can start scraping with Ember media manager.

I then launch my XBMC on that computer to see what languages this movie has and if I need an external player or not (TMT). Finally I adjust the filename of the iso to whatever is needed (.Rus./.Ext_Player./.Ned./.Kiddie./....) and copy the whole dir over to my unraid server.


I like to have full control over what XMBC displays and how. Thats why I use Ember, and I would like to have this work via filename tags or, if possible, video library tags (Has my prefference, but is not yet possible, I think. I would put these video library tags also in the .nfo file).

The level of control you get is so much, much , much better than any other (programmed/conditional) way.
e.g. Without you adjusting LPM, people could use this method to select the english AC3 track instead of the english DTS-HD track. They could need it because their HTPC isn't powerfull enough to (trans/de)code DTS-HD.

And by putting this info in the filename/.nfo tag, you only have to do this once. No problem to 'lose' the XBMC DB (HD crash/...)...


Offcourse, this methods only works if an app can get the filename to parse for tags. I assume this would work. Otherwise we will have to wait until video library tags are available to apps.

Awaiting your comments....
Wimpie
find quote
stockloanban Offline
Junior Member
Posts: 1
Joined: Feb 2013
Reputation: 0
Location: NY
Post: #11
Snapshot is helpful thanks
find quote
tevi Offline
Junior Member
Posts: 27
Joined: Jul 2012
Reputation: 0
Post: #12
Could you please add the option to disable subtitles?

For my native language, I prefer subtitles off, but for Japanese, I pretty much need the subtitles on.
find quote
Ace Offline
Team-Kodi Member
Posts: 374
Joined: Aug 2012
Reputation: 11
Location: Germany
Post: #13
Hi tevi,

I will add a switch to enable subtitles only if a preference is met in the next version. This way you can disabling subtitles by default
(play a video -> open audio settings -> disable subtitles -> set as default for all videos).
find quote
tevi Offline
Junior Member
Posts: 27
Joined: Jul 2012
Reputation: 0
Post: #14
That's great.

I looked through your code to try and help, but I don't know python.

Depending on if you make the enable subtitles button require two conditions (both audio language and sub language match) you might want to add an unknown language option.

I have several shows that list the subtitle as "Unknown".
find quote
Ace Offline
Team-Kodi Member
Posts: 374
Joined: Aug 2012
Reputation: 11
Location: Germany
Post: #15
The switch will only enable subs if a subs preference or a conditional subs preference is met.
Do your videos only have one sub (the unknown one) ? Then I could add a switch to enable subs if there is just a single one available, but I'm not sure if this is useful.

Btw don't look at my code too closely, it's my first contact with python Wink
find quote
Post Reply