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 tvhwatchlist(): try: log.info("tvheadend watch utility " + tvheadend.__version__) config = CONF.readConfig() db = tvheadend.tvhdb.TVHDb(config["tvhdb"]) listFilesWaiting(db) except Exception as e: fname = sys._getframe().f_code.co_name errorExit(fname, e)
def tvhPrograms(start=0, length=2): try: print("tvheadend enabled channel lister " + tvheadend.__version__) config = CONF.readConfig() tvheadend.user = config["user"] tvheadend.passw = config["pass"] tvheadend.ipaddr = str(config["tvhipaddr"]) + ":" + str( config["tvhport"]) TVH.timeSlotPrograms(start, length) except Exception as e: fname = sys._getframe().f_code.co_name errorExit(fname, e)
def doFile(): try: log.info("tvheadend TS file insert utility " + tvheadend.__version__) config = CONF.readConfig() db = tvheadend.tvhdb.TVHDb(config["tvhdb"]) if len(sys.argv) > 1: for fn in sys.argv[1:]: processFile(fn, db) else: sys.exit(USAGE) except Exception as e: fname = sys._getframe().f_code.co_name errorExit(fname, e)
def main(): try: log.info("tvheadend db insert utility " + tvheadend.__version__) config = CONF.readConfig() db = tvheadend.tvhdb.TVHDb(config["tvhdb"]) with open("/home/chris/Videos/kmedia/TV/mpeg-todo", "r") as ifn: lines = ifn.readlines() for line in lines: fqfn = line.strip() log.info("processing {}".format(fqfn)) processFile(fqfn, db) log.info("done") except Exception as e: fname = sys._getframe().f_code.co_name errorExit(fname, e)
def tvhChannels(channel="BBC ONE HD"): try: print("tvheadend enabled channel lister " + tvheadend.__version__) config = CONF.readConfig() tvheadend.user = config["user"] tvheadend.passw = config["pass"] tvheadend.ipaddr = str(config["tvhipaddr"]) + ":" + str( config["tvhport"]) sents = TVH.channels() for chan in sents: print(UT.padStr(str(chan["number"]), 3), chan["name"]) TVH.channelPrograms(channel) except Exception as e: fname = sys._getframe().f_code.co_name errorExit(fname, e)
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 main(): try: log.info("tvheadend gui " + tvheadend.__version__) config = CONF.readConfig() tvheadend.user = config["user"] tvheadend.passw = config["pass"] tvheadend.ipaddr = str(config["tvhipaddr"]) + ":" + str(config["tvhport"]) tvheadend.videohome = config["videohome"] tvheadend.filmhome = config["filmhome"] app = tvhg() app.run(sys.argv) # win = MainWindow() # win.connect("destroy", Gtk.main_quit) # win.CurrRecs() # Gtk.main() except Exception as e: fname = sys._getframe().f_code.co_name errorExit(fname, e)
def tvhwatch(): try: log.info("tvheadend watch utility " + tvheadend.__version__) config = CONF.readConfig() db = tvheadend.tvhdb.TVHDb(config["tvhdb"]) stopnow = False while not stopnow: stopnow = processFiles(db) if stopnow: FUT.fileDelete(stopnext) log.info("Stop file found, stopping now") break time.sleep(30) except KeyboardInterrupt: log.info(f"Keyboard interrupt") stopnow = True except Exception as e: fname = sys._getframe().f_code.co_name errorExit(fname, e)
def gobabe(): try: config = CONF.readConfig() tvheadend.user = config["user"] tvheadend.passw = config["pass"] tvheadend.ipaddr = str(config["tvhipaddr"]) + ":" + str(config["tvhport"]) start, length = getStartLength() epg = TVH.filterPrograms(channel="BBC Two HD") print(f"channel filter returned {len(epg)} progs") epg = TVH.filterPrograms(start=start, length=length) print(f"time filter returned {len(epg)} progs") epg = TVH.filterPrograms(channel="BBC Two HD", start=start, length=length) print(f"time/channel filter returned {len(epg)} progs") # total, entries = TVH.getEpg() # if total is not None and entries is not None: # print(f"received {total} entries") # TVH.timeSlotPrograms(start, length) 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)