mirror of
https://github.com/fHDHR/fHDHR_NextPVR.git
synced 2025-12-06 09:26:57 -05:00
commit
795b43d1cf
@ -11,7 +11,8 @@
|
|||||||
<th>Channel CallSign</th>
|
<th>Channel CallSign</th>
|
||||||
<th>Channel Number</th>
|
<th>Channel Number</th>
|
||||||
<th>Status</th>
|
<th>Status</th>
|
||||||
<th>Options</th>
|
<th>Update</th>
|
||||||
|
<th>Reset</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
{% for chan_dict in channelslist %}
|
{% for chan_dict in channelslist %}
|
||||||
@ -21,25 +22,35 @@
|
|||||||
<a href="{{ chan_dict["play_url"] }}">Play</a>
|
<a href="{{ chan_dict["play_url"] }}">Play</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
<td>{{ chan_dict["name"] }}</td>
|
|
||||||
<td>{{ chan_dict["callsign"] }}</td>
|
<form method="post" action="/api/channels?method=update&redirect=%2Fchannels">
|
||||||
<td>{{ chan_dict["number"] }}</td>
|
<input type="hidden" name="id" value={{ chan_dict["id"] }}>
|
||||||
|
<td data-th="Channel Name"><input type="text" size="50" name="name" value={{ chan_dict["name"] }}></td>
|
||||||
|
<td data-th="Channel Calsign"><input type="text" size="50" name="callsign" value={{ chan_dict["callsign"] }}></td>
|
||||||
|
<td data-th="Channel Number"><input type="text" size="50" name="number" value={{ chan_dict["number"] }}></td>
|
||||||
<td>
|
<td>
|
||||||
|
<select name="enabled">
|
||||||
{% if chan_dict["enabled"] %}
|
{% if chan_dict["enabled"] %}
|
||||||
Enabled
|
<option value=True selected>Enabled</option>
|
||||||
{% elif not chan_dict["enabled"] %}
|
<option value=False>Disabled</option>
|
||||||
Disabled
|
{% else %}
|
||||||
|
<option value=True>Enabled</option>
|
||||||
|
<option value=False selected>Disabled</option>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
</select>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td data-th="Update"><input type="submit" value="Update"></td>
|
||||||
<div>
|
</form>
|
||||||
{% if chan_dict["enabled"] %}
|
|
||||||
<button onclick="OpenLink('/api/channels?method=disable&channel={{ chan_dict["number"] }}&redirect=%2Fchannels')">Disable</a></button>
|
<form method="post" action="/api/channels?method=update&redirect=%2Fchannels">
|
||||||
{% elif not chan_dict["enabled"] %}
|
<input type="hidden" name="id" value={{ chan_dict["id"] }}>
|
||||||
<button onclick="OpenLink('/api/channels?method=enable&channel={{ chan_dict["number"] }}&redirect=%2Fchannels')">Enable</a></button>
|
<input type="hidden" name="name" value={{ chan_dict["origin_name"] }}>
|
||||||
{% endif %}
|
<input type="hidden" name="callsign" value={{ chan_dict["origin_callsign"] }}>
|
||||||
</div>
|
<input type="hidden" name="number" value={{ chan_dict["origin_number"] }}>
|
||||||
</td>
|
<input type="hidden" name="enabled" value=True>
|
||||||
|
<td data-th="Reset"><input type="submit" value="Reset"></td>
|
||||||
|
</form>
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
|
|||||||
@ -26,14 +26,14 @@ class Channels():
|
|||||||
def get_channel_list(self, keyfind):
|
def get_channel_list(self, keyfind):
|
||||||
return [self.list[x].dict[keyfind] for x in list(self.list.keys())]
|
return [self.list[x].dict[keyfind] for x in list(self.list.keys())]
|
||||||
|
|
||||||
def set_channel_status(self, keyfind, valfind, enablement):
|
def set_channel_status(self, keyfind, valfind, updatedict):
|
||||||
self.get_channel_obj(keyfind, valfind).set_status(enablement)
|
self.get_channel_obj(keyfind, valfind).set_status(updatedict)
|
||||||
|
|
||||||
def get_db_channels(self):
|
def get_db_channels(self):
|
||||||
channel_ids = self.fhdhr.db.get_fhdhr_value("channels", "IDs") or []
|
channel_ids = self.fhdhr.db.get_fhdhr_value("channels", "list") or []
|
||||||
for channel_id in channel_ids:
|
for channel_id in channel_ids:
|
||||||
channel_obj = Channel(self.fhdhr, self.id_system, channel_id=channel_id)
|
channel_obj = Channel(self.fhdhr, self.id_system, channel_id=channel_id)
|
||||||
channel_id = channel_obj.dict["fhdhr_id"]
|
channel_id = channel_obj.dict["id"]
|
||||||
self.list[channel_id] = channel_obj
|
self.list[channel_id] = channel_obj
|
||||||
|
|
||||||
def get_channels(self, forceupdate=False):
|
def get_channels(self, forceupdate=False):
|
||||||
@ -56,7 +56,7 @@ class Channels():
|
|||||||
channel_dict_list = self.origin.get_channels()
|
channel_dict_list = self.origin.get_channels()
|
||||||
for channel_info in channel_dict_list:
|
for channel_info in channel_dict_list:
|
||||||
channel_obj = Channel(self.fhdhr, self.id_system, origin_id=channel_info["id"])
|
channel_obj = Channel(self.fhdhr, self.id_system, origin_id=channel_info["id"])
|
||||||
channel_id = channel_obj.dict["fhdhr_id"]
|
channel_id = channel_obj.dict["id"]
|
||||||
channel_obj.basics(channel_info)
|
channel_obj.basics(channel_info)
|
||||||
self.list[channel_id] = channel_obj
|
self.list[channel_id] = channel_obj
|
||||||
|
|
||||||
|
|||||||
@ -6,28 +6,28 @@ class Channel_IDs():
|
|||||||
self.fhdhr = fhdhr
|
self.fhdhr = fhdhr
|
||||||
|
|
||||||
def get(self, origin_id):
|
def get(self, origin_id):
|
||||||
existing_ids = self.fhdhr.db.get_fhdhr_value("channels", "IDs") or []
|
existing_ids = self.fhdhr.db.get_fhdhr_value("channels", "list") or []
|
||||||
existing_channel_info = [self.fhdhr.db.get_channel_value(channel_id, "info") or {} for channel_id in existing_ids]
|
existing_channel_info = [self.fhdhr.db.get_channel_value(channel_id, "dict") or {} for channel_id in existing_ids]
|
||||||
for existing_channel in existing_channel_info:
|
for existing_channel in existing_channel_info:
|
||||||
if existing_channel["origin_id"] == origin_id:
|
if existing_channel["origin_id"] == origin_id:
|
||||||
return existing_channel["fhdhr_id"]
|
return existing_channel["id"]
|
||||||
return self.assign()
|
return self.assign()
|
||||||
|
|
||||||
def assign(self):
|
def assign(self):
|
||||||
existing_ids = self.fhdhr.db.get_fhdhr_value("channels", "IDs") or []
|
existing_ids = self.fhdhr.db.get_fhdhr_value("channels", "list") or []
|
||||||
channel_id = None
|
channel_id = None
|
||||||
while not channel_id:
|
while not channel_id:
|
||||||
unique_id = str(uuid.uuid4())
|
unique_id = str(uuid.uuid4())
|
||||||
if str(unique_id) not in existing_ids:
|
if str(unique_id) not in existing_ids:
|
||||||
channel_id = str(unique_id)
|
channel_id = str(unique_id)
|
||||||
existing_ids.append(channel_id)
|
existing_ids.append(channel_id)
|
||||||
self.fhdhr.db.set_fhdhr_value("channels", "IDs", existing_ids)
|
self.fhdhr.db.set_fhdhr_value("channels", "list", existing_ids)
|
||||||
return channel_id
|
return channel_id
|
||||||
|
|
||||||
def get_number(self, channel_id):
|
def get_number(self, channel_id):
|
||||||
existing_ids = self.fhdhr.db.get_fhdhr_value("channels", "IDs") or []
|
existing_ids = self.fhdhr.db.get_fhdhr_value("channels", "list") or []
|
||||||
existing_channel_info = [self.fhdhr.db.get_channel_value(channel_id, "info") or {} for channel_id in existing_ids]
|
existing_channel_info = [self.fhdhr.db.get_channel_value(channel_id, "dict") or {} for channel_id in existing_ids]
|
||||||
cnumber = [existing_channel["number"] for existing_channel in existing_channel_info if existing_channel["fhdhr_id"] == channel_id] or None
|
cnumber = [existing_channel["number"] for existing_channel in existing_channel_info if existing_channel["id"] == channel_id] or None
|
||||||
if cnumber:
|
if cnumber:
|
||||||
return cnumber
|
return cnumber
|
||||||
|
|
||||||
|
|||||||
@ -12,63 +12,63 @@ class Channel():
|
|||||||
channel_id = id_system.get(origin_id)
|
channel_id = id_system.get(origin_id)
|
||||||
else:
|
else:
|
||||||
channel_id = id_system.assign()
|
channel_id = id_system.assign()
|
||||||
self.dict = self.fhdhr.db.get_channel_value(str(channel_id), "info") or self.create_empty_channel(channel_id)
|
self.dict = self.fhdhr.db.get_channel_value(str(channel_id), "dict") or self.create_empty_channel(channel_id)
|
||||||
self.fhdhr.db.set_channel_value(self.dict["fhdhr_id"], "info", self.dict)
|
self.fhdhr.db.set_channel_value(self.dict["id"], "dict", self.dict)
|
||||||
|
|
||||||
def basics(self, channel_info):
|
def basics(self, channel_info):
|
||||||
"""Some Channel Information is Critical"""
|
"""Some Channel Information is Critical"""
|
||||||
|
|
||||||
if "id" in list(channel_info.keys()):
|
|
||||||
channel_info["origin_id"] = channel_info["id"]
|
|
||||||
del channel_info["id"]
|
|
||||||
|
|
||||||
if "name" not in list(channel_info.keys()):
|
if "name" not in list(channel_info.keys()):
|
||||||
channel_info["name"] = self.dict["fhdhr_id"]
|
channel_info["name"] = self.dict["id"]
|
||||||
|
self.dict["origin_name"] = channel_info["name"]
|
||||||
|
if not self.dict["name"]:
|
||||||
|
self.dict["name"] = self.dict["origin_name"]
|
||||||
|
|
||||||
|
if "id" not in list(channel_info.keys()):
|
||||||
|
channel_info["id"] = channel_info["name"]
|
||||||
|
self.dict["origin_id"] = channel_info["id"]
|
||||||
|
|
||||||
if "callsign" not in list(channel_info.keys()):
|
if "callsign" not in list(channel_info.keys()):
|
||||||
channel_info["callsign"] = channel_info["name"]
|
channel_info["callsign"] = channel_info["name"]
|
||||||
|
self.dict["origin_callsign"] = channel_info["callsign"]
|
||||||
if "origin_id" not in list(channel_info.keys()):
|
if not self.dict["callsign"]:
|
||||||
channel_info["origin_id"] = channel_info["name"]
|
self.dict["callsign"] = self.dict["origin_callsign"]
|
||||||
|
|
||||||
if "tags" not in list(channel_info.keys()):
|
if "tags" not in list(channel_info.keys()):
|
||||||
channel_info["tags"] = []
|
channel_info["tags"] = []
|
||||||
|
self.dict["origin_tags"] = channel_info["tags"]
|
||||||
|
if not self.dict["tags"]:
|
||||||
|
self.dict["tags"] = self.dict["origin_tags"]
|
||||||
|
|
||||||
if "number" not in list(channel_info.keys()):
|
if "number" not in list(channel_info.keys()):
|
||||||
channel_info["number"] = self.id_system.get_number(channel_info["origin_id"])
|
channel_info["number"] = self.id_system.get_number(channel_info["origin_id"])
|
||||||
channel_info["number"] = str(float(channel_info["number"]))
|
self.dict["origin_number"] = str(float(channel_info["number"]))
|
||||||
|
if not self.dict["number"]:
|
||||||
|
self.dict["number"] = self.dict["origin_number"]
|
||||||
|
|
||||||
self.append_channel_info(channel_info)
|
self.fhdhr.db.set_channel_value(self.dict["id"], "dict", self.dict)
|
||||||
|
|
||||||
def create_empty_channel(self, channel_id):
|
def create_empty_channel(self, channel_id):
|
||||||
return {
|
return {
|
||||||
"fhdhr_id": str(channel_id),
|
"id": str(channel_id), "origin_id": None,
|
||||||
"origin_id": None,
|
"name": None, "origin_name": None,
|
||||||
"name": None,
|
"callsign": None, "origin_callsign": None,
|
||||||
"callsign": None,
|
"number": None, "origin_number": None,
|
||||||
"number": None,
|
"tags": [], "origin_tags": [],
|
||||||
"tags": [],
|
|
||||||
"enabled": True
|
"enabled": True
|
||||||
}
|
}
|
||||||
|
|
||||||
def destroy(self):
|
def destroy(self):
|
||||||
self.fhdhr.db.delete_channel_value(self.dict["fhdhr_id"], "info")
|
self.fhdhr.db.delete_channel_value(self.dict["id"], "dict")
|
||||||
channel_ids = self.fhdhr.db.get_fhdhr_value("channels", "IDs") or []
|
channel_ids = self.fhdhr.db.get_fhdhr_value("channels", "list") or []
|
||||||
if self.dict["fhdhr_id"] in channel_ids:
|
if self.dict["id"] in channel_ids:
|
||||||
channel_ids.remove(self.dict["fhdhr_id"])
|
channel_ids.remove(self.dict["id"])
|
||||||
self.fhdhr.db.set_fhdhr_value("channels", "IDs", channel_ids)
|
self.fhdhr.db.set_fhdhr_value("channels", "list", channel_ids)
|
||||||
|
|
||||||
def append_channel_info(self, channel_info):
|
def set_status(self, updatedict):
|
||||||
for chankey in list(channel_info.keys()):
|
for key in list(updatedict.keys()):
|
||||||
self.dict[chankey] = channel_info[chankey]
|
self.dict[key] = updatedict[key]
|
||||||
self.fhdhr.db.set_channel_value(self.dict["fhdhr_id"], "info", self.dict)
|
self.fhdhr.db.set_channel_value(self.dict["id"], "dict", self.dict)
|
||||||
|
|
||||||
def set_status(self, enablement):
|
|
||||||
if enablement == "disable":
|
|
||||||
self.dict["enabled"] = False
|
|
||||||
elif enablement == "enable":
|
|
||||||
self.dict["enabled"] = True
|
|
||||||
self.fhdhr.db.set_channel_value(self.dict["fhdhr_id"], "info", self.dict)
|
|
||||||
|
|
||||||
def lineup_dict(self):
|
def lineup_dict(self):
|
||||||
return {
|
return {
|
||||||
|
|||||||
@ -33,14 +33,23 @@ class Channels():
|
|||||||
response=channels_info_json,
|
response=channels_info_json,
|
||||||
mimetype='application/json')
|
mimetype='application/json')
|
||||||
|
|
||||||
elif method in ["enable", "disable"]:
|
elif method == "update":
|
||||||
channel = request.args.get('channel', default=None, type=str)
|
channel_id = request.form.get('id', None)
|
||||||
if not channel:
|
updatedict = {}
|
||||||
if redirect_url:
|
for key in list(request.form.keys()):
|
||||||
return redirect(redirect_url + "?retmessage=" + urllib.parse.quote("%s Failed" % method))
|
if key != "id":
|
||||||
else:
|
if key in ["name", "callsign"]:
|
||||||
return "%s Falied" % method
|
updatedict[key] = str(request.form.get(key))
|
||||||
self.fhdhr.device.channels.set_channel_status("number", channel, method)
|
elif key in ["number"]:
|
||||||
|
updatedict[key] = float(request.form.get(key))
|
||||||
|
elif key in ["enabled"]:
|
||||||
|
confvalue = request.form.get(key)
|
||||||
|
if str(confvalue).lower() in ["false"]:
|
||||||
|
confvalue = False
|
||||||
|
elif str(confvalue).lower() in ["true"]:
|
||||||
|
confvalue = True
|
||||||
|
updatedict[key] = confvalue
|
||||||
|
self.fhdhr.device.channels.set_channel_status("id", channel_id, updatedict)
|
||||||
|
|
||||||
elif method == "scan":
|
elif method == "scan":
|
||||||
self.fhdhr.device.station_scan.scan()
|
self.fhdhr.device.station_scan.scan()
|
||||||
|
|||||||
@ -41,11 +41,11 @@ class OriginChannels():
|
|||||||
return channel_list
|
return channel_list
|
||||||
|
|
||||||
def get_channel_stream(self, chandict):
|
def get_channel_stream(self, chandict):
|
||||||
streamurl = ('%s%s:%s/live?channel=%s&client=%s' %
|
streamurl = ('%s%s:%s/live?channel_id=%s&client=%s' %
|
||||||
("https://" if self.fhdhr.config.dict["origin"]["ssl"] else "http://",
|
("https://" if self.fhdhr.config.dict["origin"]["ssl"] else "http://",
|
||||||
self.fhdhr.config.dict["origin"]["address"],
|
self.fhdhr.config.dict["origin"]["address"],
|
||||||
str(self.fhdhr.config.dict["origin"]["port"]),
|
str(self.fhdhr.config.dict["origin"]["port"]),
|
||||||
str(chandict["number"]),
|
str(chandict["origin_id"]),
|
||||||
str(chandict["number"]),
|
"fhdhr_" + str(chandict["origin_number"]),
|
||||||
))
|
))
|
||||||
return streamurl
|
return streamurl
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user