def cleanYaml(): try: config = CONF.readConfig() tvheadend.user = config["user"] tvheadend.passw = config["pass"] tvheadend.ipaddr = str(config["tvhipaddr"]) + ":" + str( config["tvhport"]) tot, ents = TVH.finishedRecordings() titles = set() for entry in ents: if "disp_title" in entry: titles.add(entry["disp_title"]) if config["Year"] is not None: ycn = ocn = 0 txy = [] while len(config["Year"]) > 0: ty = config["Year"].pop() # ty.keys() returns a 1 element list, this turns it into a string (year, ) = ty.keys() tmpyear = [] for title in ty[year]: ycn += 1 if title in titles: ocn += 1 tmpyear.append(title) if len(tmpyear) > 0: txy.append({year: tmpyear}) config["Year"] = txy print("searched {} titles, found {}".format(ycn, ocn)) CONF.writeConfig(config) except Exception as e: fname = sys._getframe().f_code.co_name errorExit(fname, e)
def progData(self, removeexisting=True): log.debug("progData") total, self.progs = TVH.finishedRecordings() self.win.set_title(f"{total} Current Recordings") tree = self.progTree(removeexisting) swin = Gtk.ScrolledWindow() swin.add(tree) # label for description self.label = Gtk.Label() self.label.set_text("") self.label.set_line_wrap(True) self.label.set_line_wrap_mode(Pango.WrapMode.WORD) self.attach(swin, 0, 0, 1, 1) self.attach(self.label, 0, 1, 1, 1) bbox = self.progButtons() self.attach(bbox, 0, 2, 1, 1)
def tvhlist(): try: print("tvheadend file lister " + tvheadend.__version__) config = CONF.readConfig() tvheadend.user = config["user"] tvheadend.passw = config["pass"] tvheadend.ipaddr = str(config["tvhipaddr"]) + ":" + str( config["tvhport"]) tot, ents = TVH.finishedRecordings() for show in ents: UT.addBaseFn(show) msg = "{}".format(show["opbase"]) msg += " {}".format(show["filename"]) print(msg) except Exception as e: fname = sys._getframe().f_code.co_name errorExit(fname, e)
def tvhdelete(): try: print("tvheadend file deletion " + tvheadend.__version__) if len(sys.argv) > 1: showfiles = sys.argv[1:] else: raise(TvhInputError("Please supply a filename")) config = CONF.readConfig() tvheadend.user = config["user"] tvheadend.passw = config["pass"] tvheadend.ipaddr = str(config["tvhipaddr"]) + ":" + str(config["tvhport"]) # ipaddr = str(config["tvhipaddr"]) + ":" + str(config["tvhport"]) # tvhauth = {"ip": ipaddr, "xuser": config["user"], "xpass": config["pass"]} tot, ents = TVH.finishedRecordings() for show in ents: if show["filename"] in showfiles: print("Deleting {}".format(show["filename"])) TVH.deleteRecording(show["uuid"]) except Exception as e: fname = sys._getframe().f_code.co_name errorExit(fname, e)
def tvhnfo(): try: print("tvheadend nfo writer " + tvheadend.__version__) if len(sys.argv) > 1: fns = sys.argv[1:] else: raise(TvhInputError("Please supply a filename")) config = CONF.readConfig() tvheadend.user = config["user"] tvheadend.passw = config["pass"] tvheadend.ipaddr = str(config["tvhipaddr"]) + ":" + str(config["tvhport"]) tot, ents = TVH.finishedRecordings() for show in ents: if show["filename"] in fns: UT.addBaseFn(show) snfo = NFO.makeProgNfo(show) nfofn = show["opbase"] + ".nfo" with open(nfofn, "w") as nfn: nfn.write(snfo) print("nfo written to {}".format(nfofn)) except Exception as e: fname = sys._getframe().f_code.co_name errorExit(fname, e)
def tvh(): try: print("tvheadend file utility " + tvheadend.__version__) config = CONF.readConfig() tvheadend.user = config["user"] tvheadend.passw = config["pass"] tvheadend.ipaddr = str(config["tvhipaddr"]) + ":" + str( config["tvhport"]) # ipaddr = str(config["tvhipaddr"]) + ":" + str(config["tvhport"]) # tvhauth = {"ip": ipaddr, "xuser": config["user"], "xpass": config["pass"]} tot, ents = TVH.finishedRecordings() exit = False while not exit: shows = CATS.setCategories(ents, config) print("\nshows: {}, uncat: {}, ignore: {}\n".format( len(shows["shows"]), len(shows["uncatshows"]), len(shows["ignores"]))) for ent in shows["shows"]: if "category" in ent: cat = ent["category"] elif "year" in ent: cat = ent["year"] else: cat = None print("{}: {}: {}: {}".format(cat, ent["disp_title"], ent["disp_subtitle"], ent["filename"])) print("\n") if len(shows["uncatshows"]) == 0: exit = True else: exit = UT.mainMenu(shows, config) except Exception as e: fname = sys._getframe().f_code.co_name errorExit(fname, e) finally: CONF.writeConfig(config)
def tvhbatch(): try: log.info("tvheadend batch utility " + tvheadend.__version__) # update kodi from last time, as hopefully, the transcode process will have done it's job updateKodi() config = CONF.readConfig() tvheadend.user = config["user"] tvheadend.passw = config["pass"] tvheadend.ipaddr = str(config["tvhipaddr"]) + ":" + str( config["tvhport"]) # ipaddr = str(config["tvhipaddr"]) + ":" + str(config["tvhport"]) # tvhauth = {"ip": ipaddr, "xuser": config["user"], "xpass": config["pass"]} tot, ents = TVH.finishedRecordings() shows = CATS.setCategories(ents, config) cn = 0 for show in shows["shows"]: UT.addBaseFn(show) moveShow(show, config) except Exception as e: fname = sys._getframe().f_code.co_name errorExit(fname, e) finally: cleanYears(config) CONF.writeConfig(config)
def test_getFinishedRecordings(): total, entries = TVH.finishedRecordings("chris", "internal") assert len(entries) == total