diff --git a/service.languagepreferencemanager/addon.xml b/service.languagepreferencemanager/addon.xml index 75a98295e..68b283de6 100644 --- a/service.languagepreferencemanager/addon.xml +++ b/service.languagepreferencemanager/addon.xml @@ -2,7 +2,7 @@ @@ -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. + resources/icon.png diff --git a/service.languagepreferencemanager/changelog.txt b/service.languagepreferencemanager/changelog.txt index 3f16f6ec5..d0440f1d9 100644 --- a/service.languagepreferencemanager/changelog.txt +++ b/service.languagepreferencemanager/changelog.txt @@ -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. diff --git a/service.languagepreferencemanager/resources/language/resource.language.en_gb/strings.po b/service.languagepreferencemanager/resources/language/resource.language.en_gb/strings.po index 252509de9..69fe17a6a 100644 --- a/service.languagepreferencemanager/resources/language/resource.language.en_gb/strings.po +++ b/service.languagepreferencemanager/resources/language/resource.language.en_gb/strings.po @@ -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" @@ -114,7 +114,7 @@ msgid "Ignore all Signs and Songs subtitles tracks" msgstr "" msgctxt "#30125" -msgid "Enable Keyword Blacklist" +msgid "Enable Subtitle Keyword Blacklist" msgstr " msgctxt "#30126" @@ -122,7 +122,35 @@ 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" diff --git a/service.languagepreferencemanager/resources/lib/langcodes.py b/service.languagepreferencemanager/resources/lib/langcodes.py index 6f4e392aa..aaec70d40 100644 --- a/service.languagepreferencemanager/resources/lib/langcodes.py +++ b/service.languagepreferencemanager/resources/lib/langcodes.py @@ -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 ), @@ -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 ), diff --git a/service.languagepreferencemanager/resources/lib/prefparser.py b/service.languagepreferencemanager/resources/lib/prefparser.py index 4fa3b01a1..a7ed5e8a9 100644 --- a/service.languagepreferencemanager/resources/lib/prefparser.py +++ b/service.languagepreferencemanager/resources/lib/prefparser.py @@ -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 = [] @@ -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)) diff --git a/service.languagepreferencemanager/resources/lib/prefsettings.py b/service.languagepreferencemanager/resources/lib/prefsettings.py index 43476518d..abe9cefe1 100644 --- a/service.languagepreferencemanager/resources/lib/prefsettings.py +++ b/service.languagepreferencemanager/resources/lib/prefsettings.py @@ -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' \ @@ -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): @@ -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: @@ -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)), @@ -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 )] )] diff --git a/service.languagepreferencemanager/resources/lib/prefutils.py b/service.languagepreferencemanager/resources/lib/prefutils.py index 7d9b9e994..9d59fb514 100644 --- a/service.languagepreferencemanager/resources/lib/prefutils.py +++ b/service.languagepreferencemanager/resources/lib/prefutils.py @@ -151,12 +151,25 @@ def evalPrefs(self): self.showSubtitles(True) # Workaround to an old Kodi bug creating 10-15 sec latency when activating a subtitle track. - # Force very short rewind to avoid 10-15sec delay and first few subtitles lines potentially lost - # but if we are very close to beginning, then restart from time 0 - if (self.getTime() <= 10): + # Force a short rewind to avoid 10-15sec delay and first few subtitles lines potentially lost + # but if we are very close to beginning, then restart from time 0 + # Ignore this workaround if fast_subs_display option is disabled (default = 0) + current_time = self.getTime() + if (settings.fast_subs_display == 0): + # Default is no seek back, which sometimes generate restart or freeze on slower systems + log(LOG_DEBUG, 'Fast Subs Display disabled - Subs display will be slightly delayed 8-10sec.') + elif (current_time <= 10 and settings.fast_subs_display >= 1): + # This is an initial start, seek back to 0 is securing subs are displayed immediately + log(LOG_DEBUG, 'Fast Subs Display on Start - Position time is {0} sec. Restart from 0.'.format(current_time)) self.seekTime(0) + elif (not self.LPM_initial_run_done and settings.fast_subs_display == 2): + # This is a resume, seek back 10sec to secure the 8sec normal Aud/Vid buffers are flushed + # Seek back less while resuming (ex. 1sec) create too many Large Audio Sync errors, with some unwanted restart from 0, or even possible bug freeze + log(LOG_DEBUG, 'Fast Subs Display on Resume - Position time is {0} sec. Resume with 10 sec rewind.'.format(current_time)) + self.seekTime(current_time - 10) else: - self.seekTime(self.getTime()-1) + # This is an Audio Track change on-the-fly or a Resume with fast_sub_display on 'Start Only', accept the subs latency to keep snappyness. No seek back at all. + log(LOG_DEBUG, 'Position time was {0} sec. Subs display slightly delayed.'.format(current_time)) def evalFilenamePrefs(self): log(LOG_DEBUG, 'Evaluating filename preferences' ) @@ -182,6 +195,7 @@ def evalFilenamePrefs(self): def evalAudioPrefs(self, audio_prefs): log(LOG_DEBUG, 'Evaluating audio preferences' ) + log(LOG_DEBUG, 'Audio names containing the following keywords are blacklisted: {0}'.format(','.join(settings.audio_keyword_blacklist))) i = 0 for pref in audio_prefs: i += 1 @@ -200,13 +214,19 @@ def evalAudioPrefs(self, audio_prefs): continue if (self.selected_audio_stream and 'language' in self.selected_audio_stream and + # filter out audio tracks matching Keyword Blacklist + not self.isInBlacklist(self.selected_audio_stream['name'],'Audio') and (code == self.selected_audio_stream['language'] or name == self.selected_audio_stream['language'])): log(LOG_INFO, 'Selected audio language matches preference {0} ({1})'.format(i, name) ) return -1 else: for stream in self.audiostreams: + # filter out audio tracks matching Keyword Blacklist + if (self.isInBlacklist(stream['name'],'Audio')): + log(LOG_INFO,'Audio: one audio track is found matching Keyword Blacklist : {0}. Skipping it.'.format(','.join(settings.audio_keyword_blacklist))) + continue if ((code == stream['language']) or (name == stream['language'])): - log(LOG_INFO, 'Audio language of stream {0} matches preference {1} ({2})'.format(stream['index'], i, name) ) + log(LOG_INFO, 'Language of Audio track {0} matches preference {1} ({2})'.format((stream['index']+1), i, name) ) return stream['index'] log(LOG_INFO, 'Audio: preference {0} ({1}:{2}) not available'.format(i, name, code) ) i += 1 @@ -214,7 +234,7 @@ def evalAudioPrefs(self, audio_prefs): def evalSubPrefs(self, sub_prefs): log(LOG_DEBUG, 'Evaluating subtitle preferences' ) - log(LOG_DEBUG, 'Subtitle names containing the following keywords are blacklisted: {0}'.format(','.join(settings.keyword_blacklist))) + log(LOG_DEBUG, 'Subtitle names containing the following keywords are blacklisted: {0}'.format(','.join(settings.subtitle_keyword_blacklist))) i = 0 for pref in sub_prefs: i += 1 @@ -233,13 +253,17 @@ def evalSubPrefs(self, sub_prefs): continue if (self.selected_sub and 'language' in self.selected_sub and + # filter out subtitles to be ignored via Signs&Songs Toggle or matching Keywords Blacklist + not self.isInBlacklist(self.selected_sub['name'],'Subtitle') and + not (settings.ignore_signs_on and self.isSignsSub(self.selected_sub['name'])) and ((code == self.selected_sub['language'] or name == self.selected_sub['language']) and self.testForcedFlag(forced, self.selected_sub['name'], self.selected_sub['isforced']))): log(LOG_INFO, 'Selected subtitle language matches preference {0} ({1})'.format(i, name) ) return -1 else: for sub in self.subtitles: - if (settings.keyword_blacklist_enabled and any(keyword in sub['name'].lower() for keyword in settings.keyword_blacklist)): - log(LOG_INFO,'SubPrefs : one subtitle track is found matching Keyword Blacklist : {0}. Skipping it.'.format(','.join(settings.keyword_blacklist))) + # filter out subtitles to be ignored via Signs&Songs Toggle or matching Keywords Blacklist + if self.isInBlacklist(sub['name'], 'Subtitle'): + log(LOG_INFO,'SubPrefs : one subtitle track is found matching Keyword Blacklist : {0}. Skipping it.'.format(','.join(settings.subtitle_keyword_blacklist))) continue if (settings.ignore_signs_on and self.isSignsSub(sub['name'])): log(LOG_INFO,'SubPrefs : ignore_signs toggle is on and one such subtitle track is found. Skipping it.') @@ -253,7 +277,7 @@ def evalSubPrefs(self, sub_prefs): def evalCondSubPrefs(self, condsub_prefs): log(LOG_DEBUG, 'Evaluating conditional subtitle preferences' ) - log(LOG_DEBUG, 'Subtitle names containing the following keywords are blacklisted: {0}'.format(','.join(settings.keyword_blacklist))) + log(LOG_DEBUG, 'Subtitle names containing the following keywords are blacklisted: {0}'.format(','.join(settings.subtitle_keyword_blacklist))) # if the audio track has been changed wait some time if (self.audio_changed and settings.delay > 0): log(LOG_DEBUG, "Delaying preferences evaluation by {0} ms".format(4*settings.delay)) @@ -270,44 +294,75 @@ def evalCondSubPrefs(self, condsub_prefs): log(LOG_INFO,'Cond Sub: genre/tag preference {0} met with intersection {1}'.format(g_t, (self.genres_and_tags & g_t))) for pref in preferences: - audio_name, audio_code, sub_name, sub_code, forced = pref - if (audio_code is None): - log(LOG_DEBUG,'continue') - continue + audio_name, audio_codes, sub_name, sub_codes, forced, ss_tag = pref + # manage multiple audio and/or subtitle 3-letters codes if present (ex. German = ger,deu) + audio_codes = audio_codes.split(r',') + sub_codes = sub_codes.split(r',') + nbr_sub_codes = len(sub_codes) - if (self.selected_audio_stream and - 'language' in self.selected_audio_stream and - (audio_code == self.selected_audio_stream['language'] or audio_name == self.selected_audio_stream['language'] or audio_code == "any")): - log(LOG_INFO, 'Selected audio language matches conditional preference {0} ({1}:{2}), force tag is {3}'.format(i, audio_name, sub_name, forced) ) - if (sub_code == "non"): - if (forced == 'true'): - log(LOG_INFO, 'Subtitle condition is None but forced is true, searching a forced subtitle matching selected audio...') - for sub in self.subtitles: - log(LOG_DEBUG, 'Looping subtitles...') - if ((audio_code == sub['language']) or (audio_name == sub['language'])): - log(LOG_DEBUG, 'One potential match found...') - if (self.testForcedFlag(forced, sub['name'], sub['isforced'])): - log(LOG_DEBUG, 'One forced match found...') - log(LOG_INFO, 'Language of subtitle {0} matches audio preference {1} ({2}:{3}) with forced overriding rule {4}'.format((sub['index']+1), i, audio_name, sub_name, forced) ) - return sub['index'] - log(LOG_INFO, 'Conditional subtitle: no match found for preference {0} ({1}:{2}) with forced overriding rule {3}'.format(i, audio_name, sub_name, forced) ) - return -1 - else: - for sub in self.subtitles: - if (settings.keyword_blacklist_enabled and any(keyword in sub['name'].lower() for keyword in settings.keyword_blacklist)): - log(LOG_INFO,'CondSubs : one subtitle track is found matching Keyword Blacklist : {0}. Skipping it.'.format(','.join(settings.keyword_blacklist))) - continue - if (settings.ignore_signs_on and self.isSignsSub(sub['name'])): - log(LOG_INFO,'CondSubs : ignore_signs toggle is on and one such subtitle track is found. Skipping it.') - continue - if ((sub_code == sub['language']) or (sub_name == sub['language'])): - if (self.testForcedFlag(forced, sub['name'], sub['isforced'])): - log(LOG_INFO, 'Language of subtitle {0} matches conditional preference {1} ({2}:{3}) forced {4}'.format((sub['index']+1), i, audio_name, sub_name, forced) ) - return sub['index'] - log(LOG_INFO, 'Conditional subtitle: no match found for preference {0} ({1}:{2})'.format(i, audio_name, sub_name) ) + for audio_code in audio_codes: + if (audio_code is None): + log(LOG_DEBUG,'continue') + continue + + if (self.selected_audio_stream and + 'language' in self.selected_audio_stream and + (audio_code == self.selected_audio_stream['language'] or audio_name == self.selected_audio_stream['language'] or audio_code == "any")): + log(LOG_INFO, 'Selected audio language matches conditional preference {0} ({1}:{2}), force tag is {3}'.format(i, audio_name, sub_name, forced) ) + for sub_code in sub_codes: + if (sub_code == "non"): + if (forced == 'true'): + log(LOG_INFO, 'Subtitle condition is None but forced is true, searching a forced subtitle matching selected audio...') + for sub in self.subtitles: + log(LOG_DEBUG, 'Looping subtitles...') + # filter out subtitles to be ignored via Signs&Songs Toggle or matching Keywords Blacklist + if self.isInBlacklist(sub['name'], 'Subtitle'): + log(LOG_INFO,'CondSubs : one subtitle track is found matching Keyword Blacklist : {0}. Skipping it.'.format(','.join(settings.subtitle_keyword_blacklist))) + continue + if (settings.ignore_signs_on and self.isSignsSub(sub['name'])): + log(LOG_INFO,'CondSubs : ignore_signs toggle is on and one such subtitle track is found. Skipping it.') + continue + if ((audio_code == sub['language']) or (audio_name == sub['language'])): + log(LOG_DEBUG, 'One potential match found...') + if (self.testForcedFlag(forced, sub['name'], sub['isforced'])): + log(LOG_DEBUG, 'One forced match found...') + log(LOG_INFO, 'Language of subtitle {0} matches audio preference {1} ({2}:{3}) with forced overriding rule {4}'.format((sub['index']+1), i, audio_name, sub_name, forced) ) + return sub['index'] + log(LOG_INFO, 'Conditional subtitle: no match found for preference {0} ({1}:{2}) with forced overriding rule {3}'.format(i, audio_name, sub_name, forced)) + return -1 + else: + for sub in self.subtitles: + # take into account -ss tag to prioritize specific Signs&Songs subtitles track + if ((sub_code == sub['language']) or (sub_name == sub['language'])): + if (ss_tag == 'true' and self.isSignsSub(sub['name'])): + log(LOG_INFO, 'Language of subtitle {0} matches conditional preference {1} ({2}:{3}) SubTag {4}'.format((sub['index']+1), i, audio_name, sub_name, ss_tag) ) + return sub['index'] + # filter out subtitles to be ignored via Signs&Songs Toggle or matching Keywords Blacklist + if self.isInBlacklist(sub['name'], 'Subtitle'): + log(LOG_INFO,'CondSubs : one subtitle track is found matching Keyword Blacklist : {0}. Skipping it.'.format(','.join(settings.subtitle_keyword_blacklist))) + continue + if (settings.ignore_signs_on and self.isSignsSub(sub['name'])): + log(LOG_INFO,'CondSubs : ignore_signs toggle is on and one such subtitle track is found. Skipping it.') + continue + if ((sub_code == sub['language']) or (sub_name == sub['language'])): + if (ss_tag == 'false' and self.testForcedFlag(forced, sub['name'], sub['isforced'])): + log(LOG_INFO, 'Language of subtitle {0} matches conditional preference {1} ({2}:{3}) forced {4}'.format((sub['index']+1), i, audio_name, sub_name, forced) ) + return sub['index'] + nbr_sub_codes -= 1 + if nbr_sub_codes == 0: + log(LOG_INFO, 'Conditional subtitle: no match found for preference {0} ({1}:{2})'.format(i, audio_name, sub_name) ) i += 1 return -2 + def isInBlacklist(self, TrackName, TrackType): + found = False + test = TrackName.lower() + if (TrackType == 'Subtitle' and settings.subtitle_keyword_blacklist_enabled and any(keyword in test for keyword in settings.subtitle_keyword_blacklist)): + found = True + elif (TrackType == 'Audio' and settings.audio_keyword_blacklist_enabled and any(keyword in test for keyword in settings.audio_keyword_blacklist)): + found = True + return found + def isSignsSub(self, subName): test = subName.lower() matches = ['signs'] diff --git a/service.languagepreferencemanager/resources/settings.xml b/service.languagepreferencemanager/resources/settings.xml index 0b92ffb63..e332f3d99 100644 --- a/service.languagepreferencemanager/resources/settings.xml +++ b/service.languagepreferencemanager/resources/settings.xml @@ -57,11 +57,11 @@ - + false - + true @@ -71,10 +71,10 @@ false - true + true - + true @@ -83,10 +83,54 @@ 30127 - true + true + + + false + + + + + + true + + + 30129 + + false + + true + + + + + + true + + + 30130 + + + true + + + + + + 0 + + + + + + + + + +