1
0
mirror of https://github.com/fHDHR/fHDHR_NextPVR.git synced 2025-12-06 07:26:57 -05:00
This commit is contained in:
deathbybandaid 2020-09-29 17:09:24 -04:00
parent c42028dd9e
commit 8df57591b2
4 changed files with 53 additions and 44 deletions

View File

@ -172,26 +172,26 @@ class EPGhandler():
timestamps.append(timestampdict)
for c in self.serviceproxy.get_channels():
if str(c["formatted-number"]) not in list(programguide.keys()):
programguide[str(c["formatted-number"])] = {}
if str(c["number"]) not in list(programguide.keys()):
programguide[str(c["number"])] = {}
channel_thumb_path = ("/images?source=empty&type=channel&id=%s" % (str(c['formatted-number'])))
programguide[str(c["formatted-number"])]["thumbnail"] = channel_thumb_path
channel_thumb_path = ("/images?source=empty&type=channel&id=%s" % (str(c['number'])))
programguide[str(c["number"])]["thumbnail"] = channel_thumb_path
if "name" not in list(programguide[str(c["formatted-number"])].keys()):
programguide[str(c["formatted-number"])]["name"] = c["name"]
if "name" not in list(programguide[str(c["number"])].keys()):
programguide[str(c["number"])]["name"] = c["name"]
if "callsign" not in list(programguide[str(c["formatted-number"])].keys()):
programguide[str(c["formatted-number"])]["callsign"] = c["name"]
if "callsign" not in list(programguide[str(c["number"])].keys()):
programguide[str(c["number"])]["callsign"] = c["name"]
if "id" not in list(programguide[str(c["formatted-number"])].keys()):
programguide[str(c["formatted-number"])]["id"] = c["id"]
if "id" not in list(programguide[str(c["number"])].keys()):
programguide[str(c["number"])]["id"] = c["id"]
if "number" not in list(programguide[str(c["formatted-number"])].keys()):
programguide[str(c["formatted-number"])]["number"] = c["formatted-number"]
if "number" not in list(programguide[str(c["number"])].keys()):
programguide[str(c["number"])]["number"] = c["number"]
if "listing" not in list(programguide[str(c["formatted-number"])].keys()):
programguide[str(c["formatted-number"])]["listing"] = []
if "listing" not in list(programguide[str(c["number"])].keys()):
programguide[str(c["number"])]["listing"] = []
for timestamp in timestamps:
clean_prog_dict = {}
@ -200,7 +200,7 @@ class EPGhandler():
clean_prog_dict["time_end"] = timestamp['time_end']
clean_prog_dict["duration_minutes"] = 60.0
content_thumb = ("/images?source=empty&type=content&id=%s" % (str(c['formatted-number'])))
content_thumb = ("/images?source=empty&type=content&id=%s" % (str(c['number'])))
clean_prog_dict["thumbnail"] = content_thumb
clean_prog_dict["title"] = "Unavailable"
@ -216,7 +216,7 @@ class EPGhandler():
clean_prog_dict['rating'] = "N/A"
programguide[str(c["formatted-number"])]["listing"].append(clean_prog_dict)
programguide[str(c["number"])]["listing"].append(clean_prog_dict)
self.epg_cache = programguide
with open(self.empty_cache_file, 'w') as epgfile:

View File

@ -23,9 +23,8 @@ class ZapEPG():
def __init__(self, config):
self.config = config.config
self.postalcode = config.config["zap2xml"]["postalcode"]
if not self.postalcode:
self.postalcode = self.get_location()
self.postalcode = None
self.epg_cache = None
self.cache_dir = config.config["main"]["zap_web_cache"]
@ -33,10 +32,12 @@ class ZapEPG():
self.epg_cache = self.epg_cache_open()
def get_location(self):
url = 'http://ipinfo.io/json'
response = urllib.request.urlopen(url)
data = json.load(response)
return data["postal"]
self.postalcode = self.config["zap2xml"]["postalcode"]
if self.postalcode:
url = 'http://ipinfo.io/json'
response = urllib.request.urlopen(url)
data = json.load(response)
return data["postal"]
def epg_cache_open(self):
epg_cache = None
@ -87,6 +88,8 @@ class ZapEPG():
print('Updating Zap2it EPG cache file.')
programguide = {}
self.get_location()
# Start time parameter is now rounded down to nearest `zap_timespan`, in s.
zap_time = time.mktime(time.localtime())
zap_time_window = int(self.config["zap2xml"]["timespan"]) * 3600
@ -107,7 +110,7 @@ class ZapEPG():
'timespan': self.config["zap2xml"]['timespan'],
'timezone': self.config["zap2xml"]['timezone'],
'userId': self.config["zap2xml"]['userid'],
'postalCode': self.config["zap2xml"]['postalcode'],
'postalCode': self.postalcode,
'lineupId': '%s-%s-DEFAULT' % (self.config["zap2xml"]['country'], self.config["zap2xml"]['device']),
'time': i_time,
'Activity_ID': 1,

View File

@ -126,7 +126,12 @@ class proxyserviceFetcher():
for c in channel_o_list:
dString = json.dumps(c)
channel_dict = eval(dString)
channel_list.append(channel_dict)
clean_station_item = {
"name": channel_dict["name"],
"number": channel_dict["formatted-number"],
"id": channel_dict["id"],
}
channel_list.append(clean_station_item)
return channel_list
def get_station_list(self, base_url):
@ -141,11 +146,11 @@ class proxyserviceFetcher():
("http://",
base_url,
watchtype,
c['formatted-number']
c['number']
))
station_list.append(
{
'GuideNumber': str(c['formatted-number']),
'GuideNumber': str(c['number']),
'GuideName': c['name'],
'URL': url
})
@ -164,10 +169,10 @@ class proxyserviceFetcher():
("https://" if self.config["nextpvr"]["ssl"] else "http://",
self.config["nextpvr"]["address"],
str(self.config["nextpvr"]["port"]),
str(c["formatted-number"]),
str(c["formatted-number"]),
str(c["number"]),
str(c["number"]),
))
streamdict[str(c["formatted-number"])] = url
streamdict[str(c["number"])] = url
return streamdict
def get_channel_thumbnail(self, channel_id):
@ -197,26 +202,26 @@ class proxyserviceFetcher():
programguide = {}
for c in self.get_channels():
if str(c["formatted-number"]) not in list(programguide.keys()):
programguide[str(c["formatted-number"])] = {}
if str(c["number"]) not in list(programguide.keys()):
programguide[str(c["number"])] = {}
channel_thumb_path = ("/images?source=proxy&type=channel&id=%s" % (str(c['id'])))
programguide[str(c["formatted-number"])]["thumbnail"] = channel_thumb_path
programguide[str(c["number"])]["thumbnail"] = channel_thumb_path
if "name" not in list(programguide[str(c["formatted-number"])].keys()):
programguide[str(c["formatted-number"])]["name"] = c["name"]
if "name" not in list(programguide[str(c["number"])].keys()):
programguide[str(c["number"])]["name"] = c["name"]
if "callsign" not in list(programguide[str(c["formatted-number"])].keys()):
programguide[str(c["formatted-number"])]["callsign"] = c["name"]
if "callsign" not in list(programguide[str(c["number"])].keys()):
programguide[str(c["number"])]["callsign"] = c["name"]
if "id" not in list(programguide[str(c["formatted-number"])].keys()):
programguide[str(c["formatted-number"])]["id"] = c["id"]
if "id" not in list(programguide[str(c["number"])].keys()):
programguide[str(c["number"])]["id"] = c["id"]
if "number" not in list(programguide[str(c["formatted-number"])].keys()):
programguide[str(c["formatted-number"])]["number"] = c["formatted-number"]
if "number" not in list(programguide[str(c["number"])].keys()):
programguide[str(c["number"])]["number"] = c["number"]
if "listing" not in list(programguide[str(c["formatted-number"])].keys()):
programguide[str(c["formatted-number"])]["listing"] = []
if "listing" not in list(programguide[str(c["number"])].keys()):
programguide[str(c["number"])]["listing"] = []
epg_url = ('%s%s:%s/service?method=channel.listings&channel_id=%s' %
("https://" if self.config["nextpvr"]["ssl"] else "http://",
@ -283,7 +288,7 @@ class proxyserviceFetcher():
# TODO isNEW
programguide[str(c["formatted-number"])]["listing"].append(clean_prog_dict)
programguide[str(c["number"])]["listing"].append(clean_prog_dict)
self.epg_cache = programguide
with open(self.epg_cache_file, 'w') as epgfile:

View File

@ -2,3 +2,4 @@ requests
gevent
flask
image
xmltodict