From 3fbe934dff233ede6c7214686adab79a5e36fa48 Mon Sep 17 00:00:00 2001 From: ace20022 Date: Tue, 4 Oct 2016 17:17:04 +0200 Subject: [PATCH] Fix for multi code support. (89f5196c17313a7eee787851b3e8d01f3ccea4d6) --- default.py | 64 +++++++++++++++++++++++++++++------------------------- 1 file changed, 34 insertions(+), 30 deletions(-) diff --git a/default.py b/default.py index 1fc7316..3044294 100644 --- a/default.py +++ b/default.py @@ -186,21 +186,23 @@ def evalAudioPrefs(self, audio_prefs): log(LOG_INFO,'Audio: genre/tag preference {0} met with intersection {1}'.format(g_t, (self.genres_and_tags & g_t))) for pref in preferences: - name, code = pref - if (code == 'non'): - log(LOG_DEBUG,'continue') - continue - if (self.selected_audio_stream and - self.selected_audio_stream.has_key('language') 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: - 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) ) - return stream['index'] - log(LOG_INFO, 'Audio: preference {0} ({1}:{2}) not available'.format(i, name, code) ) + name, codes = pref + codes = codes.split(r',') + for code in codes: + if (code == 'non'): + log(LOG_DEBUG,'continue') + continue + if (self.selected_audio_stream and + self.selected_audio_stream.has_key('language') 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: + 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) ) + return stream['index'] + log(LOG_INFO, 'Audio: preference {0} ({1}:{2}) not available'.format(i, name, code) ) return -2 def evalSubPrefs(self, sub_prefs): @@ -215,21 +217,23 @@ def evalSubPrefs(self, sub_prefs): log(LOG_INFO,'Subtitle: genre/tag preference {0} met with intersection {1}'.format(g_t, (self.genres_and_tags & g_t))) for pref in preferences: - name, code = pref - if (code == 'non'): - log(LOG_DEBUG,'continue') - continue - if (self.selected_sub and - self.selected_sub.has_key('language') and - (code == self.selected_sub['language'] or name == self.selected_sub['language'])): - log(LOG_INFO, 'Selected subtitle language matches preference {0} ({1})'.format(i, name) ) - return -1 - else: - for sub in self.subtitles: - if ((code == sub['language']) or (name == sub['language'])): - 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) ) + name, codes = pref + codes = codes.split(r',') + for code in codes: + if (code == 'non'): + log(LOG_DEBUG,'continue') + continue + if (self.selected_sub and + self.selected_sub.has_key('language') and + (code == self.selected_sub['language'] or name == self.selected_sub['language'])): + log(LOG_INFO, 'Selected subtitle language matches preference {0} ({1})'.format(i, name) ) + return -1 + else: + for sub in self.subtitles: + if ((code == sub['language']) or (name == sub['language'])): + 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) ) return -2 def evalCondSubPrefs(self, condsub_prefs):