diff --git a/config.yaml b/config.yaml index b827b41..fadf930 100644 --- a/config.yaml +++ b/config.yaml @@ -4,6 +4,7 @@ shows: - "Conan": - series: "Dirk Gently's Holistic Detective Agency" short: "Dirk Gently" + unique: true host: "wavehh.lassitu.de:30080" postprocess: 'NQDIR=/home/stb/.tivo/nq nq archivevideo "{item.target}"' proxies: diff --git a/tivomirror.py b/tivomirror.py index 739c753..9ed3219 100755 --- a/tivomirror.py +++ b/tivomirror.py @@ -70,8 +70,10 @@ class Config: for show in self.shows: if isinstance(show, dict): - if 'short' in show and 'series' in show: - IncludeShow(show['series'], show['short']) + if 'series' in show: + IncludeShow(show['series'], + short=show.get('short', show['series']), + unique=show.get('unique')) else: logger.error("Need either a string, or a dict with 'series' and 'short' entries for a show, got \"{}\".".format\ (show)) @@ -87,10 +89,11 @@ config = None class IncludeShow: includes = dict() - def __init__(self, title, short=None): + def __init__(self, title, short=None, unique=None): self.short = short self.title = title self.timestamp = False + self.unique = unique self.includes[title] = self @@ -316,12 +319,23 @@ class TivoToc: names[item.name] = [] names[item.name].append(item) for name in names: - if len(names[name]) > 1: - self.uniquedb[title.encode("utf-8")] = "1" + utf8title = title.encode("utf-8") + if len(names[name]) > 1 and not self.uniquedb.has_key(utf8title): + self.uniquedb[utf8title] = "1" if getattr(self.uniquedb, "sync", None) and callable(self.uniquedb.sync): self.uniquedb.sync() + # update all items based on config and uniquedb for item in self.items: - if self.uniquedb.has_key(item.title.encode("utf-8")): + multiple = None + options = IncludeShow.includes.get(title) + if options: + if options.unique: + multiple = False + if multiple == None: + utf8title = title.encode("utf-8") + if self.uniquedb.has_key(utf8title) and self.uniquedb[utf8title] == '1': + multiple = True + if multiple: item.makeNotUnique() return self.items