1
0
mirror of https://github.com/fHDHR/fHDHR_NextPVR.git synced 2025-12-06 13:36:59 -05:00
fHDHR_NextPVR/fHDHR_web/api/root_url.py
2020-12-08 09:27:51 -05:00

33 lines
937 B
Python

from flask import redirect, request
class Root_URL():
endpoints = ["/"]
endpoint_name = "page_root_html"
endpoint_methods = ["GET", "POST"]
def __init__(self, fhdhr):
self.fhdhr = fhdhr
def __call__(self, *args):
return self.get(*args)
def get(self, *args):
user_agent = request.headers.get('User-Agent')
# Client Devices Discovering Device Information
if not user_agent or str(user_agent).lower().startswith("plexmediaserver"):
# Plex Remote Media Grabber redirect
if self.fhdhr.config.dict["rmg"]["enabled"] and str(user_agent).lower().startswith("plexmediaserver"):
return redirect("/rmg")
# Client Device is looking for HDHR type device
else:
return redirect("/hdhr/device.xml")
# Anything Else is likely a Web Browser
else:
return redirect("/index")