From a4b41fb6c338ae99b99260c8132c8dd65637a278 Mon Sep 17 00:00:00 2001 From: Schimmelreiter Date: Thu, 17 Sep 2015 18:02:57 +0200 Subject: [PATCH] Revert^3 "[Autotimer] removed encoding stuff....""" While I don't see the problem, for the sake of happiness ... --- autotimer/src/AutoTimer.py | 8 ++++++++ autotimer/src/AutoTimerComponent.py | 24 +++++++++++++++++++++++- autotimer/src/AutoTimerConfiguration.py | 14 +++++++++++++- autotimer/src/AutoTimerEditor.py | 12 ++++++++++++ autotimer/src/AutoTimerResource.py | 3 +++ 5 files changed, 59 insertions(+), 2 deletions(-) mode change 100644 => 100755 autotimer/src/AutoTimer.py mode change 100644 => 100755 autotimer/src/AutoTimerEditor.py diff --git a/autotimer/src/AutoTimer.py b/autotimer/src/AutoTimer.py old mode 100644 new mode 100755 index 538b90f266..fae6e0c5a8 --- a/autotimer/src/AutoTimer.py +++ b/autotimer/src/AutoTimer.py @@ -253,6 +253,14 @@ def parseTimer(self, timer, epgcache, serviceHandler, recordHandler, checkEvtLim # Precompute timer destination dir dest = timer.destination or config.usage.default_path.value + # Workaround to allow search for umlauts if we know the encoding + match = timer.match.replace('\xc2\x86', '').replace('\xc2\x87', '') + if timer.encoding != 'UTF-8': + try: + match = match.decode('UTF-8').encode(timer.encoding) + except UnicodeDecodeError: + pass + if timer.searchType == "description": epgmatches = [] mask = (eServiceReference.isMarker | eServiceReference.isDirectory) diff --git a/autotimer/src/AutoTimerComponent.py b/autotimer/src/AutoTimerComponent.py index d68c131ad5..8e8b5bba6d 100644 --- a/autotimer/src/AutoTimerComponent.py +++ b/autotimer/src/AutoTimerComponent.py @@ -10,6 +10,9 @@ # To get preferred component from Components.config import config +# Default encoding +from Components.Language import language + class AutoTimerComponent(object): """AutoTimer Component which also handles validity checks""" @@ -48,7 +51,7 @@ def setValues(self, name, match, enabled, timespan=None, services=None, \ destination=None, include=None, matchCount=0, matchLeft=0, \ matchLimit='', matchFormatString='', lastBegin=0, justplay=False, \ avoidDuplicateDescription=0, searchForDuplicateDescription=2, bouquets=None, \ - tags=None, searchType="partial", searchCase="insensitive", \ + tags=None, encoding=None, searchType="partial", searchCase="insensitive", \ overrideAlternatives=True, timeframe=None, vps_enabled=False, \ vps_overwrite=False, setEndtime=False, series_labeling=False): self.name = name @@ -72,6 +75,7 @@ def setValues(self, name, match, enabled, timespan=None, services=None, \ self.searchForDuplicateDescription = searchForDuplicateDescription self.bouquets = bouquets self.tags = tags or [] + self.encoding = encoding or getDefaultEncoding() self.searchType = searchType self.searchCase = searchCase self.overrideAlternatives = overrideAlternatives @@ -105,6 +109,16 @@ def setBouquets(self, bouquets): bouquets = property(lambda self: self._bouquets , setBouquets) + def setEncoding(self, encoding): + if encoding == '(null)': + self._encoding = getDefaultEncoding() + elif encoding: + self._encoding = encoding + elif not self._encoding: + self._encoding = getDefaultEncoding() + + encoding = property(lambda self: self._encoding, setEncoding) + def setExclude(self, exclude): if exclude: self._exclude = ( @@ -508,6 +522,7 @@ def __copy__(self): searchForDuplicateDescription = self.searchForDuplicateDescription, bouquets = self.bouquets, tags = self.tags, + encoding = self.encoding, searchType = self.searchType, searchCase = self.searchCase, overrideAlternatives = self.overrideAlternatives, @@ -541,6 +556,7 @@ def __deepcopy__(self, memo): searchForDuplicateDescription = self.searchForDuplicateDescription, bouquets = self.bouquets[:], tags = self.tags[:], + encoding = self.encoding, searchType = self.searchType, searchCase = self.searchCase, overrideAlternatives = self.overrideAlternatives, @@ -570,6 +586,7 @@ def __repr__(self): ' (', ', '.join(( str(self.match), + str(self.encoding), str(self.searchCase), str(self.searchType), str(self.timespan), @@ -697,5 +714,10 @@ def getAlternative(self, override_service): break return override_service +def getDefaultEncoding(): + #if 'de' in language.getLanguage(): + # return 'ISO8859-15' + return 'UTF-8' + # very basic factory ;-) preferredAutoTimerComponent = lambda *args, **kwargs: AutoTimerFastscanComponent(*args, **kwargs) if config.plugins.autotimer.fastscan.value else AutoTimerComponent(*args, **kwargs) diff --git a/autotimer/src/AutoTimerConfiguration.py b/autotimer/src/AutoTimerConfiguration.py index 3aa6784547..56893cfda0 100644 --- a/autotimer/src/AutoTimerConfiguration.py +++ b/autotimer/src/AutoTimerConfiguration.py @@ -4,7 +4,7 @@ # for localized messages from . import _ -from AutoTimerComponent import preferredAutoTimerComponent +from AutoTimerComponent import preferredAutoTimerComponent, getDefaultEncoding from RecordTimer import AFTEREVENT from Tools.XMLTools import stringToXML from ServiceReference import ServiceReference @@ -111,6 +111,9 @@ def parseEntry(element, baseTimer, defaults = False): baseTimer.series_labeling = True if series_labeling == "yes" else False del series_labeling + # Read out encoding (won't change if no value is set) + baseTimer.encoding = element.get("encoding") + # Read out search type/case baseTimer.searchType = element.get("searchType", baseTimer.searchType) baseTimer.searchCase = element.get("searchCase", baseTimer.searchCase) @@ -523,6 +526,7 @@ def buildConfig(defaultTimer, timers, webif = False): list = ['\n\n\n'] append = list.append extend = list.extend + defaultEncoding = getDefaultEncoding() # This gets deleted afterwards if we do not have set any defaults append('