mirror of
https://gitea.phreedom.club/localhost_frssoft/funkwlmpv
synced 2024-12-23 12:43:33 +02:00
Add make loginning on instances (manually)
This commit is contained in:
parent
5184f81277
commit
a1765500ed
2 changed files with 26 additions and 2 deletions
|
@ -1,4 +1,4 @@
|
|||
from src.fw_api import select_instance
|
||||
from src.fw_api import s, select_instance, instance
|
||||
from src.fw_radios import list_radios
|
||||
import json, sys
|
||||
from loguru import logger
|
||||
|
@ -11,7 +11,9 @@ def main():
|
|||
logger.add(sys.stderr, filter='src.fw_api')
|
||||
logger.add(sys.stderr, filter='src.fw_radios')
|
||||
while True:
|
||||
menu = ('Radios', 'Switch instance' )
|
||||
menu =['Radios', 'Switch instance']
|
||||
if not s.headers.get('Authorization'):
|
||||
menu.append('Sign in')
|
||||
ids = fzf.prompt(menu)
|
||||
|
||||
selected = ids[0]
|
||||
|
@ -23,6 +25,26 @@ def main():
|
|||
list_instances = conf.get('public_list_instances')
|
||||
instance = fzf.prompt(list_instances, '--header \'Select instance\'')[0]
|
||||
select_instance(instance)
|
||||
if selected == 'Sign in':
|
||||
print(f'''
|
||||
If You want sign in, please visit:
|
||||
https://{instance}/settings/applications/new
|
||||
And fill Name funkwhale-cli
|
||||
Scopes: mark Read
|
||||
|
||||
Insert token from "Access token" here''')
|
||||
register_token = input()
|
||||
with open('.auth.json', 'rt') as f:
|
||||
tkns = json.loads(f.read())
|
||||
with open('.auth.json', 'wt') as f:
|
||||
tkns[instance] = register_token
|
||||
f.write(json.dumps(tkns))
|
||||
del tkns
|
||||
del register_token
|
||||
del f
|
||||
|
||||
select_instance(instance)
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
@ -22,6 +22,8 @@ else:
|
|||
def select_instance(new_instance=None):
|
||||
global instance
|
||||
instance = new_instance
|
||||
with open('.auth.json', 'rt') as f:
|
||||
auth = json.loads(f.read())
|
||||
new_token = auth.get(instance)
|
||||
s.headers.update({"Authorization": None})
|
||||
player.http_header_fields = []
|
||||
|
|
Loading…
Reference in a new issue