Compare commits
No commits in common. "7db9bc326af88fee1d41a8c1729d628dd771719d" and "bdd2116c24f3d94ab89ff86bdfe794950b4885e2" have entirely different histories.
7db9bc326a
...
bdd2116c24
@ -10,7 +10,6 @@ from .m3u import M3U
|
|||||||
from .epg import EPG
|
from .epg import EPG
|
||||||
from .tuners import Tuners
|
from .tuners import Tuners
|
||||||
from .debug import Debug_JSON
|
from .debug import Debug_JSON
|
||||||
from .tools import API_Tools
|
|
||||||
|
|
||||||
from .images import Images
|
from .images import Images
|
||||||
|
|
||||||
@ -31,6 +30,5 @@ class fHDHR_API():
|
|||||||
self.epg = EPG(fhdhr)
|
self.epg = EPG(fhdhr)
|
||||||
self.tuners = Tuners(fhdhr)
|
self.tuners = Tuners(fhdhr)
|
||||||
self.debug = Debug_JSON(fhdhr)
|
self.debug = Debug_JSON(fhdhr)
|
||||||
self.tools = API_Tools(fhdhr)
|
|
||||||
|
|
||||||
self.images = Images(fhdhr)
|
self.images = Images(fhdhr)
|
||||||
|
|||||||
@ -1,47 +0,0 @@
|
|||||||
from flask import Response, request, redirect
|
|
||||||
import urllib.parse
|
|
||||||
import json
|
|
||||||
|
|
||||||
|
|
||||||
class API_Tools():
|
|
||||||
endpoints = ["/api/tools"]
|
|
||||||
endpoint_name = "api_tools"
|
|
||||||
endpoint_methods = ["GET", "POST"]
|
|
||||||
|
|
||||||
def __init__(self, fhdhr):
|
|
||||||
self.fhdhr = fhdhr
|
|
||||||
|
|
||||||
def __call__(self, *args):
|
|
||||||
return self.get(*args)
|
|
||||||
|
|
||||||
def get(self, *args):
|
|
||||||
|
|
||||||
method = request.args.get('method', default="get", type=str)
|
|
||||||
|
|
||||||
redirect_url = request.args.get('redirect', default=None, type=str)
|
|
||||||
|
|
||||||
if method == "prettyjson":
|
|
||||||
|
|
||||||
dirty_json_url = request.form.get('url', None)
|
|
||||||
|
|
||||||
try:
|
|
||||||
json_url_req = self.fhdhr.web.session.get(dirty_json_url)
|
|
||||||
json_url_req.raise_for_status()
|
|
||||||
json_resp = json_url_req.json()
|
|
||||||
except self.fhdhr.web.exceptions.HTTPError as err:
|
|
||||||
self.fhdhr.logger.error('Error while getting stations: %s' % err)
|
|
||||||
json_resp = {"error": 'Error while getting stations: %s' % err}
|
|
||||||
|
|
||||||
return_json = json.dumps(json_resp, indent=4)
|
|
||||||
|
|
||||||
return Response(status=200,
|
|
||||||
response=return_json,
|
|
||||||
mimetype='application/json')
|
|
||||||
|
|
||||||
else:
|
|
||||||
return "%s Invalid Method" % method
|
|
||||||
|
|
||||||
if redirect_url:
|
|
||||||
return redirect(redirect_url + "?retmessage=" + urllib.parse.quote("%s Success" % method))
|
|
||||||
else:
|
|
||||||
return "%s Success" % method
|
|
||||||
@ -10,7 +10,6 @@ from .version_html import Version_HTML
|
|||||||
from .diagnostics_html import Diagnostics_HTML
|
from .diagnostics_html import Diagnostics_HTML
|
||||||
from .settings_html import Settings_HTML
|
from .settings_html import Settings_HTML
|
||||||
from .channels_editor import Channels_Editor_HTML
|
from .channels_editor import Channels_Editor_HTML
|
||||||
from .tools import Tools_HTML
|
|
||||||
|
|
||||||
|
|
||||||
class fHDHR_Pages():
|
class fHDHR_Pages():
|
||||||
@ -28,4 +27,3 @@ class fHDHR_Pages():
|
|||||||
self.version_html = Version_HTML(fhdhr)
|
self.version_html = Version_HTML(fhdhr)
|
||||||
self.diagnostics_html = Diagnostics_HTML(fhdhr)
|
self.diagnostics_html = Diagnostics_HTML(fhdhr)
|
||||||
self.settings_html = Settings_HTML(fhdhr)
|
self.settings_html = Settings_HTML(fhdhr)
|
||||||
self.tools = Tools_HTML(fhdhr)
|
|
||||||
|
|||||||
@ -1,16 +0,0 @@
|
|||||||
from flask import request, render_template
|
|
||||||
|
|
||||||
|
|
||||||
class Tools_HTML():
|
|
||||||
endpoints = ["/tools", "/tools.html"]
|
|
||||||
endpoint_name = "tools_html"
|
|
||||||
|
|
||||||
def __init__(self, fhdhr):
|
|
||||||
self.fhdhr = fhdhr
|
|
||||||
|
|
||||||
def __call__(self, *args):
|
|
||||||
return self.get(*args)
|
|
||||||
|
|
||||||
def get(self, *args):
|
|
||||||
|
|
||||||
return render_template('tools.html', request=request, fhdhr=self.fhdhr)
|
|
||||||
@ -1,12 +0,0 @@
|
|||||||
{% extends "base.html" %}
|
|
||||||
|
|
||||||
{% block content %}
|
|
||||||
|
|
||||||
<h4 style="text-align: center;">{{ fhdhr.config.dict["fhdhr"]["friendlyname"] }} Tools</h4>
|
|
||||||
|
|
||||||
<form method="post" action="/api/tools?method=prettyjson&redirect=%2Ftools">
|
|
||||||
<input type="hidden" name="url" value="">
|
|
||||||
<a data-th="Convert"><input type="submit" value="Convert"></a>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
{% endblock %}
|
|
||||||
Loading…
Reference in New Issue
Block a user