Skip to content

Commit

Permalink
[service.languagepreferencemanager] 1.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
rockrider69 committed Jan 15, 2024
1 parent 9bb482a commit a9b6d67
Show file tree
Hide file tree
Showing 8 changed files with 239 additions and 67 deletions.
9 changes: 7 additions & 2 deletions service.languagepreferencemanager/addon.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<addon
id="service.languagepreferencemanager"
name="Language Preference Manager"
version="1.0.2"
version="1.0.3"
provider-name="ace20022/scott967/rockrider69"
>
<requires>
Expand All @@ -26,7 +26,12 @@
1.0.1 : Initial version for main Kodi.tv addons repository
1.0.2 : Fix 10sec latency on subs display and possible few lines lost - at video start or when switching audio.
Forced sub tracks : check also subtitle field "isforced" in case field "name" is empty or misspelled.

1.0.3 : Improve 10sec subs latency workaround: new option to disable it (default), or enable it at 'start only' or 'start+resume'.
Option to prioritize 'SignsSongs' tracks via custom conditional sub preferences. Syntax is ...>Eng:Eng-ss>...
New Keywords Blacklist for Audio tracks. Same principle as for Subtitles, based on track name, to skip some (ex. Commentary, ...)
Fix Greek and Serbian language codes according to iso639-2/T. Fix some typos.
Fix multiple 3 digit codes per language (ex. German ger,deu). Now OK also for Conditional Subtitles preferences.

</news>
<assets>
<icon>resources/icon.png</icon>
Expand Down
10 changes: 10 additions & 0 deletions service.languagepreferencemanager/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
--- Version 1.0.3

- Improve 10sec subs latency workaround: new option to disable it (default), or enable it at 'start only' or 'start+resume'.
(fast multiple resumes could sometimes generate video restart or long freeze due to large audio/video desynch)
- Option to prioritize 'SignsSongs' tracks via custom conditional sub preferences. Syntax is ...>Eng:Eng-ss>...
(Overrides general 'Ignore Signs and Songs toggle' or 'Blacklisting Signs via keyword', if ever used)
- New Keywords Blacklist for Audio tracks. Same principle as for Subtitles, based on track name, to skip some (ex. Commentary, ...)
- Fix Greek and Serbian language codes according to Iso639-2/T. Fix some typos.
- Fix support of multiple 3 digit codes per language (ex. German ger,deu). Now OK also for Conditional Subtitles preferences.

--- Version 1.0.2

- Fix 10sec latency on subs display and possible few lines lost - at video start or when switching audio.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ msgid "Delay the evaluation by the following value [ms]"
msgstr ""

msgctxt "#30113"
msgid "Turn on subtitles if a subtitle prefrence matched"
msgid "Turn on subtitles if a subtitle preference matched"
msgstr ""

msgctxt "#30114"
msgid "Turn off subtitles if no subtitle prefrence matched"
msgid "Turn off subtitles if no subtitle preference matched"
msgstr ""

msgctxt "#30115"
Expand Down Expand Up @@ -114,15 +114,43 @@ msgid "Ignore all Signs and Songs subtitles tracks"
msgstr ""

msgctxt "#30125"
msgid "Enable Keyword Blacklist"
msgid "Enable Subtitle Keyword Blacklist"
msgstr "
msgctxt "#30126"
msgid "Enter a comma-separated list of keywords to blacklist in subtitle names"
msgstr "
msgctxt "#30127"
msgid "Keyword List:"
msgid "Subtitle Keyword List:"
msgstr "
msgctxt "#30128"
msgid "Enable Audio Keyword Blacklist"
msgstr "
msgctxt "#30129"
msgid "Enter a comma-separated list of keywords to blacklist in audio names"
msgstr "
msgctxt "#30130"
msgid "Audio Keyword List:"
msgstr "
msgctxt "#30131"
msgid "Fast Subtitles Display:"
msgstr "
msgctxt "#30132"
msgid "Disabled"
msgstr "
msgctxt "#30133"
msgid "New Start only"
msgstr "
msgctxt "#30134"
msgid "Start & Resume"
msgstr "
msgctxt "#30201"
Expand Down
4 changes: 2 additions & 2 deletions service.languagepreferencemanager/resources/lib/langcodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
("Finnish" , "31", "fi", "fin", "14", 30215 ),
("French" , "8", "fr", "fre", "15", 30216 ),
("German" , "5", "de", "ger,deu", "16", 30217 ),
("Greek" , "16", "el", "ell", "17", 30218 ),
("Greek" , "16", "el", "ell,gre", "17", 30218 ),
("Hebrew" , "22", "he", "heb", "18", 30219 ),
("Hindi" , "42", "hi", "hin", "19", 30220 ),
("Hungarian" , "15", "hu", "hun", "20", 30221 ),
Expand All @@ -45,7 +45,7 @@
("Portuguese (Brazil)" , "48", "pb", "pt-br", "33", 30234 ),
("Romanian" , "13", "ro", "rum", "34", 30235 ),
("Russian" , "27", "ru", "rus", "35", 30236 ),
("Serbian" , "36", "sr", "scc", "36", 30237 ),
("Serbian" , "36", "sr", "srp,scc", "36", 30237 ),
("Slovak" , "37", "sk", "slo", "37", 30238 ),
("Slovenian" , "1", "sl", "slv", "38", 30239 ),
("Spanish" , "28", "es", "spa", "39", 30240 ),
Expand Down
15 changes: 14 additions & 1 deletion service.languagepreferencemanager/resources/lib/prefparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def __init__( self ):
self.custom_g_t_pref_delim = r'#'
self.custom_g_t_delim = r','
self.custom_condSub_delim = r':'
self.custom_subtag_delim = r'-'

def parsePrefString(self, pref_string):
preferences = []
Expand Down Expand Up @@ -79,13 +80,25 @@ def parsePref(self, prefs):
self.log(LOG_INFO, 'Custom cond subs prefs parse error: {0}'.format(pref))
else:
temp_a = (languageTranslate(pref[0], 3, 0), pref[0])
# Searching if a sub tag is present (like Eng:Eng-ss to prioritize Signs&Songs tracks)
ss_tag = 'false'
if (pref[1].find(self.custom_subtag_delim) > 0):
st_pref = pref[1].split(self.custom_subtag_delim)
if len(st_pref) != 2:
print('Custom cond subs prefs parse error: {0}'.format(pref))
else:
if (st_pref[1] == 'ss'):
ss_tag = 'true'
else:
self.log(LOG_INFO, 'Custom cond subs prefs parse error: {0}. Unknown sub tag is ignored'.format(pref))
pref[1] = st_pref[0]
temp_s = (languageTranslate(pref[1], 3, 0), pref[1])
if (temp_a[0] and temp_a[1] and temp_s[0] and temp_s[1]):
if (temp_s[1] == 'non'):
forced_tag = 'true'
else:
forced_tag = 'false'
lang_prefs.append((temp_a[0], temp_a[1], temp_s[0], temp_s[1], forced_tag))
lang_prefs.append((temp_a[0], temp_a[1], temp_s[0], temp_s[1], forced_tag, ss_tag))
else:
self.log(LOG_INFO, 'Custom cond sub prefs: lang code not found in db!'\
' Please report this: {0}:{1}'.format(temp_a, temp_s))
Expand Down
37 changes: 27 additions & 10 deletions service.languagepreferencemanager/resources/lib/prefsettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ def readSettings(self):
'cond subs on: {3}\n' \
'turn subs on: {4}, turn subs off: {5}\n' \
'signs: {15}\n' \
'blacklisted keywords: {16}\n' \
'blacklisted keywords (subtitles): {16}\n' \
'blacklisted keywords (audio): {17}\n' \
'fast subtitles display (10sec latency workaround): {18}\n' \
'use file name: {6}, file name regex: {7}\n' \
'at least one pref on: {8}\n'\
'audio prefs: {9}\n' \
Expand All @@ -65,7 +67,10 @@ def readSettings(self):
self.useFilename, self.filenameRegex, self.at_least_one_pref_on,
self.AudioPrefs, self.SubtitlePrefs, self.CondSubtitlePrefs,
self.custom_audio, self.custom_subs, self.custom_condsub, self.ignore_signs_on,
','.join(self.keyword_blacklist))
','.join(self.subtitle_keyword_blacklist),
','.join(self.audio_keyword_blacklist),
self.fast_subs_display
)
)

def readPrefs(self):
Expand All @@ -79,12 +84,19 @@ def readPrefs(self):
self.turn_subs_on = addon.getSetting('turnSubsOn') == 'true'
self.turn_subs_off = addon.getSetting('turnSubsOff') == 'true'
self.ignore_signs_on = addon.getSetting('signs') == 'true'
self.keyword_blacklist_enabled = addon.getSetting('enableKeywordBlacklist') == 'true'
self.keyword_blacklist = addon.getSetting('KeywordBlacklist')
if self.keyword_blacklist and self.keyword_blacklist_enabled:
self.keyword_blacklist = self.keyword_blacklist.lower().split(',')
self.subtitle_keyword_blacklist_enabled = addon.getSetting('enableSubtitleKeywordBlacklist') == 'true'
self.subtitle_keyword_blacklist = addon.getSetting('SubtitleKeywordBlacklist')
if self.subtitle_keyword_blacklist and self.subtitle_keyword_blacklist_enabled:
self.subtitle_keyword_blacklist = self.subtitle_keyword_blacklist.lower().split(',')
else:
self.keyword_blacklist = []
self.subtitle_keyword_blacklist = []
self.audio_keyword_blacklist_enabled = addon.getSetting('enableAudioKeywordBlacklist') == 'true'
self.audio_keyword_blacklist = addon.getSetting('AudioKeywordBlacklist')
if self.audio_keyword_blacklist and self.audio_keyword_blacklist_enabled:
self.audio_keyword_blacklist = self.audio_keyword_blacklist.lower().split(',')
else:
self.audio_keyword_blacklist = []
self.fast_subs_display = int(addon.getSetting('FastSubsDisplay'))
self.useFilename = addon.getSetting('useFilename') == 'true'
self.filenameRegex = addon.getSetting('filenameRegex')
if self.useFilename:
Expand All @@ -96,6 +108,8 @@ def readPrefs(self):
or self.condsub_prefs_on
or self.useFilename)

self.CondSubTag = 'false'

self.AudioPrefs = [(set(), [
(languageTranslate(addon.getSetting('AudioLang01'), 4, 0) ,
languageTranslate(addon.getSetting('AudioLang01'), 4, 3)),
Expand All @@ -121,21 +135,24 @@ def readPrefs(self):
languageTranslate(addon.getSetting('CondAudioLang01'), 4, 3),
languageTranslate(addon.getSetting('CondSubLang01'), 4, 0),
languageTranslate(addon.getSetting('CondSubLang01'), 4, 3),
addon.getSetting('CondSubForced01')
addon.getSetting('CondSubForced01'),
self.CondSubTag
),
(
languageTranslate(addon.getSetting('CondAudioLang02'), 4, 0),
languageTranslate(addon.getSetting('CondAudioLang02'), 4, 3),
languageTranslate(addon.getSetting('CondSubLang02'), 4, 0),
languageTranslate(addon.getSetting('CondSubLang02'), 4, 3),
addon.getSetting('CondSubForced02')
addon.getSetting('CondSubForced02'),
self.CondSubTag
),
(
languageTranslate(addon.getSetting('CondAudioLang03'), 4, 0),
languageTranslate(addon.getSetting('CondAudioLang03'), 4, 3),
languageTranslate(addon.getSetting('CondSubLang03'), 4, 0),
languageTranslate(addon.getSetting('CondSubLang03'), 4, 3),
addon.getSetting('CondSubForced03')
addon.getSetting('CondSubForced03'),
self.CondSubTag
)]
)]

Expand Down
Loading

0 comments on commit a9b6d67

Please sign in to comment.