From 755a244bab8223c5da3b0b58bf8d655bfde5a58c Mon Sep 17 00:00:00 2001 From: rockrider69 Date: Sun, 12 Nov 2023 17:48:15 +0100 Subject: [PATCH] [service.languagepreferencemanager] 1.0.2 --- service.languagepreferencemanager/addon.xml | 4 +++- .../changelog.txt | 5 ++++ .../resources/lib/prefutils.py | 23 +++++++++++++++---- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/service.languagepreferencemanager/addon.xml b/service.languagepreferencemanager/addon.xml index 3241fe6d7..75a98295e 100644 --- a/service.languagepreferencemanager/addon.xml +++ b/service.languagepreferencemanager/addon.xml @@ -2,7 +2,7 @@ @@ -24,6 +24,8 @@ 0.1.7BETA : New Keywords Blacklist to ignore chosen subtitles tracks based on name content. 1.0.0 : Mandatory clean-up to propose as candidate version for Kodi.tv addons repository. 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. diff --git a/service.languagepreferencemanager/changelog.txt b/service.languagepreferencemanager/changelog.txt index 3c8df4ce9..3f16f6ec5 100644 --- a/service.languagepreferencemanager/changelog.txt +++ b/service.languagepreferencemanager/changelog.txt @@ -1,3 +1,8 @@ +--- Version 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. + --- Version 1.0.1 - Initial version for main Kodi.tv addons repository diff --git a/service.languagepreferencemanager/resources/lib/prefutils.py b/service.languagepreferencemanager/resources/lib/prefutils.py index 6589bc5e0..7d9b9e994 100644 --- a/service.languagepreferencemanager/resources/lib/prefutils.py +++ b/service.languagepreferencemanager/resources/lib/prefutils.py @@ -150,6 +150,14 @@ def evalPrefs(self): log(LOG_DEBUG, 'Subtitle: enabling subs' ) 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): + self.seekTime(0) + else: + self.seekTime(self.getTime()-1) + def evalFilenamePrefs(self): log(LOG_DEBUG, 'Evaluating filename preferences' ) audio = -1 @@ -225,7 +233,7 @@ def evalSubPrefs(self, sub_prefs): continue if (self.selected_sub and 'language' in self.selected_sub and - ((code == self.selected_sub['language'] or name == self.selected_sub['language']) and self.testForcedFlag(forced, self.selected_sub['name']))): + ((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: @@ -236,7 +244,7 @@ def evalSubPrefs(self, sub_prefs): 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.') continue - if ((code == sub['language'] or name == sub['language']) and self.testForcedFlag(forced, sub['name'])): + if ((code == sub['language'] or name == sub['language']) and self.testForcedFlag(forced, sub['name'], sub['isforced'])): log(LOG_INFO, 'Subtitle language of subtitle {0} matches preference {1} ({2})'.format((sub['index']+1), i, name) ) return sub['index'] log(LOG_INFO, 'Subtitle: preference {0} ({1}:{2}) not available'.format(i, name, code) ) @@ -278,7 +286,7 @@ def evalCondSubPrefs(self, condsub_prefs): 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'])): + 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'] @@ -293,7 +301,7 @@ def evalCondSubPrefs(self, condsub_prefs): 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'])): + 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) ) @@ -305,10 +313,15 @@ def isSignsSub(self, subName): matches = ['signs'] return any(x in test for x in matches) - def testForcedFlag(self, forced, subName): + def testForcedFlag(self, forced, subName, subForcedTag): test = subName.lower() matches = ['forced', 'forcés'] found = any(x in test for x in matches) + # Only when looking for forced subs : + # in case the sub name is plain empty or not well documented, + # check also the sub isforced tag and consider it a match if set + if (forced and not found and subForcedTag): + found = True return ((forced == 'false') and not found) or ((forced == 'true') and found) def isExternalSub(self, subName):