From e2a734f5718852747eb31d20c9dfb27650c1b890 Mon Sep 17 00:00:00 2001 From: Stefan Bethke Date: Mon, 17 Jul 2017 21:41:53 +0200 Subject: [PATCH] Move shows to be included to its own YAML file --- tivomirror.py | 58 +++++++++++++++++---------------------------------- 1 file changed, 19 insertions(+), 39 deletions(-) diff --git a/tivomirror.py b/tivomirror.py index f8c431e..e3d826f 100755 --- a/tivomirror.py +++ b/tivomirror.py @@ -30,6 +30,7 @@ import threading import time import urllib2 import xml.dom.minidom +import yaml host = "tivo.lassitu.de" #host = "wavehh.lassitu.de:30080" @@ -42,6 +43,7 @@ tivodecode = "tivodecode" cookies = "cookies.txt" proxies=None #proxies={"http":"http://us:8888","https":"http://us:8888"} +config = '~/.tivo/config.yaml' headers = requests.utils.default_headers() headers.update( @@ -59,42 +61,6 @@ class IncludeShow: self.timestamp = False self.includes[title] = self -IncludeShow('Splash and Bubbles') -IncludeShow('Angie Tribeca') -IncludeShow('Anthony Bourdain Parts Unknown') -IncludeShow('Better Call Saul') -IncludeShow('Brooklyn Nine-Nine') -IncludeShow('Bull') -IncludeShow('College Football') -IncludeShow('Conan') -IncludeShow("Dirk Gently's Holistic Detective Agency", short='Dirk Gently') -IncludeShow('The Expanse') -IncludeShow('Family Guy') -IncludeShow('Full Frontal With Samantha Bee', short='Full Frontal') -IncludeShow("How It's Made") -IncludeShow("How Do They Do It?") -IncludeShow("How We Got to Now With Steven Johnson") -IncludeShow('Inside Amy Schumer') -IncludeShow('Join or Die With Craig Ferguson') -IncludeShow('Last Week Tonight With John Oliver', short='John Oliver') -IncludeShow('Louie') -IncludeShow('Modern Family') -IncludeShow('MythBusters') -IncludeShow('NCIS') -IncludeShow('NCIS: New Orleans') -#IncludeShow('NFL Football') -IncludeShow('Person of Interest') -IncludeShow('Saturday Night Live', short='SNL') -IncludeShow('Sesame Street') -IncludeShow("Somebody's Gotta Do It With Mike Rowe") -IncludeShow('StarTalk') -IncludeShow('The Big Bang Theory') -IncludeShow('The Daily Show With Trevor Noah', short='Daily Show') -IncludeShow('The Late Show With Stephen Colbert', short='Colbert') -#IncludeShow('The Late Late Show With James Corden') -IncludeShow('The Muppets') -IncludeShow('The X-Files') -#IncludeShow('The Tonight Show Starring Jimmy Fallon') @@ -544,7 +510,7 @@ def printtoc(toc, downloaddb): def main(): - global ignoreepisodetitle, logger + global config, ignoreepisodetitle, logger curdir = os.getcwd() os.chdir(os.path.expanduser("~") + "/.tivo") handler = logging.handlers.RotatingFileHandler("tivomirror.log", maxBytes=2*1024*1024, backupCount=5) @@ -557,10 +523,12 @@ def main(): updateToc = False try: - options, remainder = getopt.getopt(sys.argv[1:], 'dvuT', - ['ignoreepisodetitle', 'debug', 'verbose', 'update']) + options, remainder = getopt.getopt(sys.argv[1:], 'c:dvuT', + ['config', 'ignoreepisodetitle', 'debug', 'verbose', 'update']) for opt, arg in options: + if opt in ('-c', '--config'): + config = arg if opt in ('-d', '--debug'): logger.setLevel(logging.DEBUG) if opt in ('-v', '--verbose'): @@ -571,6 +539,18 @@ def main(): if opt in ('-T', '--ignoreepisodetitle'): ignoreepisodetitle = True + config = os.path.expanduser(config) + with open(config, 'r') as ymlfile: + y = yaml.load(ymlfile) + + for show in y['shows']: + for key in show: + value = show[key] + if value and 'short' in value: + IncludeShow(key, value['short']) + else: + IncludeShow(key) + if len(remainder) >= 1: cmd = remainder[0]