From 10ccbecd9e70ec057fb85bb4c6f76b7ee789a78c Mon Sep 17 00:00:00 2001 From: localhost_frssoft Date: Mon, 2 Jan 2023 18:43:18 +0300 Subject: [PATCH] Fix header and add brotli, deflate --- README.md | 1 + src/fw_api.py | 15 ++++----------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index c12513a..d973200 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ Dependencies: Python dependencies: ```pip install -r requirements.txt``` +Optional: brotli Also, tnx Inex for his FunkWhale instance (set by default instance) diff --git a/src/fw_api.py b/src/fw_api.py index 6a16bf3..ade8592 100644 --- a/src/fw_api.py +++ b/src/fw_api.py @@ -29,6 +29,7 @@ else: class current_instance: s = requests.Session() + s.headers.update({"Accept-encoding": 'gzip, br, deflate'}) instance = get_config('instance') token = auth.get(instance) listen_token = None @@ -40,25 +41,17 @@ class current_instance: with open(auth_file, 'rt') as f: auth = json.loads(f.read()) new_token = auth.get(current_instance.instance) - current_instance.s.headers.update({"Authorization": None, - "Accept-encoding": 'gzip'}) + current_instance.s.headers.update({"Authorization": None}) current_instance.token = new_token current_instance.listen_token = None if new_token: s.get(f'https://{current_instance.instance}') - s.headers.update({ - "Authorization": "Bearer " + new_token, - "Accept-encoding": 'gzip' - }) + s.headers.update({"Authorization": "Bearer " + new_token}) if current_instance.token: - current_instance.s.headers.update({ - "Authorization": "Bearer " + current_instance.token, - "Accept-encoding": 'gzip' - }) + current_instance.s.headers.update({"Authorization": "Bearer " + current_instance.token}) else: - current_instance.s.headers.update({"Accept-encoding": 'gzip'}) # Get cookies from unauthorized instance for working some functionality (radios) current_instance.s.get(f'https://{current_instance.instance}/')