From e3a264f24e3e9b06b08f300ffe8c1e8f02811caa Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Sun, 20 Dec 2020 11:22:46 -0500 Subject: [PATCH] Use session to store the DeviceAuth --- fHDHR_web/__init__.py | 5 +++++ fHDHR_web/api/xmltv.py | 5 ++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/fHDHR_web/__init__.py b/fHDHR_web/__init__.py index ef80fff..3749ac7 100644 --- a/fHDHR_web/__init__.py +++ b/fHDHR_web/__init__.py @@ -71,12 +71,17 @@ class fHDHR_HTTP_Server(): if session["is_plexmediaserver"]: self.fhdhr.logger.debug("Client is a Plex Media Server.") + session["deviceauth"] = self.detect_plexmediaserver(request) + self.fhdhr.logger.debug("Client %s requested %s Opening" % (request.method, request.path)) def after_request(self, response): self.fhdhr.logger.debug("Client %s requested %s Closing" % (request.method, request.path)) return response + def detect_deviceauth(self, request): + return request.args.get('DeviceAuth', default=None, type=str) + def detect_mobile(self, request): user_agent = request.headers.get('User-Agent') phones = ["iphone", "android", "blackberry"] diff --git a/fHDHR_web/api/xmltv.py b/fHDHR_web/api/xmltv.py index f13b6b0..200a435 100644 --- a/fHDHR_web/api/xmltv.py +++ b/fHDHR_web/api/xmltv.py @@ -1,4 +1,4 @@ -from flask import Response, request, redirect +from flask import Response, request, redirect, session import xml.etree.ElementTree from io import BytesIO import urllib.parse @@ -30,8 +30,7 @@ class xmlTV(): def get(self, *args): if self.fhdhr.config.dict["fhdhr"]["require_auth"]: - DeviceAuth = request.args.get('DeviceAuth', default=None, type=str) - if DeviceAuth != self.fhdhr.config.dict["fhdhr"]["device_auth"]: + if session["deviceauth"] != self.fhdhr.config.dict["fhdhr"]["device_auth"]: return "not subscribed" base_url = request.url_root[:-1]