mirror of
https://github.com/fHDHR/fHDHR_NextPVR.git
synced 2025-12-06 09:36:59 -05:00
Compare commits
No commits in common. "7348101eea1fe3e0fb7ea155752486f622804a74" and "698e407c383d43824954857cf8062bd021aa73b7" have entirely different histories.
7348101eea
...
698e407c38
@ -7,7 +7,6 @@ from .settings import Settings
|
||||
from .channels import Channels
|
||||
from .xmltv import xmlTV
|
||||
from .m3u import M3U
|
||||
from .w3u import W3U
|
||||
from .epg import EPG
|
||||
from .tuners import Tuners
|
||||
from .debug import Debug_JSON
|
||||
@ -31,7 +30,6 @@ class fHDHR_API():
|
||||
self.channels = Channels(fhdhr)
|
||||
self.xmltv = xmlTV(fhdhr)
|
||||
self.m3u = M3U(fhdhr)
|
||||
self.w3u = W3U(fhdhr)
|
||||
self.epg = EPG(fhdhr)
|
||||
self.tuners = Tuners(fhdhr)
|
||||
self.debug = Debug_JSON(fhdhr)
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
from flask import Response, request, redirect, abort, stream_with_context, session
|
||||
import urllib.parse
|
||||
import uuid
|
||||
import json
|
||||
|
||||
from fHDHR.exceptions import TunerError
|
||||
@ -74,7 +75,7 @@ class Tuners():
|
||||
"transcode": transcode,
|
||||
"accessed": accessed_url,
|
||||
"client": client_address,
|
||||
"client_id": session["session_id"]
|
||||
"client_id": "%s_%s" % (client_address, uuid.uuid4())
|
||||
}
|
||||
|
||||
try:
|
||||
|
||||
@ -1,89 +0,0 @@
|
||||
from flask import Response, request, redirect
|
||||
import urllib.parse
|
||||
import json
|
||||
|
||||
from fHDHR.tools import channel_sort
|
||||
|
||||
|
||||
class W3U():
|
||||
endpoints = ["/api/w3u"]
|
||||
endpoint_name = "api_w3u"
|
||||
endpoint_methods = ["GET", "POST"]
|
||||
|
||||
def __init__(self, fhdhr):
|
||||
self.fhdhr = fhdhr
|
||||
|
||||
def __call__(self, *args):
|
||||
return self.get(*args)
|
||||
|
||||
def get(self, *args):
|
||||
|
||||
base_url = request.url_root[:-1]
|
||||
|
||||
method = request.args.get('method', default="get", type=str)
|
||||
channel = request.args.get('channel', default="all", type=str)
|
||||
redirect_url = request.args.get('redirect', default=None, type=str)
|
||||
|
||||
if method == "get":
|
||||
|
||||
channel_info_m3u = {
|
||||
"name": self.fhdhr.config.dict["fhdhr"]["friendlyname"],
|
||||
"image": '%s/favicon.ico' % base_url,
|
||||
"epg": '%s/api/xmltv' % base_url,
|
||||
"stations": []
|
||||
}
|
||||
|
||||
channel_items = []
|
||||
|
||||
if channel == "all":
|
||||
fileName = "channels.w3u"
|
||||
for fhdhr_id in [x["id"] for x in self.fhdhr.device.channels.get_channels()]:
|
||||
channel_obj = self.fhdhr.device.channels.list[fhdhr_id]
|
||||
if channel_obj.enabled:
|
||||
channel_items.append(channel_obj)
|
||||
elif str(channel) in [str(x) for x in self.fhdhr.device.channels.get_channel_list("number")]:
|
||||
channel_obj = self.fhdhr.device.channels.get_channel_obj("number", channel)
|
||||
fileName = "%s.w3u" % channel_obj.number
|
||||
if channel_obj.enabled:
|
||||
channel_items.append(channel_obj)
|
||||
else:
|
||||
return "Channel Disabled"
|
||||
else:
|
||||
return "Invalid Channel"
|
||||
|
||||
channels_info = {}
|
||||
|
||||
for channel_obj in channel_items:
|
||||
|
||||
if self.fhdhr.config.dict["epg"]["images"] == "proxy" or not channel_obj.thumbnail:
|
||||
logourl = ('%s/api/images?method=get&type=channel&id=%s' %
|
||||
(base_url, str(channel_obj.dict['origin_id'])))
|
||||
else:
|
||||
logourl = channel_obj.thumbnail
|
||||
|
||||
channels_info[channel_obj.number] = {
|
||||
"name": str(channel_obj.dict['name']),
|
||||
"url": "%s%s" % (base_url, channel_obj.api_stream_url),
|
||||
"epgId": str(channel_obj.dict['origin_id']),
|
||||
"image": logourl,
|
||||
}
|
||||
|
||||
# Sort the channels
|
||||
sorted_channel_list = channel_sort(list(channels_info.keys()))
|
||||
for channel in sorted_channel_list:
|
||||
channel_info_m3u["stations"].append(channels_info[channel])
|
||||
|
||||
channels_info_json = json.dumps(channel_info_m3u, indent=4)
|
||||
|
||||
resp = Response(status=200, response=channels_info_json, mimetype='application/json')
|
||||
resp.headers["content-disposition"] = "attachment; filename=%s" % fileName
|
||||
return resp
|
||||
|
||||
return Response(status=200,
|
||||
response=channels_info_json,
|
||||
mimetype='application/json')
|
||||
|
||||
if redirect_url:
|
||||
return redirect("%s?retmessage=%s" % (redirect_url, urllib.parse.quote("%s Success" % method)))
|
||||
else:
|
||||
return "%s Success" % method
|
||||
@ -28,8 +28,6 @@
|
||||
|
||||
<a class="pull-right" style="padding: 5px;" href="/api/xmltv?method=get&source={{ fhdhr.device.epg.def_method }}">xmltv</a>
|
||||
<a class="pull-right" style="padding: 5px;" href="/api/m3u?method=get&channel=all">m3u</a>
|
||||
<a class="pull-right" style="padding: 5px;" href="/api/w3u?method=get&channel=all">w3u</a>
|
||||
|
||||
<form class="pull-right" style="padding: 5px;" method="post" action="/api/settings?method=update&redirect={{ request.path }}">
|
||||
<input type="hidden" name="config_section" value="web_ui">
|
||||
<input type="hidden" name="config_name" value="access_level">
|
||||
|
||||
Loading…
Reference in New Issue
Block a user