Fix header and add brotli, deflate

This commit is contained in:
localhost_frssoft 2023-01-02 18:43:18 +03:00
parent 1e3972d009
commit 10ccbecd9e
2 changed files with 5 additions and 11 deletions

View File

@ -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)

View File

@ -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}/')