From 2b9179021c6a81ff4f9fed238b7556ab0874a347 Mon Sep 17 00:00:00 2001 From: rockrider69 <99220315+rockrider69@users.noreply.github.com> Date: Tue, 22 Feb 2022 15:23:39 +0100 Subject: [PATCH 01/11] Bump to v1.0.4BETA --- addon.xml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/addon.xml b/addon.xml index 817afc5..93c26b6 100644 --- a/addon.xml +++ b/addon.xml @@ -2,7 +2,7 @@ @@ -17,7 +17,8 @@ Sets the audio and subtitle track according to your language preferences For bugs, requests or general questions visit the Language Preference Manager thread on the Kodi forum. all - Updated with changes required for Kodi 19 / Python 3 + Fixed Languages labels/tables, ConditionnalSubs to None, Custom settings + 1.0.3 : Updated with changes required for Kodi 19 / Python 3 + Fixed Languages labels/tables, ConditionnalSubs to None, Custom settings + 1.0.4BETA : Conditional Subtitles rules are re-assessed on-the-fly when toggling audio tracks resources/icon.png From cca0bd73fddf3f7879003879132f8e01fbd26d54 Mon Sep 17 00:00:00 2001 From: rockrider69 <99220315+rockrider69@users.noreply.github.com> Date: Tue, 22 Feb 2022 15:26:04 +0100 Subject: [PATCH 02/11] Bump to v0.1.4BETA --- changelog.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/changelog.txt b/changelog.txt index 42481f1..5305099 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,7 @@ +--- Version 0.1.4BETA + +- Conditional subtitle logic improvement. Rules are re-evaluated and applied on-the-fly if audio track is changed during the playback. + --- Version 0.1.3 - Conditional subtitle logic adjustement : if "Lang1:None and forced tag set" then disable subtitles From 4a89b9f7a7324f9d412ab288e68132ae1d998c0f Mon Sep 17 00:00:00 2001 From: rockrider69 <99220315+rockrider69@users.noreply.github.com> Date: Tue, 22 Feb 2022 15:40:49 +0100 Subject: [PATCH 03/11] On-the-fly Conditional Subtitles adjustement Conditional subtitle logic improvement. Rules are re-evaluated and applied on-the-fly if audio track is changed during the playback. --- default.py | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/default.py b/default.py index a205ad7..230fd11 100644 --- a/default.py +++ b/default.py @@ -62,12 +62,14 @@ def _daemon( self ): class LangPrefMan_Player(xbmc.Player) : def __init__ (self): + self.LPM_initial_run_done = False xbmc.Player.__init__(self) def onAVStarted(self): if settings.service_enabled and settings.at_least_one_pref_on and self.isPlayingVideo(): log(LOG_DEBUG, 'Playback started') self.audio_changed = False + self.LPM_initial_run_done = False # switching an audio track to early leads to a reopen -> start at the beginning if settings.delay > 0: log(LOG_DEBUG, "Delaying preferences evaluation by {0} ms".format(settings.delay)) @@ -75,12 +77,28 @@ def onAVStarted(self): log(LOG_DEBUG, 'Getting video properties') self.getDetails() self.evalPrefs() + self.LPM_initial_run_done = True + def onAVChange(self): + if self.LPM_initial_run_done and settings.service_enabled and settings.at_least_one_pref_on and self.isPlayingVideo(): + log(LOG_DEBUG, 'AVChange detected - Checking possible change of audio track...') + if settings.delay > 0: + log(LOG_DEBUG, "Delaying preferences evaluation by {0} ms".format(settings.delay)) + xbmc.sleep(settings.delay) + previous_audio_index = self.selected_audio_stream['index'] + previous_audio_language = self.selected_audio_stream['language'] + log(LOG_DEBUG, 'Getting video properties') + self.getDetails() + if (self.selected_audio_stream['index'] != previous_audio_index): + log(LOG_INFO, 'Audio track changed from {0} to {1}. Reviewing Conditional Subtitles rules...'.format(previous_audio_language, self.selected_audio_stream['language'])) + self.audio_changed = True + self.evalPrefs() + def evalPrefs(self): # recognized filename audio or filename subtitle fa = False fs = False - if settings.useFilename: + if settings.useFilename and not self.LPM_initial_run_done: audio, sub = self.evalFilenamePrefs() if (audio >= 0) and audio < len(self.audiostreams): log(LOG_INFO, 'Filename preference: Match, selecting audio track {0}'.format(audio)) @@ -103,7 +121,7 @@ def evalPrefs(self): log(LOG_INFO, 'Subtitle: disabling subs' ) self.showSubtitles(False) - if settings.audio_prefs_on and not fa: + if settings.audio_prefs_on and not fa and not self.LPM_initial_run_done: if settings.custom_audio_prefs_on: trackIndex = self.evalAudioPrefs(settings.custom_audio) else: @@ -115,7 +133,7 @@ def evalPrefs(self): self.setAudioStream(trackIndex) self.audio_changed = True - if settings.sub_prefs_on and not fs: + if settings.sub_prefs_on and not fs and not self.LPM_initial_run_done: if settings.custom_sub_prefs_on: trackIndex = self.evalSubPrefs(settings.custom_subs) else: From 872f37f54dc3e181ef332636d6f2551389ab60dd Mon Sep 17 00:00:00 2001 From: rockrider69 <99220315+rockrider69@users.noreply.github.com> Date: Tue, 22 Feb 2022 15:52:16 +0100 Subject: [PATCH 04/11] Update News for 1.0.4BETA --- addon.xml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/addon.xml b/addon.xml index 93c26b6..3bfa151 100644 --- a/addon.xml +++ b/addon.xml @@ -17,8 +17,10 @@ Sets the audio and subtitle track according to your language preferences For bugs, requests or general questions visit the Language Preference Manager thread on the Kodi forum. all - 1.0.3 : Updated with changes required for Kodi 19 / Python 3 + Fixed Languages labels/tables, ConditionnalSubs to None, Custom settings - 1.0.4BETA : Conditional Subtitles rules are re-assessed on-the-fly when toggling audio tracks + + 1.0.3 : Updated with changes required for Kodi 19 / Python 3 + Fixed Languages labels/tables, ConditionnalSubs to None, Custom settings + 1.0.4BETA : Conditional Subtitles rules are re-assessed on-the-fly when toggling audio tracks + resources/icon.png From 906c31055073557fb4c56f84d4845d1adb0df7b3 Mon Sep 17 00:00:00 2001 From: rockrider69 <99220315+rockrider69@users.noreply.github.com> Date: Fri, 25 Feb 2022 12:08:29 +0100 Subject: [PATCH 05/11] Fix : reset of a key flag was done too late Earlier reset of LPM_initial_run_done flag. To avoid multiple non necessary onAVChange block execution including video getdetails JSON calls prior to any actual video stream exists --- default.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/default.py b/default.py index 230fd11..62bb96e 100644 --- a/default.py +++ b/default.py @@ -64,12 +64,16 @@ class LangPrefMan_Player(xbmc.Player) : def __init__ (self): self.LPM_initial_run_done = False xbmc.Player.__init__(self) - + + def onPlayBackStarted(self): + if settings.service_enabled and settings.at_least_one_pref_on: + log(LOG_DEBUG, 'New AV Playback initiated - Resetting LPM Initial Flag') + self.LPM_initial_run_done = False + def onAVStarted(self): if settings.service_enabled and settings.at_least_one_pref_on and self.isPlayingVideo(): log(LOG_DEBUG, 'Playback started') self.audio_changed = False - self.LPM_initial_run_done = False # switching an audio track to early leads to a reopen -> start at the beginning if settings.delay > 0: log(LOG_DEBUG, "Delaying preferences evaluation by {0} ms".format(settings.delay)) From 648c0d1b10f335b161c22e79709f32fc6f661234 Mon Sep 17 00:00:00 2001 From: rockrider69 <99220315+rockrider69@users.noreply.github.com> Date: Fri, 25 Feb 2022 15:54:55 +0100 Subject: [PATCH 06/11] Some optimisation No need for extra 4*delay wait before getting video details when the audio track changed is external to the addon. New audio track is already fully effective when we enter to the CondSub evaluation block. --- default.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/default.py b/default.py index 62bb96e..0fb54d6 100644 --- a/default.py +++ b/default.py @@ -86,6 +86,7 @@ def onAVStarted(self): def onAVChange(self): if self.LPM_initial_run_done and settings.service_enabled and settings.at_least_one_pref_on and self.isPlayingVideo(): log(LOG_DEBUG, 'AVChange detected - Checking possible change of audio track...') + self.audio_changed = False if settings.delay > 0: log(LOG_DEBUG, "Delaying preferences evaluation by {0} ms".format(settings.delay)) xbmc.sleep(settings.delay) @@ -95,7 +96,6 @@ def onAVChange(self): self.getDetails() if (self.selected_audio_stream['index'] != previous_audio_index): log(LOG_INFO, 'Audio track changed from {0} to {1}. Reviewing Conditional Subtitles rules...'.format(previous_audio_language, self.selected_audio_stream['language'])) - self.audio_changed = True self.evalPrefs() def evalPrefs(self): From ca321446c59d9c3f52b31812a1b3ec3fda6320ce Mon Sep 17 00:00:00 2001 From: rockrider69 <99220315+rockrider69@users.noreply.github.com> Date: Mon, 7 Mar 2022 22:27:57 +0100 Subject: [PATCH 07/11] Bump & news for 1.0.5 --- addon.xml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/addon.xml b/addon.xml index 3bfa151..4d20964 100644 --- a/addon.xml +++ b/addon.xml @@ -2,7 +2,7 @@ @@ -17,10 +17,9 @@ Sets the audio and subtitle track according to your language preferences For bugs, requests or general questions visit the Language Preference Manager thread on the Kodi forum. all - - 1.0.3 : Updated with changes required for Kodi 19 / Python 3 + Fixed Languages labels/tables, ConditionnalSubs to None, Custom settings - 1.0.4BETA : Conditional Subtitles rules are re-assessed on-the-fly when toggling audio tracks - + 1.0.3 : Updated with changes required for Kodi 19 / Python 3 + Fixed Languages labels/tables, ConditionnalSubs to None, Custom settings +1.0.4BETA : Conditional Subtitles rules are re-assessed on-the-fly when toggling audio tracks +1.0.5 : Some minor optimisations resources/icon.png From 1ba688f90c012287293d7d91b9d247f76eb80aeb Mon Sep 17 00:00:00 2001 From: rockrider69 <99220315+rockrider69@users.noreply.github.com> Date: Mon, 7 Mar 2022 22:31:43 +0100 Subject: [PATCH 08/11] Bump to v0.1.5 --- changelog.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/changelog.txt b/changelog.txt index 5305099..156bae3 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,7 @@ +--- Version 0.1.5 + +- Some minor optimisation in Conditional Subtitles evaluation block. + --- Version 0.1.4BETA - Conditional subtitle logic improvement. Rules are re-evaluated and applied on-the-fly if audio track is changed during the playback. From 6412725fe7d8f034deffcb1760b424c009c90de3 Mon Sep 17 00:00:00 2001 From: rockrider69 <99220315+rockrider69@users.noreply.github.com> Date: Mon, 7 Mar 2022 22:33:58 +0100 Subject: [PATCH 09/11] Bump to v0.1.5 --- addon.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addon.xml b/addon.xml index 4d20964..29b2fa5 100644 --- a/addon.xml +++ b/addon.xml @@ -19,7 +19,7 @@ all 1.0.3 : Updated with changes required for Kodi 19 / Python 3 + Fixed Languages labels/tables, ConditionnalSubs to None, Custom settings 1.0.4BETA : Conditional Subtitles rules are re-assessed on-the-fly when toggling audio tracks -1.0.5 : Some minor optimisations +1.0.5 : Some minor optimisation resources/icon.png From 374d07c2611d515c6a0c4d21a7fed23be3088495 Mon Sep 17 00:00:00 2001 From: rockrider69 <99220315+rockrider69@users.noreply.github.com> Date: Mon, 7 Mar 2022 22:55:18 +0100 Subject: [PATCH 10/11] Some more optimisations Skip extra tags/genres JSON query when no custom prefs used at all Fix preferences numbering in log messages --- default.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/default.py b/default.py index 0fb54d6..94dd453 100644 --- a/default.py +++ b/default.py @@ -169,7 +169,7 @@ def evalPrefs(self): log(LOG_INFO, 'Conditional subtitle: disabling subs' ) self.showSubtitles(False) if trackIndex == -2: - log(LOG_INFO, 'Conditional subtitle: No matching preferences found fo current audio stream. Doing nothing.') + log(LOG_INFO, 'Conditional subtitle: No matching preferences found for current audio stream. Doing nothing.') elif trackIndex >= 0: self.setSubtitleStream(trackIndex) if settings.turn_subs_on: @@ -227,6 +227,7 @@ def evalAudioPrefs(self, audio_prefs): log(LOG_INFO, 'Audio language of stream {0} matches preference {1} ({2})'.format(stream['index'], i, name) ) return stream['index'] log(LOG_INFO, 'Audio: preference {0} ({1}:{2}) not available'.format(i, name, code) ) + i += 1 return -2 def evalSubPrefs(self, sub_prefs): @@ -258,6 +259,7 @@ def evalSubPrefs(self, sub_prefs): log(LOG_INFO, 'Subtitle language of subtitle {0} matches preference {1} ({2})'.format(sub['index'], i, name) ) return sub['index'] log(LOG_INFO, 'Subtitle: preference {0} ({1}:{2}) not available'.format(i, name, code) ) + i += 1 return -2 def evalCondSubPrefs(self, condsub_prefs): @@ -307,6 +309,7 @@ def evalCondSubPrefs(self, condsub_prefs): log(LOG_INFO, 'Language of subtitle {0} matches conditional preference {1} ({2}:{3}) forced {4}'.format(sub['index'], 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) ) + i += 1 return -2 def testForcedFlag(self, forced, subName): @@ -345,6 +348,12 @@ def getDetails(self): self.audiostreams = json_response['result']['audiostreams'] self.subtitles = json_response['result']['subtitles'] log(LOG_DEBUG, json_response ) + + if (not settings.custom_condsub_prefs_on and not settings.custom_audio_prefs_on and not settings.custom_sub_prefs_on): + log(LOG_DEBUG, 'No custom prefs used at all, skipping extra Video tags/genres JSON query.') + self.genres_and_tags = set() + return + genre_tags_query_dict = {"jsonrpc": "2.0", "method": "Player.GetItem", "params": { "properties": From 567336c8eccdc19f544e22ed56044dcb77f484c8 Mon Sep 17 00:00:00 2001 From: rockrider69 <99220315+rockrider69@users.noreply.github.com> Date: Mon, 7 Mar 2022 22:59:42 +0100 Subject: [PATCH 11/11] Bump to v0.1.5 --- changelog.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/changelog.txt b/changelog.txt index 156bae3..6c2e546 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,6 +1,7 @@ --- Version 0.1.5 -- Some minor optimisation in Conditional Subtitles evaluation block. +- Fix preferences rules numbering in log messages. +- Skip extra genre/tag JSON video query when no custom prefs used at all. --- Version 0.1.4BETA