diff --git a/PseudoChannel.py b/PseudoChannel.py index 09d5f05..f912ebc 100644 --- a/PseudoChannel.py +++ b/PseudoChannel.py @@ -49,6 +49,8 @@ class PseudoChannel(): COMMERCIAL_PADDING_IN_SECONDS = config.commercialPadding + CONTROLLER_SERVER_PATH = config.controllerServerPath + DEBUG = config.debug_mode def __init__(self): @@ -59,6 +61,7 @@ class PseudoChannel(): config.baseurl, config.token, config.plexClients, + self.CONTROLLER_SERVER_PATH, self.DEBUG ) @@ -1087,8 +1090,6 @@ if __name__ == '__main__': pseudo_channel.generate_daily_schedule() - pseudo_channel.make_xml_schedule() - the_daily_schedule = pseudo_channel.db.get_daily_schedule() pseudo_channel.controller.tv_controller(the_daily_schedule) diff --git a/pseudo_config.py b/pseudo_config.py index c7cd7dd..93cc5bf 100644 --- a/pseudo_config.py +++ b/pseudo_config.py @@ -66,6 +66,12 @@ useCommercialInjection = True # How many seconds to pad commercials between each other / other media commercialPadding = 5 +# Run a web server at the ./schedules directory and put the path here (i.e. http://192.168.1.28:8000/) +# Make sure to have trailing slash. +# If you would rather not deal with this, just leave an empty string...the schedule will still work, +# but will refresh every 30 seconds. +controllerServerPath = "http://localhost:8000/" + dailyUpdateTime = "12:00 AM" debug_mode = False diff --git a/src/PseudoDailyScheduleController.py b/src/PseudoDailyScheduleController.py index 908d474..6107d12 100644 --- a/src/PseudoDailyScheduleController.py +++ b/src/PseudoDailyScheduleController.py @@ -13,7 +13,7 @@ import logging.handlers class PseudoDailyScheduleController(): - def __init__(self, server, token, clients, debugMode = False): + def __init__(self, server, token, clients, controllerServerPath = '', debugMode = False): self.PLEX = PlexServer(server, token) @@ -23,6 +23,8 @@ class PseudoDailyScheduleController(): self.PLEX_CLIENTS = clients + self.CONTROLLER_SERVER_PATH = controllerServerPath + self.DEBUG = debugMode self.my_logger = logging.getLogger('MyLogger') @@ -150,7 +152,58 @@ class PseudoDailyScheduleController(): text(time + " - Daily Pseudo Schedule") doc.asis('') - doc.asis('') + doc.asis('') + doc.asis('') + + doc.asis(""" + + """) if bgImageURL != None: doc.asis('') @@ -304,6 +357,42 @@ class PseudoDailyScheduleController(): f.write(data) + + ''' + * + * Write 0 or 1 to file for the ajax in the schedule.html to know when to refresh + * @param data: xml string + * @return null + * + ''' + def write_refresh_bool_to_file(self): + + fileName = "pseudo_refresh.txt" + + writepath = './schedules/' + + first_line = '' + + if not os.path.exists(writepath): + + os.makedirs(writepath) + + if os.path.exists(writepath+fileName): + + os.remove(writepath+fileName) + + mode = 'a' if os.path.exists(writepath) else 'w' + + with open(writepath+fileName, mode) as f: + + if first_line == '' or first_line == "0": + + f.write("1") + + else: + + f.write("0") + ''' * * Trigger "playMedia()" on the Python Plex API for specified media. @@ -407,6 +496,8 @@ class PseudoDailyScheduleController(): self.write_schedule_to_file(self.get_html_from_daily_schedule(None, None, datalist)) self.write_xml_to_file(self.get_xml_from_daily_schedule(None, None, datalist)) + self.write_refresh_bool_to_file() + break ''' * @@ -453,6 +544,8 @@ class PseudoDailyScheduleController(): ) ) + self.write_refresh_bool_to_file() + """Generate / write XML to file """ self.write_xml_to_file( @@ -480,5 +573,6 @@ class PseudoDailyScheduleController(): print "+++++ ", "Writing XML / HTML to file." + self.write_refresh_bool_to_file() self.write_schedule_to_file(self.get_html_from_daily_schedule(None, None, datalist)) self.write_xml_to_file(self.get_xml_from_daily_schedule(None, None, datalist)) \ No newline at end of file