1
0
mirror of https://github.com/fHDHR/fHDHR_NextPVR.git synced 2025-12-06 08:46:58 -05:00

Compare commits

...

4 Commits

Author SHA1 Message Date
Deathbybandaid
4efdded7e1
Merge pull request #123 from deathbybandaid/dev
Update String Formatting for Alternative_EPG
2021-01-08 15:58:48 -05:00
deathbybadaid
b4d8ed6e4d Update String Formatting for Alternative_EPG 2021-01-08 15:57:50 -05:00
Deathbybandaid
cdbe545df6
Merge pull request #122 from deathbybandaid/dev
Update String Formatting
2021-01-08 15:38:25 -05:00
deathbybadaid
d1038ab46a Update String Formatting 2021-01-08 15:35:55 -05:00
27 changed files with 83 additions and 88 deletions

View File

@ -20,7 +20,7 @@ class tvtvEPG():
data = postalcode_req.json() data = postalcode_req.json()
postalcode = data["postal"] postalcode = data["postal"]
except Exception as e: except Exception as e:
raise EPGSetupError("Unable to automatically optain postalcode: " + str(e)) raise EPGSetupError("Unable to automatically optain postalcode: %s" % e)
postalcode = None postalcode = None
return postalcode return postalcode
@ -119,10 +119,10 @@ class tvtvEPG():
def get_cached_item(self, cache_key, url): def get_cached_item(self, cache_key, url):
cacheitem = self.fhdhr.db.get_cacheitem_value(cache_key, "epg_cache", "tvtv") cacheitem = self.fhdhr.db.get_cacheitem_value(cache_key, "epg_cache", "tvtv")
if cacheitem: if cacheitem:
self.fhdhr.logger.info('FROM CACHE: ' + str(cache_key)) self.fhdhr.logger.info("FROM CACHE: %s" % cache_key)
return cacheitem return cacheitem
else: else:
self.fhdhr.logger.info('Fetching: ' + url) self.fhdhr.logger.info("Fetching: %s" % url)
try: try:
resp = self.fhdhr.web.session.get(url) resp = self.fhdhr.web.session.get(url)
except self.fhdhr.web.exceptions.HTTPError: except self.fhdhr.web.exceptions.HTTPError:
@ -144,12 +144,12 @@ class tvtvEPG():
if cachedate < todaysdate: if cachedate < todaysdate:
cache_to_kill.append(cacheitem) cache_to_kill.append(cacheitem)
self.fhdhr.db.delete_cacheitem_value(cacheitem, "epg_cache", "tvtv") self.fhdhr.db.delete_cacheitem_value(cacheitem, "epg_cache", "tvtv")
self.fhdhr.logger.info('Removing stale cache: ' + str(cacheitem)) self.fhdhr.logger.info("Removing stale cache: %s" % cacheitem)
self.fhdhr.db.set_cacheitem_value("cache_list", "epg_cache", [x for x in cache_list if x not in cache_to_kill], "tvtv") self.fhdhr.db.set_cacheitem_value("cache_list", "epg_cache", [x for x in cache_list if x not in cache_to_kill], "tvtv")
def clear_cache(self): def clear_cache(self):
cache_list = self.fhdhr.db.get_cacheitem_value("cache_list", "epg_cache", "tvtv") or [] cache_list = self.fhdhr.db.get_cacheitem_value("cache_list", "epg_cache", "tvtv") or []
for cacheitem in cache_list: for cacheitem in cache_list:
self.fhdhr.db.delete_cacheitem_value(cacheitem, "epg_cache", "tvtv") self.fhdhr.db.delete_cacheitem_value(cacheitem, "epg_cache", "tvtv")
self.fhdhr.logger.info('Removing cache: ' + str(cacheitem)) self.fhdhr.logger.info("Removing cache: %s" % str(cacheitem))
self.fhdhr.db.delete_cacheitem_value("cache_list", "epg_cache", "tvtv") self.fhdhr.db.delete_cacheitem_value("cache_list", "epg_cache", "tvtv")

View File

@ -22,7 +22,7 @@ class zap2itEPG():
data = postalcode_req.json() data = postalcode_req.json()
postalcode = data["postal"] postalcode = data["postal"]
except Exception as e: except Exception as e:
raise EPGSetupError("Unable to automatically optain postalcode: " + str(e)) raise EPGSetupError("Unable to automatically optain postalcode: %s" % e)
postalcode = None postalcode = None
return postalcode return postalcode
@ -69,7 +69,7 @@ class zap2itEPG():
"time_start": timestamp['time_start'], "time_start": timestamp['time_start'],
"time_end": timestamp['time_end'], "time_end": timestamp['time_end'],
"duration_minutes": eventdict['duration'], "duration_minutes": eventdict['duration'],
"thumbnail": str("https://zap2it.tmsimg.com/assets/" + str(eventdict['thumbnail']) + ".jpg"), "thumbnail": "https://zap2it.tmsimg.com/assets/%s.jpg" % eventdict['thumbnail'],
"title": progdict['title'] or "Unavailable", "title": progdict['title'] or "Unavailable",
"sub-title": progdict['sub-title'] or "Unavailable", "sub-title": progdict['sub-title'] or "Unavailable",
"description": progdict['shortDesc'] or "Unavailable", "description": progdict['shortDesc'] or "Unavailable",
@ -87,7 +87,7 @@ class zap2itEPG():
clean_prog_dict["genres"].append(f.replace('filter-', '')) clean_prog_dict["genres"].append(f.replace('filter-', ''))
if 'movie' in clean_prog_dict['genres'] and clean_prog_dict['releaseyear']: if 'movie' in clean_prog_dict['genres'] and clean_prog_dict['releaseyear']:
clean_prog_dict["sub-title"] = 'Movie: ' + clean_prog_dict['releaseyear'] clean_prog_dict["sub-title"] = 'Movie: %s' % clean_prog_dict['releaseyear']
elif clean_prog_dict['episodetitle']: elif clean_prog_dict['episodetitle']:
clean_prog_dict["sub-title"] = clean_prog_dict['episodetitle'] clean_prog_dict["sub-title"] = clean_prog_dict['episodetitle']
@ -137,10 +137,10 @@ class zap2itEPG():
def get_cached_item(self, cache_key, url): def get_cached_item(self, cache_key, url):
cacheitem = self.fhdhr.db.get_cacheitem_value(cache_key, "epg_cache", "zap2it") cacheitem = self.fhdhr.db.get_cacheitem_value(cache_key, "epg_cache", "zap2it")
if cacheitem: if cacheitem:
self.fhdhr.logger.info('FROM CACHE: ' + str(cache_key)) self.fhdhr.logger.info("FROM CACHE: %s" % cache_key)
return cacheitem return cacheitem
else: else:
self.fhdhr.logger.info('Fetching: ' + url) self.fhdhr.logger.info("Fetching: %s" % url)
try: try:
resp = self.fhdhr.web.session.get(url) resp = self.fhdhr.web.session.get(url)
except self.fhdhr.web.exceptions.HTTPError: except self.fhdhr.web.exceptions.HTTPError:
@ -162,12 +162,12 @@ class zap2itEPG():
if cachedate < zap_time: if cachedate < zap_time:
cache_to_kill.append(cacheitem) cache_to_kill.append(cacheitem)
self.fhdhr.db.delete_cacheitem_value(cacheitem, "epg_cache", "zap2it") self.fhdhr.db.delete_cacheitem_value(cacheitem, "epg_cache", "zap2it")
self.fhdhr.logger.info('Removing stale cache: ' + str(cacheitem)) self.fhdhr.logger.info("Removing stale cache: %s" % cacheitem)
self.fhdhr.db.set_cacheitem_value("cache_list", "epg_cache", [x for x in cache_list if x not in cache_to_kill], "zap2it") self.fhdhr.db.set_cacheitem_value("cache_list", "epg_cache", [x for x in cache_list if x not in cache_to_kill], "zap2it")
def clear_cache(self): def clear_cache(self):
cache_list = self.fhdhr.db.get_cacheitem_value("cache_list", "epg_cache", "zap2it") or [] cache_list = self.fhdhr.db.get_cacheitem_value("cache_list", "epg_cache", "zap2it") or []
for cacheitem in cache_list: for cacheitem in cache_list:
self.fhdhr.db.delete_cacheitem_value(cacheitem, "epg_cache", "zap2it") self.fhdhr.db.delete_cacheitem_value(cacheitem, "epg_cache", "zap2it")
self.fhdhr.logger.info('Removing cache: ' + str(cacheitem)) self.fhdhr.logger.info("Removing cache: %s" % cacheitem)
self.fhdhr.db.delete_cacheitem_value("cache_list", "epg_cache", "zap2it") self.fhdhr.db.delete_cacheitem_value("cache_list", "epg_cache", "zap2it")

View File

@ -36,4 +36,4 @@ class fHDHR_OBJ():
def __getattr__(self, name): def __getattr__(self, name):
''' will only get called for undefined attributes ''' ''' will only get called for undefined attributes '''
if hasattr(self.fhdhr, name): if hasattr(self.fhdhr, name):
return eval("self.fhdhr." + name) return eval("self.fhdhr.%s" % name)

View File

@ -10,7 +10,7 @@ class Fillin_Client():
def __getattr__(self, name): def __getattr__(self, name):
''' will only get called for undefined attributes ''' ''' will only get called for undefined attributes '''
if hasattr(self.web.session, name): if hasattr(self.web.session, name):
return eval("self.web.session." + name) return eval("self.web.session.%s" % name)
class fHDHR_API_URLs(): class fHDHR_API_URLs():

View File

@ -71,7 +71,7 @@ class Config():
if str(file_item_path).endswith("_conf.json"): if str(file_item_path).endswith("_conf.json"):
self.read_json_config(file_item_path) self.read_json_config(file_item_path)
print("Loading Configuration File: " + str(self.config_file)) print("Loading Configuration File: %s" % self.config_file)
self.read_ini_config(self.config_file) self.read_ini_config(self.config_file)
self.load_versions() self.load_versions()
@ -270,7 +270,7 @@ class Config():
if not self.dict[req_section][req_key]: if not self.dict[req_section][req_key]:
required_missing.append(req_item) required_missing.append(req_item)
if len(required_missing): if len(required_missing):
raise fHDHR.exceptions.ConfigurationError("Required configuration options missing: " + ", ".join(required_missing)) raise fHDHR.exceptions.ConfigurationError("Required configuration options missing: %s" % ", ".join(required_missing))
self.dict["origin"] = self.dict.pop(self.dict["main"]["dictpopname"]) self.dict["origin"] = self.dict.pop(self.dict["main"]["dictpopname"])

View File

@ -68,14 +68,14 @@ class fHDHR_Cluster():
for location in list(cluster.keys()): for location in list(cluster.keys()):
if location != self.fhdhr.api.base: if location != self.fhdhr.api.base:
self.fhdhr.logger.debug("Checking Cluster Syncronization information from %s." % location) self.fhdhr.logger.debug("Checking Cluster Syncronization information from %s." % location)
sync_url = location + "/api/cluster?method=get" sync_url = "%s/api/cluster?method=get" % location
try: try:
sync_open = self.fhdhr.web.session.get(sync_url) sync_open = self.fhdhr.web.session.get(sync_url)
retrieved_cluster = sync_open.json() retrieved_cluster = sync_open.json()
if self.fhdhr.api.base not in list(retrieved_cluster.keys()): if self.fhdhr.api.base not in list(retrieved_cluster.keys()):
return self.leave() return self.leave()
except self.fhdhr.web.exceptions.ConnectionError: except self.fhdhr.web.exceptions.ConnectionError:
self.fhdhr.logger.error("Unreachable: " + location) self.fhdhr.logger.error("Unreachable: %s" % location)
def leave(self): def leave(self):
self.fhdhr.logger.info("Leaving cluster.") self.fhdhr.logger.info("Leaving cluster.")
@ -86,30 +86,30 @@ class fHDHR_Cluster():
for location in list(cluster.keys()): for location in list(cluster.keys()):
if location != self.fhdhr.api.base: if location != self.fhdhr.api.base:
self.fhdhr.logger.info("Informing %s that I am departing the Cluster." % location) self.fhdhr.logger.info("Informing %s that I am departing the Cluster." % location)
sync_url = location + "/api/cluster?method=del&location=" + self.fhdhr.api.base sync_url = "%s/api/cluster?method=del&location=%s" % (location, self.fhdhr.api.base)
try: try:
self.fhdhr.web.session.get(sync_url) self.fhdhr.web.session.get(sync_url)
except self.fhdhr.web.exceptions.ConnectionError: except self.fhdhr.web.exceptions.ConnectionError:
self.fhdhr.logger.error("Unreachable: " + location) self.fhdhr.logger.error("Unreachable: %s" % location)
self.leave() self.leave()
def sync(self, location): def sync(self, location):
sync_url = location + "/api/cluster?method=get" sync_url = "%s/api/cluster?method=get" % location
try: try:
sync_open = self.fhdhr.web.session.get(sync_url) sync_open = self.fhdhr.web.session.get(sync_url)
self.fhdhr.db.set_fhdhr_value("cluster", "dict", sync_open.json()) self.fhdhr.db.set_fhdhr_value("cluster", "dict", sync_open.json())
except self.fhdhr.web.exceptions.ConnectionError: except self.fhdhr.web.exceptions.ConnectionError:
self.fhdhr.logger.error("Unreachable: " + location) self.fhdhr.logger.error("Unreachable: %s" % location)
def push_sync(self): def push_sync(self):
cluster = self.fhdhr.db.get_fhdhr_value("cluster", "dict") or self.default_cluster() cluster = self.fhdhr.db.get_fhdhr_value("cluster", "dict") or self.default_cluster()
for location in list(cluster.keys()): for location in list(cluster.keys()):
if location != self.fhdhr.api.base: if location != self.fhdhr.api.base:
sync_url = location + "/api/cluster?method=sync&location=" + self.fhdhr.api.base_quoted sync_url = "%s/api/cluster?method=sync&location=%s" % (location, self.fhdhr.api.base_quoted)
try: try:
self.fhdhr.web.session.get(sync_url) self.fhdhr.web.session.get(sync_url)
except self.fhdhr.web.exceptions.ConnectionError: except self.fhdhr.web.exceptions.ConnectionError:
self.fhdhr.logger.error("Unreachable: " + location) self.fhdhr.logger.error("Unreachable: %s" % location)
def add(self, location): def add(self, location):
cluster = self.fhdhr.db.get_fhdhr_value("cluster", "dict") or self.default_cluster() cluster = self.fhdhr.db.get_fhdhr_value("cluster", "dict") or self.default_cluster()
@ -121,18 +121,18 @@ class fHDHR_Cluster():
try: try:
location_info_req = self.fhdhr.web.session.get(location_info_url) location_info_req = self.fhdhr.web.session.get(location_info_url)
except self.fhdhr.web.exceptions.ConnectionError: except self.fhdhr.web.exceptions.ConnectionError:
self.fhdhr.logger.error("Unreachable: " + location) self.fhdhr.logger.error("Unreachable: %s" % location)
del cluster[location] del cluster[location]
self.fhdhr.db.set_fhdhr_value("cluster", "dict", cluster) self.fhdhr.db.set_fhdhr_value("cluster", "dict", cluster)
return return
location_info = location_info_req.json() location_info = location_info_req.json()
cluster[location]["name"] = location_info["FriendlyName"] cluster[location]["name"] = location_info["FriendlyName"]
cluster_info_url = location + "/api/cluster?method=get" cluster_info_url = "%s/api/cluster?method=get" % location
try: try:
cluster_info_req = self.fhdhr.web.session.get(cluster_info_url) cluster_info_req = self.fhdhr.web.session.get(cluster_info_url)
except self.fhdhr.web.exceptions.ConnectionError: except self.fhdhr.web.exceptions.ConnectionError:
self.fhdhr.logger.error("Unreachable: " + location) self.fhdhr.logger.error("Unreachable: %s" % location)
del cluster[location] del cluster[location]
self.fhdhr.db.set_fhdhr_value("cluster", "dict", cluster) self.fhdhr.db.set_fhdhr_value("cluster", "dict", cluster)
return return
@ -149,10 +149,10 @@ class fHDHR_Cluster():
if location in list(cluster.keys()): if location in list(cluster.keys()):
self.fhdhr.logger.info("Removing %s from cluster." % location) self.fhdhr.logger.info("Removing %s from cluster." % location)
del cluster[location] del cluster[location]
sync_url = location + "/api/cluster?method=leave" sync_url = "%s/api/cluster?method=leave" % location
try: try:
self.fhdhr.web.session.get(sync_url) self.fhdhr.web.session.get(sync_url)
except self.fhdhr.web.exceptions.ConnectionError: except self.fhdhr.web.exceptions.ConnectionError:
self.fhdhr.logger.error("Unreachable: " + location) self.fhdhr.logger.error("Unreachable: %s" % location)
self.push_sync() self.push_sync()
self.fhdhr.db.set_fhdhr_value("cluster", "dict", cluster) self.fhdhr.db.set_fhdhr_value("cluster", "dict", cluster)

View File

@ -54,7 +54,7 @@ class EPG():
if method in [self.fhdhr.config.dict["main"]["dictpopname"], "origin"]: if method in [self.fhdhr.config.dict["main"]["dictpopname"], "origin"]:
epgtypename = self.fhdhr.config.dict["main"]["dictpopname"] epgtypename = self.fhdhr.config.dict["main"]["dictpopname"]
self.fhdhr.logger.info("Clearing " + epgtypename + " EPG cache.") self.fhdhr.logger.info("Clearing %s EPG cache." % epgtypename)
if hasattr(self.epg_handling[method], 'clear_cache'): if hasattr(self.epg_handling[method], 'clear_cache'):
self.epg_handling[method].clear_cache() self.epg_handling[method].clear_cache()
@ -180,7 +180,7 @@ class EPG():
if method in [self.fhdhr.config.dict["main"]["dictpopname"], "origin"]: if method in [self.fhdhr.config.dict["main"]["dictpopname"], "origin"]:
epgtypename = self.fhdhr.config.dict["main"]["dictpopname"] epgtypename = self.fhdhr.config.dict["main"]["dictpopname"]
self.fhdhr.logger.info("Updating " + epgtypename + " EPG cache.") self.fhdhr.logger.info("Updating %s EPG cache." % epgtypename)
if method == 'origin': if method == 'origin':
programguide = self.epg_handling['origin'].update_epg(self.channels) programguide = self.epg_handling['origin'].update_epg(self.channels)
else: else:

View File

@ -91,7 +91,7 @@ class Direct_M3U8_Stream():
except GeneratorExit: except GeneratorExit:
self.fhdhr.logger.info("Connection Closed.") self.fhdhr.logger.info("Connection Closed.")
except Exception as e: except Exception as e:
self.fhdhr.logger.info("Connection Closed: " + str(e)) self.fhdhr.logger.info("Connection Closed: %s" % e)
finally: finally:
self.fhdhr.logger.info("Connection Closed: Tuner Lock Removed") self.fhdhr.logger.info("Connection Closed: Tuner Lock Removed")
self.tuner.close() self.tuner.close()

View File

@ -54,7 +54,7 @@ class Direct_Stream():
except GeneratorExit: except GeneratorExit:
self.fhdhr.logger.info("Connection Closed.") self.fhdhr.logger.info("Connection Closed.")
except Exception as e: except Exception as e:
self.fhdhr.logger.info("Connection Closed: " + str(e)) self.fhdhr.logger.info("Connection Closed: %s" % e)
finally: finally:
req.close() req.close()
self.fhdhr.logger.info("Connection Closed: Tuner Lock Removed") self.fhdhr.logger.info("Connection Closed: Tuner Lock Removed")

View File

@ -34,7 +34,7 @@ class FFMPEG_Stream():
except GeneratorExit: except GeneratorExit:
self.fhdhr.logger.info("Connection Closed.") self.fhdhr.logger.info("Connection Closed.")
except Exception as e: except Exception as e:
self.fhdhr.logger.info("Connection Closed: " + str(e)) self.fhdhr.logger.info("Connection Closed: %s" % e)
finally: finally:
ffmpeg_proc.terminate() ffmpeg_proc.terminate()
ffmpeg_proc.communicate() ffmpeg_proc.communicate()
@ -104,7 +104,7 @@ class FFMPEG_Stream():
""" """
if stream_args["transcode"]: if stream_args["transcode"]:
self.fhdhr.logger.info("Client requested a " + stream_args["transcode"] + " transcode for stream.") self.fhdhr.logger.info("Client requested a %s transcode for stream." % stream_args["transcode"])
stream_args["transcode"] = None stream_args["transcode"] = None
ffmpeg_command = [] ffmpeg_command = []

View File

@ -35,7 +35,7 @@ class VLC_Stream():
except GeneratorExit: except GeneratorExit:
self.fhdhr.logger.info("Connection Closed.") self.fhdhr.logger.info("Connection Closed.")
except Exception as e: except Exception as e:
self.fhdhr.logger.info("Connection Closed: " + str(e)) self.fhdhr.logger.info("Connection Closed: %s" % e)
finally: finally:
vlc_proc.terminate() vlc_proc.terminate()
vlc_proc.communicate() vlc_proc.communicate()
@ -96,7 +96,7 @@ class VLC_Stream():
vlc_command = [] vlc_command = []
if stream_args["transcode"]: if stream_args["transcode"]:
self.fhdhr.logger.info("Client requested a " + stream_args["transcode"] + " transcode for stream.") self.fhdhr.logger.info("Client requested a %s transcode for stream." % stream_args["transcode"])
stream_args["transcode"] = None stream_args["transcode"] = None
vlc_transcode_string = "#std{mux=ts,access=file,dst=-}" vlc_transcode_string = "#std{mux=ts,access=file,dst=-}"

View File

@ -49,7 +49,7 @@ class Tuner():
def grab(self, channel_number): def grab(self, channel_number):
if self.tuner_lock.locked(): if self.tuner_lock.locked():
self.fhdhr.logger.error("Tuner #" + str(self.number) + " is not available.") self.fhdhr.logger.error("Tuner #%s is not available." % self.number)
raise TunerError("804 - Tuner In Use") raise TunerError("804 - Tuner In Use")
self.tuner_lock.acquire() self.tuner_lock.acquire()
self.status["status"] = "Acquired" self.status["status"] = "Acquired"
@ -60,7 +60,7 @@ class Tuner():
self.set_off_status() self.set_off_status()
if self.tuner_lock.locked(): if self.tuner_lock.locked():
self.tuner_lock.release() self.tuner_lock.release()
self.fhdhr.logger.info("Tuner #" + str(self.number) + " Released.") self.fhdhr.logger.info("Tuner #%s Released." % self.number)
def get_status(self): def get_status(self):
current_status = self.status.copy() current_status = self.status.copy()

View File

@ -45,12 +45,12 @@ class OriginServiceWrapper():
def __getattr__(self, name): def __getattr__(self, name):
''' will only get called for undefined attributes ''' ''' will only get called for undefined attributes '''
if hasattr(self.fhdhr, name): if hasattr(self.fhdhr, name):
return eval("self.fhdhr." + name) return eval("self.fhdhr.%s" % name)
if hasattr(self.originservice, name): if hasattr(self.originservice, name):
return eval("self.originservice." + name) return eval("self.originservice.%s" % name)
elif hasattr(self.channels, name): elif hasattr(self.channels, name):
return eval("self.channels." + name) return eval("self.channels.%s" % name)
elif hasattr(self.epg, name): elif hasattr(self.epg, name):
return eval("self.epg." + name) return eval("self.epg.%s" % name)
else: else:
raise AttributeError(name) raise AttributeError(name)

View File

@ -133,9 +133,9 @@ def humanized_time(countdownseconds):
if currenttimevar > 1: if currenttimevar > 1:
timetype = str(x+"s") timetype = str(x+"s")
if displaymsg: if displaymsg:
displaymsg = str(displaymsg + " " + str(int(currenttimevar)) + " " + timetype) displaymsg = "%s %s %s" % (displaymsg, int(currenttimevar), timetype)
else: else:
displaymsg = str(str(int(currenttimevar)) + " " + timetype) displaymsg = "%s %s" % (int(currenttimevar), timetype)
if not displaymsg: if not displaymsg:
return "just now" return "just now"
return displaymsg return displaymsg
@ -151,4 +151,4 @@ class WebReq():
def __getattr__(self, name): def __getattr__(self, name):
''' will only get called for undefined attributes ''' ''' will only get called for undefined attributes '''
if hasattr(self.session, name): if hasattr(self.session, name):
return eval("self.session." + name) return eval("self.session.%s" % name)

View File

@ -113,7 +113,7 @@ class fHDHR_HTTP_Server():
# if session["tuner_used"] is not None: # if session["tuner_used"] is not None:
# tuner = self.fhdhr.device.tuners.tuners[str(session["tuner_used"])] # tuner = self.fhdhr.device.tuners.tuners[str(session["tuner_used"])]
# if tuner.tuner_lock.locked(): # if tuner.tuner_lock.locked():
# self.fhdhr.logger.info("Shutting down Tuner #" + str(session["tuner_used"]) + " after Request.") # self.fhdhr.logger.info("Shutting down Tuner #%s after Request." % session["tuner_used"])
# tuner.close() # tuner.close()
self.fhdhr.logger.debug("Client %s requested %s Closing" % (request.method, request.path)) self.fhdhr.logger.debug("Client %s requested %s Closing" % (request.method, request.path))
@ -160,29 +160,29 @@ class fHDHR_HTTP_Server():
item_list = [x for x in dir(index_list) if self.isapath(x)] item_list = [x for x in dir(index_list) if self.isapath(x)]
for item in item_list: for item in item_list:
endpoints = eval("self." + str(index_name) + "." + str(item) + ".endpoints") endpoints = eval("self.%s.%s.%s" % (index_name, item, "endpoints"))
if isinstance(endpoints, str): if isinstance(endpoints, str):
endpoints = [endpoints] endpoints = [endpoints]
handler = eval("self." + str(index_name) + "." + str(item)) handler = eval("self.%s.%s" % (index_name, item))
endpoint_name = eval("self." + str(index_name) + "." + str(item) + ".endpoint_name") endpoint_name = eval("self.%s.%s.%s" % (index_name, item, "endpoint_name"))
try: try:
endpoint_methods = eval("self." + str(index_name) + "." + str(item) + ".endpoint_methods") endpoint_methods = eval("self.%s.%s.%s" % (index_name, item, "endpoint_methods"))
except AttributeError: except AttributeError:
endpoint_methods = ['GET'] endpoint_methods = ['GET']
try: try:
endpoint_access_level = eval("self." + str(index_name) + "." + str(item) + ".endpoint_access_level") endpoint_access_level = eval("self.%s.%s.%s" % (index_name, item, "endpoint_access_level"))
except AttributeError: except AttributeError:
endpoint_access_level = 0 endpoint_access_level = 0
try: try:
pretty_name = eval("self." + str(index_name) + "." + str(item) + ".pretty_name") pretty_name = eval("self.%s.%s.%s" % (index_name, item, "pretty_name"))
except AttributeError: except AttributeError:
pretty_name = endpoint_name pretty_name = endpoint_name
try: try:
endpoint_default_parameters = eval("self." + str(index_name) + "." + str(item) + ".endpoint_default_parameters") endpoint_default_parameters = eval("self.%s.%s.%s" % (index_name, item, "endpoint_default_parameters"))
except AttributeError: except AttributeError:
endpoint_default_parameters = {} endpoint_default_parameters = {}

View File

@ -50,7 +50,7 @@ class Channels():
channel = request.args.get('channel', default=None, type=str) channel = request.args.get('channel', default=None, type=str)
if not channel: if not channel:
if redirect_url: if redirect_url:
return redirect(redirect_url + "?retmessage=" + urllib.parse.quote("%s Failed" % method)) return redirect("%s?retmessage=%s" % (redirect_url, urllib.parse.quote("%s Failed" % method)))
else: else:
return "%s Falied" % method return "%s Falied" % method
@ -73,7 +73,7 @@ class Channels():
self.fhdhr.device.channels.set_channel_enablement("number", channel_number, "toggle") self.fhdhr.device.channels.set_channel_enablement("number", channel_number, "toggle")
else: else:
self.fhdhr.logger.warning("Unknown favorite command " + request.args['favorite']) self.fhdhr.logger.warning("Unknown favorite command %s" % request.args['favorite'])
return abort(200, "Not a valid favorite command") return abort(200, "Not a valid favorite command")
elif method in ["enable", "disable"]: elif method in ["enable", "disable"]:
@ -82,7 +82,7 @@ class Channels():
self.fhdhr.device.channels.set_channel_enablement_all(method) self.fhdhr.device.channels.set_channel_enablement_all(method)
elif not channel or str(channel) not in [str(x) for x in self.fhdhr.device.channels.get_channel_list("number")]: elif not channel or str(channel) not in [str(x) for x in self.fhdhr.device.channels.get_channel_list("number")]:
if redirect_url: if redirect_url:
return redirect(redirect_url + "?retmessage=" + urllib.parse.quote("%s Failed" % method)) return redirect("%s?retmessage=%s" % (redirect_url, urllib.parse.quote("%s Failed" % method)))
else: else:
return "%s Falied" % method return "%s Falied" % method
else: else:
@ -148,7 +148,7 @@ class Channels():
return "Invalid Method" return "Invalid Method"
if redirect_url: if redirect_url:
return redirect(redirect_url + "?retmessage=" + urllib.parse.quote("%s Success" % method)) return redirect("%s?retmessage=%s" % (redirect_url, urllib.parse.quote("%s Success" % method)))
else: else:
if method == "scan": if method == "scan":
return redirect('/lineup_status.json') return redirect('/lineup_status.json')

View File

@ -54,6 +54,6 @@ class Cluster():
return "Invalid Method" return "Invalid Method"
if redirect_url: if redirect_url:
return redirect(redirect_url + "?retmessage=" + urllib.parse.quote("%s Success" % method)) return redirect("%s?retmessage=%s" % (redirect_url, urllib.parse.quote("%s Success" % method)))
else: else:
return "%s Success" % method return "%s Success" % method

View File

@ -55,6 +55,6 @@ class EPG():
return "%s Invalid Method" % method return "%s Invalid Method" % method
if redirect_url: if redirect_url:
return redirect(redirect_url + "?retmessage=" + urllib.parse.quote("%s Success" % method)) return redirect("%s?retmessage=%s" % (redirect_url, urllib.parse.quote("%s Success" % method)))
else: else:
return "%s Success" % method return "%s Success" % method

View File

@ -33,12 +33,7 @@ class M3U():
xmltvurl = ('%s/api/xmltv' % base_url) xmltvurl = ('%s/api/xmltv' % base_url)
fakefile.write( fakefile.write("%s url-tvg=\"%s\" x-tvg-url=\"%s\"\n" % (FORMAT_DESCRIPTOR, xmltvurl, xmltvurl))
"%s\n" % (
FORMAT_DESCRIPTOR + " " +
"url-tvg=\"" + xmltvurl + "\"" + " " +
"x-tvg-url=\"" + xmltvurl + "\"")
)
channel_items = [] channel_items = []
@ -50,7 +45,7 @@ class M3U():
channel_items.append(channel_obj) channel_items.append(channel_obj)
elif str(channel) in [str(x) for x in self.fhdhr.device.channels.get_channel_list("number")]: elif str(channel) in [str(x) for x in self.fhdhr.device.channels.get_channel_list("number")]:
channel_obj = self.fhdhr.device.channels.get_channel_obj("number", channel) channel_obj = self.fhdhr.device.channels.get_channel_obj("number", channel)
fileName = str(channel_obj.number) + ".m3u" fileName = "%s.m3u" % channel_obj.number
if channel_obj.enabled: if channel_obj.enabled:
channel_items.append(channel_obj) channel_items.append(channel_obj)
else: else:
@ -96,10 +91,10 @@ class M3U():
channels_m3u = fakefile.getvalue() channels_m3u = fakefile.getvalue()
resp = Response(status=200, response=channels_m3u, mimetype='audio/x-mpegurl') resp = Response(status=200, response=channels_m3u, mimetype='audio/x-mpegurl')
resp.headers["content-disposition"] = "attachment; filename=" + fileName resp.headers["content-disposition"] = "attachment; filename=%s" % fileName
return resp return resp
if redirect_url: if redirect_url:
return redirect(redirect_url + "?retmessage=" + urllib.parse.quote("%s Success" % method)) return redirect("%s?retmessage=%s" % (redirect_url, urllib.parse.quote("%s Success" % method)))
else: else:
return "%s Success" % method return "%s Success" % method

View File

@ -32,6 +32,6 @@ class Route_List():
return "%s Invalid Method" % method return "%s Invalid Method" % method
if redirect_url: if redirect_url:
return redirect(redirect_url + "?retmessage=" + urllib.parse.quote("%s Success" % method)) return redirect("%s?retmessage=%s" % (redirect_url, urllib.parse.quote("%s Success" % method)))
else: else:
return "%s Success" % method return "%s Success" % method

View File

@ -52,7 +52,7 @@ class Settings():
if not config_section or not config_name or not config_value: if not config_section or not config_name or not config_value:
if redirect_url: if redirect_url:
return redirect(redirect_url + "?retmessage=" + urllib.parse.quote("%s Failed" % method)) return redirect("%s?retmessage=%s" % (redirect_url, urllib.parse.quote("%s Failed" % method)))
else: else:
return "%s Falied" % method return "%s Falied" % method
@ -64,13 +64,13 @@ class Settings():
elif method == "restart": elif method == "restart":
restart_thread = threading.Thread(target=self.restart_thread) restart_thread = threading.Thread(target=self.restart_thread)
restart_thread.start() restart_thread.start()
return redirect(redirect_url + "?retmessage=" + urllib.parse.quote("Restarting in %s seconds" % self.restart_sleep)) return redirect("%s?retmessage=%s" % (redirect_url, urllib.parse.quote("Restarting in %s seconds" % self.restart_sleep)))
elif method == "restart_actual": elif method == "restart_actual":
session["restart"] = True session["restart"] = True
if redirect_url: if redirect_url:
return redirect(redirect_url + "?retmessage=" + urllib.parse.quote("%s Success" % method)) return redirect("%s?retmessage=%s" % (redirect_url, urllib.parse.quote("%s Success" % method)))
else: else:
return "%s Success" % method return "%s Success" % method

View File

@ -53,6 +53,6 @@ class API_Tools():
return "%s Invalid Method" % method return "%s Invalid Method" % method
if redirect_url: if redirect_url:
return redirect(redirect_url + "?retmessage=" + urllib.parse.quote("%s Success" % method)) return redirect("%s?retmessage=%s" % (redirect_url, urllib.parse.quote("%s Success" % method)))
else: else:
return "%s Success" % method return "%s Success" % method

View File

@ -75,7 +75,7 @@ class Tuners():
"transcode": transcode, "transcode": transcode,
"accessed": accessed_url, "accessed": accessed_url,
"client": client_address, "client": client_address,
"client_id": str(client_address) + "_" + str(uuid.uuid4()) "client_id": "%s_%s" % (client_address, uuid.uuid4())
} }
try: try:
@ -104,7 +104,7 @@ class Tuners():
tuner.close() tuner.close()
abort(response) abort(response)
self.fhdhr.logger.info("Tuner #" + str(tunernum) + " to be used for stream.") self.fhdhr.logger.info("Tuner #%s to be used for stream." % tunernum)
tuner.set_status(stream_args) tuner.set_status(stream_args)
session["tuner_used"] = tunernum session["tuner_used"] = tunernum
@ -148,6 +148,6 @@ class Tuners():
return "%s Invalid Method" % method return "%s Invalid Method" % method
if redirect_url: if redirect_url:
return redirect(redirect_url + "?retmessage=" + urllib.parse.quote("%s Success" % method)) return redirect("%s?retmessage=%s" % (redirect_url, urllib.parse.quote("%s Success" % method)))
else: else:
return "%s Success" % method return "%s Success" % method

View File

@ -74,7 +74,7 @@ class xmlTV():
return "%s Invalid Method" % method return "%s Invalid Method" % method
if redirect_url: if redirect_url:
return redirect(redirect_url + "?retmessage=" + urllib.parse.quote("%s Success" % method)) return redirect("%s?retmessage=%s" % (redirect_url, urllib.parse.quote("%s Success" % method)))
else: else:
return "%s Success" % method return "%s Success" % method
@ -84,7 +84,7 @@ class xmlTV():
xmltvgen.set('source-info-url', self.fhdhr.config.dict["fhdhr"]["friendlyname"]) xmltvgen.set('source-info-url', self.fhdhr.config.dict["fhdhr"]["friendlyname"])
xmltvgen.set('source-info-name', self.fhdhr.config.dict["main"]["servicename"]) xmltvgen.set('source-info-name', self.fhdhr.config.dict["main"]["servicename"])
xmltvgen.set('generator-info-name', 'fHDHR') xmltvgen.set('generator-info-name', 'fHDHR')
xmltvgen.set('generator-info-url', 'fHDHR/' + self.fhdhr.config.dict["main"]["reponame"]) xmltvgen.set('generator-info-url', 'fHDHR/%s' % self.fhdhr.config.dict["main"]["reponame"])
return xmltvgen return xmltvgen
def xmltv_file(self, xmltvgen): def xmltv_file(self, xmltvgen):
@ -135,7 +135,7 @@ class xmlTV():
sub_el(c_out, 'display-name', text=epgdict[c]['name']) sub_el(c_out, 'display-name', text=epgdict[c]['name'])
if self.fhdhr.config.dict["epg"]["images"] == "proxy": if self.fhdhr.config.dict["epg"]["images"] == "proxy":
sub_el(c_out, 'icon', src=(str(base_url) + "/api/images?method=get&type=channel&id=" + str(epgdict[c]['id']))) sub_el(c_out, 'icon', src=("%s/api/images?method=get&type=channel&id=%s" % (base_url, epgdict[c]['id'])))
else: else:
sub_el(c_out, 'icon', src=(epgdict[c]["thumbnail"])) sub_el(c_out, 'icon', src=(epgdict[c]["thumbnail"]))
@ -156,7 +156,7 @@ class xmlTV():
sub_el(prog_out, 'desc', lang='en', text=program['description']) sub_el(prog_out, 'desc', lang='en', text=program['description'])
sub_el(prog_out, 'sub-title', lang='en', text='Movie: ' + program['sub-title']) sub_el(prog_out, 'sub-title', lang='en', text='Movie: %s' % program['sub-title'])
sub_el(prog_out, 'length', units='minutes', text=str(int(program['duration_minutes']))) sub_el(prog_out, 'length', units='minutes', text=str(int(program['duration_minutes'])))
@ -178,11 +178,11 @@ class xmlTV():
if program["thumbnail"]: if program["thumbnail"]:
if self.fhdhr.config.dict["epg"]["images"] == "proxy": if self.fhdhr.config.dict["epg"]["images"] == "proxy":
sub_el(prog_out, 'icon', src=(str(base_url) + "/api/images?method=get&type=content&id=" + str(program['id']))) sub_el(prog_out, 'icon', src=("%s/api/images?method=get&type=content&id=%s" % (base_url, program['id'])))
else: else:
sub_el(prog_out, 'icon', src=(program["thumbnail"])) sub_el(prog_out, 'icon', src=(program["thumbnail"]))
else: else:
sub_el(prog_out, 'icon', src=(str(base_url) + "/api/images?method=generate&type=content&message=" + urllib.parse.quote(program['title']))) sub_el(prog_out, 'icon', src=("%s/api/images?method=generate&type=content&message=%s" % (base_url, urllib.parse.quote(program['title']))))
if program['rating']: if program['rating']:
rating_out = sub_el(prog_out, 'rating', system="MPAA") rating_out = sub_el(prog_out, 'rating', system="MPAA")

View File

@ -41,7 +41,7 @@ class HDHR_Device_XML():
sub_el(device_out, 'serialNumber') sub_el(device_out, 'serialNumber')
sub_el(device_out, 'UDN', "uuid:" + self.fhdhr.config.dict["main"]["uuid"]) sub_el(device_out, 'UDN', "uuid:%s" % self.fhdhr.config.dict["main"]["uuid"])
fakefile = BytesIO() fakefile = BytesIO()
fakefile.write(b'<?xml version="1.0" encoding="UTF-8"?>\n') fakefile.write(b'<?xml version="1.0" encoding="UTF-8"?>\n')

View File

@ -30,7 +30,7 @@ class Lineup_Post():
return Response(status=200, mimetype='text/html') return Response(status=200, mimetype='text/html')
else: else:
self.fhdhr.logger.warning("Unknown scan command " + request.args['scan']) self.fhdhr.logger.warning("Unknown scan command %s" % request.args['scan'])
return abort(200, "Not a valid scan command") return abort(200, "Not a valid scan command")
elif 'favorite' in list(request.args.keys()): elif 'favorite' in list(request.args.keys()):
@ -53,7 +53,7 @@ class Lineup_Post():
self.fhdhr.device.channels.set_channel_enablement("number", channel_number, "toggle") self.fhdhr.device.channels.set_channel_enablement("number", channel_number, "toggle")
else: else:
self.fhdhr.logger.warning("Unknown favorite command " + request.args['favorite']) self.fhdhr.logger.warning("Unknown favorite command %s" % request.args['favorite'])
return abort(200, "Not a valid favorite command") return abort(200, "Not a valid favorite command")
else: else:

View File

@ -35,12 +35,12 @@ class Cluster_HTML():
location_name = self.fhdhr.device.cluster.cluster()[location]["name"] location_name = self.fhdhr.device.cluster.cluster()[location]["name"]
else: else:
try: try:
location_info_url = location + "/discover.json" location_info_url = "%s/discover.json" % location
location_info_req = self.fhdhr.web.session.get(location_info_url) location_info_req = self.fhdhr.web.session.get(location_info_url)
location_info = location_info_req.json() location_info = location_info_req.json()
location_name = location_info["FriendlyName"] location_name = location_info["FriendlyName"]
except self.fhdhr.web.exceptions.ConnectionError: except self.fhdhr.web.exceptions.ConnectionError:
self.fhdhr.logger.error("Unreachable: " + location) self.fhdhr.logger.error("Unreachable: %s" % location)
location_dict = { location_dict = {
"name": location_name, "name": location_name,
"location": location, "location": location,