mirror of
https://gitea.phreedom.club/localhost_frssoft/funkwlmpv
synced 2024-11-22 22:59:19 +02:00
Add make loginning on instances (manually)
This commit is contained in:
parent
5184f81277
commit
a1765500ed
|
@ -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
|
from src.fw_radios import list_radios
|
||||||
import json, sys
|
import json, sys
|
||||||
from loguru import logger
|
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_api')
|
||||||
logger.add(sys.stderr, filter='src.fw_radios')
|
logger.add(sys.stderr, filter='src.fw_radios')
|
||||||
while True:
|
while True:
|
||||||
menu = ('Radios', 'Switch instance' )
|
menu =['Radios', 'Switch instance']
|
||||||
|
if not s.headers.get('Authorization'):
|
||||||
|
menu.append('Sign in')
|
||||||
ids = fzf.prompt(menu)
|
ids = fzf.prompt(menu)
|
||||||
|
|
||||||
selected = ids[0]
|
selected = ids[0]
|
||||||
|
@ -23,6 +25,26 @@ def main():
|
||||||
list_instances = conf.get('public_list_instances')
|
list_instances = conf.get('public_list_instances')
|
||||||
instance = fzf.prompt(list_instances, '--header \'Select instance\'')[0]
|
instance = fzf.prompt(list_instances, '--header \'Select instance\'')[0]
|
||||||
select_instance(instance)
|
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__':
|
if __name__ == '__main__':
|
||||||
|
|
|
@ -22,6 +22,8 @@ else:
|
||||||
def select_instance(new_instance=None):
|
def select_instance(new_instance=None):
|
||||||
global instance
|
global instance
|
||||||
instance = new_instance
|
instance = new_instance
|
||||||
|
with open('.auth.json', 'rt') as f:
|
||||||
|
auth = json.loads(f.read())
|
||||||
new_token = auth.get(instance)
|
new_token = auth.get(instance)
|
||||||
s.headers.update({"Authorization": None})
|
s.headers.update({"Authorization": None})
|
||||||
player.http_header_fields = []
|
player.http_header_fields = []
|
||||||
|
|
Loading…
Reference in New Issue