mirror of
https://gitea.phreedom.club/localhost_frssoft/funkwlmpv
synced 2024-12-23 12:43:33 +02:00
Security fix: correct update header; Added some types radios
This commit is contained in:
parent
b0d4d3976e
commit
ae1cba2e98
2 changed files with 18 additions and 10 deletions
|
@ -10,9 +10,9 @@ instance = 'fw.ponychord.rocks'
|
|||
token = auth.get(instance)
|
||||
|
||||
if token:
|
||||
s.headers.update = {
|
||||
s.headers.update({
|
||||
"Authorization": "Bearer " + token
|
||||
}
|
||||
})
|
||||
player.http_header_fields = ['Authorization: ' + 'Bearer ' + token]
|
||||
else:
|
||||
s.get(f'https://{instance}/') # Get cookies from unauthorized instance for working some functionality (radios)
|
||||
|
@ -23,13 +23,13 @@ def select_instance(new_instance=None):
|
|||
global instance
|
||||
instance = new_instance
|
||||
new_token = auth.get(instance)
|
||||
s.headers.update = {}
|
||||
s.headers.update({"Authorization": None})
|
||||
player.http_header_fields = []
|
||||
if new_token:
|
||||
s.get(f'https://{instance}')
|
||||
s.headers.update = {
|
||||
s.headers.update({
|
||||
"Authorization": "Bearer " + new_token
|
||||
}
|
||||
})
|
||||
player.http_header_fields = ['Authorization: ' + 'Bearer ' + new_token]
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from src.fw_api import get_radios, post_radio_session, get_track_radio, concatinate_endpoint
|
||||
from src.fw_api import s, get_radios, post_radio_session, get_track_radio, concatinate_endpoint
|
||||
from src.utils import download_track
|
||||
from src.mpv_control import player
|
||||
from pyfzf.pyfzf import FzfPrompt
|
||||
|
@ -20,13 +20,21 @@ def list_radios():
|
|||
id_radio = i.get('id')
|
||||
name = i.get('name')
|
||||
view.append(f'{index}.{name}')
|
||||
|
||||
view.append('Favourites')
|
||||
if s.headers.get('Authorization'): # Radios avalaible only for auth user
|
||||
view.append('Favourites')
|
||||
view.append('Less listened')
|
||||
view.append('Random')
|
||||
view.append('Recently Added')
|
||||
|
||||
selected = fzf.prompt(view, f'--header \'Found {count} radios\'')[0].split('.', 1)
|
||||
if 'Favourites' in selected:
|
||||
type_radio = 'favorites'
|
||||
radio_load(id_radio, type_radio)
|
||||
radio_load(id_radio, 'favorites')
|
||||
elif 'Random' in selected:
|
||||
radio_load(id_radio, 'random')
|
||||
elif 'Recently Added' in selected:
|
||||
radio_load(id_radio, 'recently-added')
|
||||
elif 'Less listened' in selected:
|
||||
radio_load(id_radio, 'less-listened')
|
||||
else:
|
||||
id_selected = selected[0]
|
||||
id_radio = results[int(id_selected)].get('id')
|
||||
|
|
Loading…
Reference in a new issue