Add unique config option to shows

This disables the automatic detection of multiple shows with identical names,
which will add a timestamp to the filename.  With unique=true, the show is
treated as having unique episode titles, and only the first one will be
downloaded.
This commit is contained in:
Stefan Bethke 2017-09-30 11:51:16 +02:00
parent f91a6afc70
commit b77ae6c9a8
2 changed files with 21 additions and 6 deletions

View file

@ -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:

View file

@ -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