DeltaMikeCharlie
I've thought about that in the past, but creating services etc is more involved than I'd like.
I already have a script I used to populate networks/muxes (because the scan tables suck):
import requests
import xml.etree.ElementTree as ET
import re
import json
TVH = "http://192.168.1.200:9981/api/"
SATS = ET.fromstring(
requests.get(
"https://github.com/morpheus883/enigma2-settings/raw/master/morph883_motor/satellites.xml"
).text
)
POLARIZATION = {"0": "H", "1": "V", "2": "L", "3": "R"}
FEC = {
"0": "AUTO",
"1": "1/2",
"2": "2/3",
"3": "3/4",
"4": "5/6",
"5": "7/8",
"6": "8/9",
"7": "3/5",
"8": "4/5",
"9": "9/10",
"15": "NONE",
}
SYSTEM = {"0": "DVB-S", "1": "DVB-S2"}
MODULATION = {
"0": "AUTO",
"1": "QPSK",
"2": "PSK/8",
"3": "QAM/16",
"4": "16APSK",
"5": "32APSK",
}
PLS_MODE = {"0": "ROOT", "1": "GOLD", "2": "COMBO"}
def get_networks():
return requests.post(TVH + "mpegts/network/grid", data={"limit": 999999999}).json()[
"entries"
]
def get_muxes():
return requests.post(TVH + "mpegts/mux/grid", data={"limit": 999999999}).json()[
"entries"
]
def get_network_id_by_name(networks, name):
for n in networks:
if n["networkname"] == name:
return n["uuid"]
def create_network(name):
data = {
"class": "dvb_network_dvbs",
"conf": json.dumps(
{
"enabled": True,
"networkname": name,
"bouquet": False,
"scanfile": "",
"orbital_pos": name,
"pnetworkname": "",
"nid": 0,
"autodiscovery": 2,
"ignore_chnum": False,
"satip_source": 0,
"charset": "",
"skipinitscan": True,
"idlescan": False,
"sid_chnum": False,
"localtime": 0,
},
),
}
response = requests.post(TVH + "mpegts/network/create", data=data)
return response.json()["uuid"]
def is_network_enabled(networks, uuid):
for n in networks:
if n["uuid"] == uuid:
if n["enabled"]:
return True
else:
return False
# not found means its new and is enabled by default
return True
def get_existing_mux_uuid(muxes, network_id, frequency, polarization):
for mux in muxes:
if (
"delsys" in mux
and mux["delsys"] == "DVB-S"
or "delsys" in mux
and mux["delsys"] == "DVB-S2"
):
if (
mux["network_uuid"] == network_id
and int(mux["frequency"]) == int(frequency)
and mux["polarisation"] == polarization
):
return mux["uuid"]
def update_mux(uuid, tp):
frequency = tp.attrib["frequency"]
symbol_rate = tp.attrib["symbol_rate"]
polarization = POLARIZATION[tp.attrib["polarization"]]
fec_inner = FEC[tp.attrib["fec_inner"]]
system = SYSTEM[tp.attrib["system"]]
modulation = MODULATION[tp.attrib["modulation"]]
try:
is_id = tp.attrib["is_id"]
except:
is_id = -1
try:
pls_mode = PLS_MODE[tp.attrib["pls_mode"]]
except:
pls_mode = "ROOT"
try:
pls_code = tp.attrib["pls_code"]
except:
pls_code = 1
data = {
"node": json.dumps(
{
"delsys": system,
"frequency": frequency,
"symbolrate": symbol_rate,
"polarisation": polarization,
"modulation": modulation,
"fec": fec_inner,
"stream_id": is_id,
"pls_mode": pls_mode,
"pls_code": pls_code,
"uuid": uuid,
}
)
}
requests.post(TVH + "idnode/save", data=data)
def create_mux(network_id, tp):
frequency = tp.attrib["frequency"]
symbol_rate = tp.attrib["symbol_rate"]
polarization = POLARIZATION[tp.attrib["polarization"]]
fec_inner = FEC[tp.attrib["fec_inner"]]
system = SYSTEM[tp.attrib["system"]]
modulation = MODULATION[tp.attrib["modulation"]]
try:
is_id = tp.attrib["is_id"]
except:
is_id = -1
try:
pls_mode = PLS_MODE[tp.attrib["pls_mode"]]
except:
pls_mode = "ROOT"
try:
pls_code = tp.attrib["pls_code"]
except:
pls_code = 1
data = {
"uuid": network_id,
"conf": json.dumps(
{
"enabled": 1,
"epg": 1,
"epg_module_id": "",
"delsys": system,
"frequency": frequency,
"symbolrate": symbol_rate,
"polarisation": polarization,
"modulation": modulation,
"fec": fec_inner,
"scan_state": 0,
"charset": "",
"rolloff": "AUTO",
"pilot": "AUTO",
"dvb_satip_dvbc_freq": 0,
"dvb_satip_dvbt_freq": 0,
"tsid_zero": False,
"pmt_06_ac3": 0,
"eit_tsid_nocheck": False,
"sid_filter": 0,
"stream_id": is_id,
"pls_mode": pls_mode,
"pls_code": pls_code,
}
),
}
response = requests.post(
TVH + "mpegts/network/mux_create",
data=data,
)
return response.json()["uuid"]
networks = get_networks()
muxes = get_muxes()
for sat in SATS.findall("sat"):
# get sat name
sat_name = re.search("\d+\.\d+[e|E|w|W]", sat.attrib["name"])[0]
if len(sat_name.split(".")[0]) < 2:
sat_name = "0" + sat_name
# create network if missing
network_id = get_network_id_by_name(networks, sat_name)
if not network_id:
network_id = create_network(sat_name)
# loop transponders
if is_network_enabled(networks, network_id):
for tp in sat.findall("transponder"):
frequency = tp.attrib["frequency"]
polarization = POLARIZATION[tp.attrib["polarization"]]
existing_mux_uuid = get_existing_mux_uuid(
muxes, network_id, frequency, polarization
)
if existing_mux_uuid:
pass
else:
create_mux(network_id, tp)
I'm sure it isn't perfect, but it worked well enough to get me started.
The reason I asked for this to be added as a feature is because the way I imagined it working was services having additional fields for name and provider overrides. If an override is set and if the service is mapped to a channel, the override names are used.
If I was to attempt just the channel naming part myself, how could I achieve it?
When should the script run?
Is there something I can use to trigger it?
How do I find the channels by namespace/sid/whatever the other numbers are in the lamedb?
There must be some wiggle room when deciding if an orbital position is correct, because some people might refer to a satellite as 0.8 or 1, for example.
I'm assuming renaming the channels and not the services is the best option because otherwise my script will be fighting TVH whenever a scan is done.
Thanks,
Chris