mirror of
https://github.com/fHDHR/fHDHR_NextPVR.git
synced 2025-12-06 07:56:57 -05:00
commit
74f0f17a29
@ -172,26 +172,26 @@ class EPGhandler():
|
|||||||
timestamps.append(timestampdict)
|
timestamps.append(timestampdict)
|
||||||
|
|
||||||
for c in self.serviceproxy.get_channels():
|
for c in self.serviceproxy.get_channels():
|
||||||
if str(c["formatted-number"]) not in list(programguide.keys()):
|
if str(c["number"]) not in list(programguide.keys()):
|
||||||
programguide[str(c["formatted-number"])] = {}
|
programguide[str(c["number"])] = {}
|
||||||
|
|
||||||
channel_thumb_path = ("/images?source=empty&type=channel&id=%s" % (str(c['formatted-number'])))
|
channel_thumb_path = ("/images?source=empty&type=channel&id=%s" % (str(c['number'])))
|
||||||
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()):
|
if "name" not in list(programguide[str(c["number"])].keys()):
|
||||||
programguide[str(c["formatted-number"])]["name"] = c["name"]
|
programguide[str(c["number"])]["name"] = c["name"]
|
||||||
|
|
||||||
if "callsign" not in list(programguide[str(c["formatted-number"])].keys()):
|
if "callsign" not in list(programguide[str(c["number"])].keys()):
|
||||||
programguide[str(c["formatted-number"])]["callsign"] = c["name"]
|
programguide[str(c["number"])]["callsign"] = c["name"]
|
||||||
|
|
||||||
if "id" not in list(programguide[str(c["formatted-number"])].keys()):
|
if "id" not in list(programguide[str(c["number"])].keys()):
|
||||||
programguide[str(c["formatted-number"])]["id"] = c["id"]
|
programguide[str(c["number"])]["id"] = c["id"]
|
||||||
|
|
||||||
if "number" not in list(programguide[str(c["formatted-number"])].keys()):
|
if "number" not in list(programguide[str(c["number"])].keys()):
|
||||||
programguide[str(c["formatted-number"])]["number"] = c["formatted-number"]
|
programguide[str(c["number"])]["number"] = c["number"]
|
||||||
|
|
||||||
if "listing" not in list(programguide[str(c["formatted-number"])].keys()):
|
if "listing" not in list(programguide[str(c["number"])].keys()):
|
||||||
programguide[str(c["formatted-number"])]["listing"] = []
|
programguide[str(c["number"])]["listing"] = []
|
||||||
|
|
||||||
for timestamp in timestamps:
|
for timestamp in timestamps:
|
||||||
clean_prog_dict = {}
|
clean_prog_dict = {}
|
||||||
@ -200,7 +200,7 @@ class EPGhandler():
|
|||||||
clean_prog_dict["time_end"] = timestamp['time_end']
|
clean_prog_dict["time_end"] = timestamp['time_end']
|
||||||
clean_prog_dict["duration_minutes"] = 60.0
|
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["thumbnail"] = content_thumb
|
||||||
|
|
||||||
clean_prog_dict["title"] = "Unavailable"
|
clean_prog_dict["title"] = "Unavailable"
|
||||||
@ -216,7 +216,7 @@ class EPGhandler():
|
|||||||
|
|
||||||
clean_prog_dict['rating'] = "N/A"
|
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
|
self.epg_cache = programguide
|
||||||
with open(self.empty_cache_file, 'w') as epgfile:
|
with open(self.empty_cache_file, 'w') as epgfile:
|
||||||
|
|||||||
@ -23,9 +23,8 @@ class ZapEPG():
|
|||||||
def __init__(self, config):
|
def __init__(self, config):
|
||||||
|
|
||||||
self.config = config.config
|
self.config = config.config
|
||||||
self.postalcode = config.config["zap2xml"]["postalcode"]
|
|
||||||
if not self.postalcode:
|
self.postalcode = None
|
||||||
self.postalcode = self.get_location()
|
|
||||||
|
|
||||||
self.epg_cache = None
|
self.epg_cache = None
|
||||||
self.cache_dir = config.config["main"]["zap_web_cache"]
|
self.cache_dir = config.config["main"]["zap_web_cache"]
|
||||||
@ -33,10 +32,12 @@ class ZapEPG():
|
|||||||
self.epg_cache = self.epg_cache_open()
|
self.epg_cache = self.epg_cache_open()
|
||||||
|
|
||||||
def get_location(self):
|
def get_location(self):
|
||||||
url = 'http://ipinfo.io/json'
|
self.postalcode = self.config["zap2xml"]["postalcode"]
|
||||||
response = urllib.request.urlopen(url)
|
if self.postalcode:
|
||||||
data = json.load(response)
|
url = 'http://ipinfo.io/json'
|
||||||
return data["postal"]
|
response = urllib.request.urlopen(url)
|
||||||
|
data = json.load(response)
|
||||||
|
return data["postal"]
|
||||||
|
|
||||||
def epg_cache_open(self):
|
def epg_cache_open(self):
|
||||||
epg_cache = None
|
epg_cache = None
|
||||||
@ -87,6 +88,8 @@ class ZapEPG():
|
|||||||
print('Updating Zap2it EPG cache file.')
|
print('Updating Zap2it EPG cache file.')
|
||||||
programguide = {}
|
programguide = {}
|
||||||
|
|
||||||
|
self.get_location()
|
||||||
|
|
||||||
# Start time parameter is now rounded down to nearest `zap_timespan`, in s.
|
# Start time parameter is now rounded down to nearest `zap_timespan`, in s.
|
||||||
zap_time = time.mktime(time.localtime())
|
zap_time = time.mktime(time.localtime())
|
||||||
zap_time_window = int(self.config["zap2xml"]["timespan"]) * 3600
|
zap_time_window = int(self.config["zap2xml"]["timespan"]) * 3600
|
||||||
@ -107,7 +110,7 @@ class ZapEPG():
|
|||||||
'timespan': self.config["zap2xml"]['timespan'],
|
'timespan': self.config["zap2xml"]['timespan'],
|
||||||
'timezone': self.config["zap2xml"]['timezone'],
|
'timezone': self.config["zap2xml"]['timezone'],
|
||||||
'userId': self.config["zap2xml"]['userid'],
|
'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']),
|
'lineupId': '%s-%s-DEFAULT' % (self.config["zap2xml"]['country'], self.config["zap2xml"]['device']),
|
||||||
'time': i_time,
|
'time': i_time,
|
||||||
'Activity_ID': 1,
|
'Activity_ID': 1,
|
||||||
|
|||||||
@ -126,7 +126,12 @@ class proxyserviceFetcher():
|
|||||||
for c in channel_o_list:
|
for c in channel_o_list:
|
||||||
dString = json.dumps(c)
|
dString = json.dumps(c)
|
||||||
channel_dict = eval(dString)
|
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
|
return channel_list
|
||||||
|
|
||||||
def get_station_list(self, base_url):
|
def get_station_list(self, base_url):
|
||||||
@ -141,11 +146,11 @@ class proxyserviceFetcher():
|
|||||||
("http://",
|
("http://",
|
||||||
base_url,
|
base_url,
|
||||||
watchtype,
|
watchtype,
|
||||||
c['formatted-number']
|
c['number']
|
||||||
))
|
))
|
||||||
station_list.append(
|
station_list.append(
|
||||||
{
|
{
|
||||||
'GuideNumber': str(c['formatted-number']),
|
'GuideNumber': str(c['number']),
|
||||||
'GuideName': c['name'],
|
'GuideName': c['name'],
|
||||||
'URL': url
|
'URL': url
|
||||||
})
|
})
|
||||||
@ -164,10 +169,10 @@ class proxyserviceFetcher():
|
|||||||
("https://" if self.config["nextpvr"]["ssl"] else "http://",
|
("https://" if self.config["nextpvr"]["ssl"] else "http://",
|
||||||
self.config["nextpvr"]["address"],
|
self.config["nextpvr"]["address"],
|
||||||
str(self.config["nextpvr"]["port"]),
|
str(self.config["nextpvr"]["port"]),
|
||||||
str(c["formatted-number"]),
|
str(c["number"]),
|
||||||
str(c["formatted-number"]),
|
str(c["number"]),
|
||||||
))
|
))
|
||||||
streamdict[str(c["formatted-number"])] = url
|
streamdict[str(c["number"])] = url
|
||||||
return streamdict
|
return streamdict
|
||||||
|
|
||||||
def get_channel_thumbnail(self, channel_id):
|
def get_channel_thumbnail(self, channel_id):
|
||||||
@ -197,26 +202,26 @@ class proxyserviceFetcher():
|
|||||||
programguide = {}
|
programguide = {}
|
||||||
|
|
||||||
for c in self.get_channels():
|
for c in self.get_channels():
|
||||||
if str(c["formatted-number"]) not in list(programguide.keys()):
|
if str(c["number"]) not in list(programguide.keys()):
|
||||||
programguide[str(c["formatted-number"])] = {}
|
programguide[str(c["number"])] = {}
|
||||||
|
|
||||||
channel_thumb_path = ("/images?source=proxy&type=channel&id=%s" % (str(c['id'])))
|
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()):
|
if "name" not in list(programguide[str(c["number"])].keys()):
|
||||||
programguide[str(c["formatted-number"])]["name"] = c["name"]
|
programguide[str(c["number"])]["name"] = c["name"]
|
||||||
|
|
||||||
if "callsign" not in list(programguide[str(c["formatted-number"])].keys()):
|
if "callsign" not in list(programguide[str(c["number"])].keys()):
|
||||||
programguide[str(c["formatted-number"])]["callsign"] = c["name"]
|
programguide[str(c["number"])]["callsign"] = c["name"]
|
||||||
|
|
||||||
if "id" not in list(programguide[str(c["formatted-number"])].keys()):
|
if "id" not in list(programguide[str(c["number"])].keys()):
|
||||||
programguide[str(c["formatted-number"])]["id"] = c["id"]
|
programguide[str(c["number"])]["id"] = c["id"]
|
||||||
|
|
||||||
if "number" not in list(programguide[str(c["formatted-number"])].keys()):
|
if "number" not in list(programguide[str(c["number"])].keys()):
|
||||||
programguide[str(c["formatted-number"])]["number"] = c["formatted-number"]
|
programguide[str(c["number"])]["number"] = c["number"]
|
||||||
|
|
||||||
if "listing" not in list(programguide[str(c["formatted-number"])].keys()):
|
if "listing" not in list(programguide[str(c["number"])].keys()):
|
||||||
programguide[str(c["formatted-number"])]["listing"] = []
|
programguide[str(c["number"])]["listing"] = []
|
||||||
|
|
||||||
epg_url = ('%s%s:%s/service?method=channel.listings&channel_id=%s' %
|
epg_url = ('%s%s:%s/service?method=channel.listings&channel_id=%s' %
|
||||||
("https://" if self.config["nextpvr"]["ssl"] else "http://",
|
("https://" if self.config["nextpvr"]["ssl"] else "http://",
|
||||||
@ -283,7 +288,7 @@ class proxyserviceFetcher():
|
|||||||
|
|
||||||
# TODO isNEW
|
# 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
|
self.epg_cache = programguide
|
||||||
with open(self.epg_cache_file, 'w') as epgfile:
|
with open(self.epg_cache_file, 'w') as epgfile:
|
||||||
|
|||||||
@ -2,3 +2,4 @@ requests
|
|||||||
gevent
|
gevent
|
||||||
flask
|
flask
|
||||||
image
|
image
|
||||||
|
xmltodict
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user