From 1eee01d2e6361e0e8a78eb909647cc0806f1f67c Mon Sep 17 00:00:00 2001 From: westsurname <155189104+westsurname@users.noreply.github.com> Date: Sun, 21 Jul 2024 22:56:59 +0000 Subject: [PATCH] misc fixes --- docker-compose.yml | 12 ++++++------ plex_authentication.py | 10 ++++++++-- plex_request.py | 1 + 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 2ad737f..2b07af8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -160,13 +160,13 @@ services: volumes: - ./shared/tokens.json:/app/shared/tokens.json ports: - - 8000:8000 + - 8010:8000 env_file: - .env - environment: - - SERVER_DOMAIN=${SERVER_DOMAIN}:8000 + # environment: + # - SERVER_DOMAIN=${SERVER_DOMAIN}:8010 restart: unless-stopped - profiles: [plex_authentication, all] + profiles: [plex_authentication, watchlist, plex_request, all] plex_request: build: @@ -178,7 +178,7 @@ services: volumes: - ./shared/tokens.json:/app/shared/tokens.json ports: - - 8001:8000 + - 8011:8000 env_file: - .env restart: unless-stopped @@ -194,7 +194,7 @@ services: volumes: - ${PLEX_REQUEST_SSL_PATH:-/dev/null}:${PLEX_REQUEST_SSL_PATH:-/dev/null}:ro ports: - - 8002:8000 + - 8012:8000 env_file: - .env restart: unless-stopped diff --git a/plex_authentication.py b/plex_authentication.py index a81b309..fa9971d 100644 --- a/plex_authentication.py +++ b/plex_authentication.py @@ -7,13 +7,14 @@ from shared.plex import getServerToken from werkzeug.serving import run_simple from werkzeug.middleware.dispatcher import DispatcherMiddleware +from werkzeug.middleware.proxy_fix import ProxyFix host = server['host'] # instantiate the app app = Flask(__name__) app.config.from_object(__name__) -app.config['SERVER_NAME'] = f"{host}" +# app.config['SERVER_NAME'] = f"{host}" @app.route('/', methods=['GET']) @@ -42,9 +43,13 @@ def setupComplete(pin): with open(tokensFilename, 'r+') as tokensFile: tokens = json.load(tokensFile) - token = tokens.get(user['id'], { 'etag': '' }) + token = tokens.get(userId, { 'etag': '' }) token['token'] = authToken token['serverToken'] = serverToken + + if serverToken == authToken: + token['owner'] = True + tokens[userId] = token tokensFile.seek(0) json.dump(tokens, tokensFile) @@ -55,6 +60,7 @@ def setupComplete(pin): return jsonify('There was an error, please try again.') # app.wsgi_app = DispatcherMiddleware(run_simple, {'/plexAuthentication': app.wsgi_app}) +app.wsgi_app = ProxyFix(app.wsgi_app, x_for=1, x_proto=1, x_host=1, x_port=1, x_prefix=1) if __name__ == '__main__': app.run('127.0.0.1', 12598) \ No newline at end of file diff --git a/plex_request.py b/plex_request.py index dea074d..d89a56c 100644 --- a/plex_request.py +++ b/plex_request.py @@ -140,6 +140,7 @@ def requestRatingKey(mediaType, mediaTypeNum, ratingKey, season=None): # return response # response = jsonify(json.loads(blankMediaContainer)) + response = Response('', status=204) response.headers.add('Access-Control-Allow-Origin', 'https://app.plex.tv') return response