1
0
mirror of https://github.com/fHDHR/fHDHR_NextPVR.git synced 2025-12-06 12:26:57 -05:00
fHDHR_NextPVR/fHDHR_web/rmg/devices_devicekey_scanners.py
2020-12-08 09:27:51 -05:00

49 lines
1.7 KiB
Python

from flask import Response, request
from io import BytesIO
import xml.etree.ElementTree
from fHDHR.tools import sub_el
class RMG_Devices_DeviceKey_Scanners():
endpoints = ["/devices/<devicekey>/scanners", "/rmg/devices/<devicekey>/scanners"]
endpoint_name = "rmg_devices_devicekey_scanners"
endpoint_methods = ["GET"]
def __init__(self, fhdhr):
self.fhdhr = fhdhr
def __call__(self, devicekey, *args):
return self.get(devicekey, *args)
def get(self, devicekey, *args):
"""ascertain which type of scanners are supported."""
method = request.args.get('type', default="0", type=str)
# 0 (atsc), 1 (cqam), 2 (dvb-s), 3 (iptv), 4 (virtual), 5 (dvb-t), 6 (dvb-c), 7 (isdbt)
out = xml.etree.ElementTree.Element('MediaContainer')
if devicekey == self.fhdhr.config.dict["main"]["uuid"]:
if method == "0":
out.set('size', "1")
out.set('simultaneousScanners', "1")
scanner_out = sub_el(out, 'Scanner',
type="atsc",
# TODO country
)
sub_el(scanner_out, 'Setting',
id="provider",
type="text",
enumValues=self.fhdhr.config.dict["main"]["servicename"]
)
fakefile = BytesIO()
fakefile.write(b'<?xml version="1.0" encoding="UTF-8"?>\n')
fakefile.write(xml.etree.ElementTree.tostring(out, encoding='UTF-8'))
device_xml = fakefile.getvalue()
return Response(status=200,
response=device_xml,
mimetype='application/xml')