Skip to content

Commit

Permalink
unicode correction
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberden committed May 19, 2020
1 parent cd2b575 commit bd70575
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions default.py
@@ -1,5 +1,5 @@

# -*-coding:Latin-1 -*
# -*- coding: utf-8 -*-
# Your code goes below this line

import os, sys, re
import xbmc, xbmcaddon
Expand Down Expand Up @@ -33,7 +33,11 @@ def log(level, msg):
l = xbmc.LOGINFO
elif level == LOG_DEBUG:
l = xbmc.LOGDEBUG
xbmc.log("[Language Preference Manager]: " + str(msg), l)

if isinstance(msg, dict):
xbmc.log("[Language Preference Manager]: " + str(msg), l)
else:
xbmc.log('[Language Preference Manager]: ' + msg.encode('ascii','replace'), l)


class LangPref_Monitor( xbmc.Monitor ):
Expand Down Expand Up @@ -231,13 +235,13 @@ def evalSubPrefs(self, sub_prefs):
continue

for sub in sorted(self.subtitles, key=lambda subElt: (self.isExternalSub(subElt['name']))):
log(LOG_DEBUG,'Wanted name={0}, wanted forced={1}, stream sub index={2} lang={3} name={4}, for iteration {5}'.format(name, forced, sub['index'], sub['language'], sub['name'], i))
log(LOG_DEBUG, u'Wanted name={0}, wanted forced={1}, stream sub index={2} lang={3} name={4}, for iteration {5}'.format(name, forced, sub['index'], sub['language'], sub['name'], i))
if ((code == sub['language']) or (name == sub['language'])):
if (self.testForcedFlag(forced, sub['name'])):
log(LOG_INFO, 'Subtitle language of subtitle {0} matches preference {1} ({2}) forced {3}'.format(sub['index'], i, name, forced) )
log(LOG_INFO, u'Subtitle language of subtitle {0} matches preference {1} ({2}) forced {3}'.format(sub['index'], i, name, forced) )
return sub['index']

log(LOG_INFO, 'Subtitle: preference {0} ({1}:{2}) not available'.format(i, name, code) )
log(LOG_INFO, u'Subtitle: preference {0} ({1}:{2}) not available'.format(i, name, code) )
return -2

def evalCondSubPrefs(self, condsub_prefs):
Expand Down Expand Up @@ -266,16 +270,16 @@ def evalCondSubPrefs(self, condsub_prefs):
if (self.selected_audio_stream and
self.selected_audio_stream.has_key('language') and
(audio_code == self.selected_audio_stream['language'] or audio_name == self.selected_audio_stream['language'])):
log(LOG_INFO, 'Selected audio language matches conditional preference {0} ({1}:{2}), force tag is {3}'.format(i, audio_name, sub_name, forced) )
log(LOG_INFO, u'Selected audio language matches conditional preference {0} ({1}:{2}), force tag is {3}'.format(i, audio_name, sub_name, forced) )
if (sub_code == 'non'):
return -1
else:
for sub in self.subtitles:
if ((sub_code == sub['language']) or (sub_name == sub['language'])):
if (self.testForcedFlag(forced, sub['name'])):
log(LOG_INFO, 'Language of subtitle {0} matches conditional preference {1} ({2}:{3}) forced {4}'.format(sub['index'], i, audio_name, sub_name, forced) )
log(LOG_INFO, u'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) )
log(LOG_INFO, u'Conditional subtitle: no match found for preference {0} ({1}:{2})'.format(i, audio_name, sub_name) )
return -2

def testForcedFlag(self, forced, subName):
Expand Down

0 comments on commit bd70575

Please sign in to comment.