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

Merge pull request #122 from deathbybandaid/dev

Update String Formatting
This commit is contained in:
Deathbybandaid 2021-01-08 15:38:25 -05:00 committed by GitHub
commit cdbe545df6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
27 changed files with 81 additions and 86 deletions

View File

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

View File

@ -22,7 +22,7 @@ class zap2itEPG():
data = postalcode_req.json()
postalcode = data["postal"]
except Exception as e:
raise EPGSetupError("Unable to automatically optain postalcode: " + str(e))
raise EPGSetupError("Unable to automatically optain postalcode: %s" % e)
postalcode = None
return postalcode
@ -137,10 +137,10 @@ class zap2itEPG():
def get_cached_item(self, cache_key, url):
cacheitem = self.fhdhr.db.get_cacheitem_value(cache_key, "epg_cache", "zap2it")
if cacheitem:
self.fhdhr.logger.info('FROM CACHE: ' + str(cache_key))
self.fhdhr.logger.info("FROM CACHE: %s" % cache_key)
return cacheitem
else:
self.fhdhr.logger.info('Fetching: ' + url)
self.fhdhr.logger.info("Fetching: %s" % url)
try:
resp = self.fhdhr.web.session.get(url)
except self.fhdhr.web.exceptions.HTTPError:
@ -162,12 +162,12 @@ class zap2itEPG():
if cachedate < zap_time:
cache_to_kill.append(cacheitem)
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")
def clear_cache(self):
cache_list = self.fhdhr.db.get_cacheitem_value("cache_list", "epg_cache", "zap2it") or []
for cacheitem in cache_list:
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")

View File

@ -36,4 +36,4 @@ class fHDHR_OBJ():
def __getattr__(self, name):
''' will only get called for undefined attributes '''
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):
''' will only get called for undefined attributes '''
if hasattr(self.web.session, name):
return eval("self.web.session." + name)
return eval("self.web.session.%s" % name)
class fHDHR_API_URLs():

View File

@ -71,7 +71,7 @@ class Config():
if str(file_item_path).endswith("_conf.json"):
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.load_versions()
@ -270,7 +270,7 @@ class Config():
if not self.dict[req_section][req_key]:
required_missing.append(req_item)
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"])

View File

@ -68,14 +68,14 @@ class fHDHR_Cluster():
for location in list(cluster.keys()):
if location != self.fhdhr.api.base:
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:
sync_open = self.fhdhr.web.session.get(sync_url)
retrieved_cluster = sync_open.json()
if self.fhdhr.api.base not in list(retrieved_cluster.keys()):
return self.leave()
except self.fhdhr.web.exceptions.ConnectionError:
self.fhdhr.logger.error("Unreachable: " + location)
self.fhdhr.logger.error("Unreachable: %s" % location)
def leave(self):
self.fhdhr.logger.info("Leaving cluster.")
@ -86,30 +86,30 @@ class fHDHR_Cluster():
for location in list(cluster.keys()):
if location != self.fhdhr.api.base:
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:
self.fhdhr.web.session.get(sync_url)
except self.fhdhr.web.exceptions.ConnectionError:
self.fhdhr.logger.error("Unreachable: " + location)
self.fhdhr.logger.error("Unreachable: %s" % location)
self.leave()
def sync(self, location):
sync_url = location + "/api/cluster?method=get"
sync_url = "%s/api/cluster?method=get" % location
try:
sync_open = self.fhdhr.web.session.get(sync_url)
self.fhdhr.db.set_fhdhr_value("cluster", "dict", sync_open.json())
except self.fhdhr.web.exceptions.ConnectionError:
self.fhdhr.logger.error("Unreachable: " + location)
self.fhdhr.logger.error("Unreachable: %s" % location)
def push_sync(self):
cluster = self.fhdhr.db.get_fhdhr_value("cluster", "dict") or self.default_cluster()
for location in list(cluster.keys()):
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:
self.fhdhr.web.session.get(sync_url)
except self.fhdhr.web.exceptions.ConnectionError:
self.fhdhr.logger.error("Unreachable: " + location)
self.fhdhr.logger.error("Unreachable: %s" % location)
def add(self, location):
cluster = self.fhdhr.db.get_fhdhr_value("cluster", "dict") or self.default_cluster()
@ -121,18 +121,18 @@ class fHDHR_Cluster():
try:
location_info_req = self.fhdhr.web.session.get(location_info_url)
except self.fhdhr.web.exceptions.ConnectionError:
self.fhdhr.logger.error("Unreachable: " + location)
self.fhdhr.logger.error("Unreachable: %s" % location)
del cluster[location]
self.fhdhr.db.set_fhdhr_value("cluster", "dict", cluster)
return
location_info = location_info_req.json()
cluster[location]["name"] = location_info["FriendlyName"]
cluster_info_url = location + "/api/cluster?method=get"
cluster_info_url = "%s/api/cluster?method=get" % location
try:
cluster_info_req = self.fhdhr.web.session.get(cluster_info_url)
except self.fhdhr.web.exceptions.ConnectionError:
self.fhdhr.logger.error("Unreachable: " + location)
self.fhdhr.logger.error("Unreachable: %s" % location)
del cluster[location]
self.fhdhr.db.set_fhdhr_value("cluster", "dict", cluster)
return
@ -149,10 +149,10 @@ class fHDHR_Cluster():
if location in list(cluster.keys()):
self.fhdhr.logger.info("Removing %s from cluster." % location)
del cluster[location]
sync_url = location + "/api/cluster?method=leave"
sync_url = "%s/api/cluster?method=leave" % location
try:
self.fhdhr.web.session.get(sync_url)
except self.fhdhr.web.exceptions.ConnectionError:
self.fhdhr.logger.error("Unreachable: " + location)
self.fhdhr.logger.error("Unreachable: %s" % location)
self.push_sync()
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"]:
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'):
self.epg_handling[method].clear_cache()
@ -180,7 +180,7 @@ class EPG():
if method in [self.fhdhr.config.dict["main"]["dictpopname"], "origin"]:
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':
programguide = self.epg_handling['origin'].update_epg(self.channels)
else:

View File

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

View File

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

View File

@ -34,7 +34,7 @@ class FFMPEG_Stream():
except GeneratorExit:
self.fhdhr.logger.info("Connection Closed.")
except Exception as e:
self.fhdhr.logger.info("Connection Closed: " + str(e))
self.fhdhr.logger.info("Connection Closed: %s" % e)
finally:
ffmpeg_proc.terminate()
ffmpeg_proc.communicate()
@ -104,7 +104,7 @@ class FFMPEG_Stream():
"""
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
ffmpeg_command = []

View File

@ -35,7 +35,7 @@ class VLC_Stream():
except GeneratorExit:
self.fhdhr.logger.info("Connection Closed.")
except Exception as e:
self.fhdhr.logger.info("Connection Closed: " + str(e))
self.fhdhr.logger.info("Connection Closed: %s" % e)
finally:
vlc_proc.terminate()
vlc_proc.communicate()
@ -96,7 +96,7 @@ class VLC_Stream():
vlc_command = []
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
vlc_transcode_string = "#std{mux=ts,access=file,dst=-}"

View File

@ -49,7 +49,7 @@ class Tuner():
def grab(self, channel_number):
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")
self.tuner_lock.acquire()
self.status["status"] = "Acquired"
@ -60,7 +60,7 @@ class Tuner():
self.set_off_status()
if self.tuner_lock.locked():
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):
current_status = self.status.copy()

View File

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

View File

@ -133,9 +133,9 @@ def humanized_time(countdownseconds):
if currenttimevar > 1:
timetype = str(x+"s")
if displaymsg:
displaymsg = str(displaymsg + " " + str(int(currenttimevar)) + " " + timetype)
displaymsg = "%s %s %s" % (displaymsg, int(currenttimevar), timetype)
else:
displaymsg = str(str(int(currenttimevar)) + " " + timetype)
displaymsg = "%s %s" % (int(currenttimevar), timetype)
if not displaymsg:
return "just now"
return displaymsg
@ -151,4 +151,4 @@ class WebReq():
def __getattr__(self, name):
''' will only get called for undefined attributes '''
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:
# tuner = self.fhdhr.device.tuners.tuners[str(session["tuner_used"])]
# 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()
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)]
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):
endpoints = [endpoints]
handler = eval("self." + str(index_name) + "." + str(item))
endpoint_name = eval("self." + str(index_name) + "." + str(item) + ".endpoint_name")
handler = eval("self.%s.%s" % (index_name, item))
endpoint_name = eval("self.%s.%s.%s" % (index_name, item, "endpoint_name"))
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:
endpoint_methods = ['GET']
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:
endpoint_access_level = 0
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:
pretty_name = endpoint_name
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:
endpoint_default_parameters = {}

View File

@ -50,7 +50,7 @@ class Channels():
channel = request.args.get('channel', default=None, type=str)
if not channel:
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:
return "%s Falied" % method
@ -73,7 +73,7 @@ class Channels():
self.fhdhr.device.channels.set_channel_enablement("number", channel_number, "toggle")
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")
elif method in ["enable", "disable"]:
@ -82,7 +82,7 @@ class Channels():
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")]:
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:
return "%s Falied" % method
else:
@ -148,7 +148,7 @@ class Channels():
return "Invalid Method"
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:
if method == "scan":
return redirect('/lineup_status.json')

View File

@ -54,6 +54,6 @@ class Cluster():
return "Invalid Method"
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:
return "%s Success" % method

View File

@ -55,6 +55,6 @@ class EPG():
return "%s Invalid Method" % method
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:
return "%s Success" % method

View File

@ -33,12 +33,7 @@ class M3U():
xmltvurl = ('%s/api/xmltv' % base_url)
fakefile.write(
"%s\n" % (
FORMAT_DESCRIPTOR + " " +
"url-tvg=\"" + xmltvurl + "\"" + " " +
"x-tvg-url=\"" + xmltvurl + "\"")
)
fakefile.write("%s url-tvg=\"%s\" x-tvg-url=\"%s\"\n" % (FORMAT_DESCRIPTOR, xmltvurl, xmltvurl))
channel_items = []
@ -50,7 +45,7 @@ class M3U():
channel_items.append(channel_obj)
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)
fileName = str(channel_obj.number) + ".m3u"
fileName = "%s.m3u" % channel_obj.number
if channel_obj.enabled:
channel_items.append(channel_obj)
else:
@ -96,10 +91,10 @@ class M3U():
channels_m3u = fakefile.getvalue()
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
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:
return "%s Success" % method

View File

@ -32,6 +32,6 @@ class Route_List():
return "%s Invalid Method" % method
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:
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 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:
return "%s Falied" % method
@ -64,13 +64,13 @@ class Settings():
elif method == "restart":
restart_thread = threading.Thread(target=self.restart_thread)
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":
session["restart"] = True
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:
return "%s Success" % method

View File

@ -53,6 +53,6 @@ class API_Tools():
return "%s Invalid Method" % method
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:
return "%s Success" % method

View File

@ -75,7 +75,7 @@ class Tuners():
"transcode": transcode,
"accessed": accessed_url,
"client": client_address,
"client_id": str(client_address) + "_" + str(uuid.uuid4())
"client_id": "%s_%s" % (client_address, uuid.uuid4())
}
try:
@ -104,7 +104,7 @@ class Tuners():
tuner.close()
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)
session["tuner_used"] = tunernum
@ -148,6 +148,6 @@ class Tuners():
return "%s Invalid Method" % method
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:
return "%s Success" % method

View File

@ -74,7 +74,7 @@ class xmlTV():
return "%s Invalid Method" % method
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:
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-name', self.fhdhr.config.dict["main"]["servicename"])
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
def xmltv_file(self, xmltvgen):
@ -135,7 +135,7 @@ class xmlTV():
sub_el(c_out, 'display-name', text=epgdict[c]['name'])
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:
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, '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'])))
@ -178,11 +178,11 @@ class xmlTV():
if program["thumbnail"]:
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:
sub_el(prog_out, 'icon', src=(program["thumbnail"]))
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']:
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, 'UDN', "uuid:" + self.fhdhr.config.dict["main"]["uuid"])
sub_el(device_out, 'UDN', "uuid:%s" % self.fhdhr.config.dict["main"]["uuid"])
fakefile = BytesIO()
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')
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")
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")
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")
else:

View File

@ -35,12 +35,12 @@ class Cluster_HTML():
location_name = self.fhdhr.device.cluster.cluster()[location]["name"]
else:
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 = location_info_req.json()
location_name = location_info["FriendlyName"]
except self.fhdhr.web.exceptions.ConnectionError:
self.fhdhr.logger.error("Unreachable: " + location)
self.fhdhr.logger.error("Unreachable: %s" % location)
location_dict = {
"name": location_name,
"location": location,