Compare commits

..

2 Commits

Author SHA1 Message Date
localhost_frssoft 9ec77975e5 print some long info via less 2023-06-14 01:52:06 +03:00
localhost_frssoft 821769f47b cosmetic fix 2023-06-14 00:59:09 +03:00
2 changed files with 17 additions and 18 deletions

View File

@ -11,8 +11,7 @@ from src.fw_recents import list_fav_or_history
import src.settings as settings import src.settings as settings
import src.mpv_control import src.mpv_control
import json import json
import sys import os
import time
from shlex import quote from shlex import quote
from loguru import logger from loguru import logger
from pyfzf.pyfzf import FzfPrompt from pyfzf.pyfzf import FzfPrompt
@ -90,7 +89,7 @@ def main():
print('Input url:') print('Input url:')
returned_obj = federate_search_by_url(input()) returned_obj = federate_search_by_url(input())
logger.info(str(returned_obj)) logger.info(str(returned_obj))
if selected == 'Switch instance': if selected == 'Switch instance':
with open('config.json', 'rt') as f: with open('config.json', 'rt') as f:
conf = json.loads(f.read()) conf = json.loads(f.read())
@ -104,10 +103,10 @@ def main():
current_instance.select_instance(instance) current_instance.select_instance(instance)
if selected == 'Sign in': if selected == 'Sign in':
print(f''' print(f'''
If You want sign in, please visit: If You want sign in, please visit:
https://{instance}/settings/applications/new https://{instance}/settings/applications/new
And fill Name funkwhale-cli And fill Name funkwhale-cli
Scopes: Read, Write (optional): write:favorites write:listenings write:filters Scopes: Read, Write (optional): write:favorites write:listenings write:filters
Insert token from "Access token" here''') Insert token from "Access token" here''')
register_token = input() register_token = input()
@ -122,21 +121,22 @@ Insert token from "Access token" here''')
current_instance.select_instance(instance) current_instance.select_instance(instance)
if selected == 'Donate': if selected == 'Donate':
print('Support instance message:') os.system(f'less <<EOF\nSupport instance message:\n{support_message}')
print(support_message)
input()
if selected == 'About instance': if selected == 'About instance':
about_instance_info = []
for i in ins_settings: for i in ins_settings:
k, v = i.get('verbose_name'), i.get('value') k, v = i.get('verbose_name'), i.get('value')
print(f'{k}: {v}') about_instance_info.append(f'{k}: {v}')
print('|||||Some stats:') about_instance_info.append('|||||Some stats:')
for k, v in ins_nodeinfo['metadata']['usage'].items(): for k, v in ins_nodeinfo['metadata']['usage'].items():
print(f'{k}: {v}') about_instance_info.append(f'{k}: {v}')
for k, v in ins_nodeinfo['metadata']['library'].items(): for k, v in ins_nodeinfo['metadata']['library'].items():
print(f'{k}: {v}') about_instance_info.append(f'{k}: {v}')
for k, v in ins_nodeinfo['usage'].items(): for k, v in ins_nodeinfo['usage'].items():
print(f'{k}: {v}') about_instance_info.append(f'{k}: {v}')
input() about_instance_info = '\n'.join(about_instance_info)
os.system(f'less <<EOF\n{about_instance_info}')
del about_instance_info
if selected == 'Player': if selected == 'Player':
src.mpv_control.player_menu( src.mpv_control.player_menu(
storage=src.mpv_control.player_fw_storage.storage) storage=src.mpv_control.player_fw_storage.storage)

View File

@ -35,7 +35,6 @@ class current_instance:
token = auth.get(instance) token = auth.get(instance)
listen_token = None listen_token = None
@logger.catch @logger.catch
def select_instance(new_instance=None): def select_instance(new_instance=None):
current_instance.instance = new_instance current_instance.instance = new_instance
@ -55,7 +54,7 @@ if current_instance.token:
else: else:
# Get cookies from unauthorized instance for working some functionality (radios) # Get cookies from unauthorized instance for working some functionality (radios)
current_instance.s.get(f'https://{current_instance.instance}/') current_instance.s.get(f'https://{current_instance.instance}/')
@logger.catch @logger.catch
def get_me(): def get_me():
@ -65,7 +64,7 @@ def get_me():
r = current_instance.s.get(f'https://{current_instance.instance}/api/v1/users/me') r = current_instance.s.get(f'https://{current_instance.instance}/api/v1/users/me')
resp = r.json() resp = r.json()
current_instance.listen_token = resp['tokens']['listen'] current_instance.listen_token = resp['tokens']['listen']
return resp return resp
def get_instance_settings(): def get_instance_settings():
@ -77,7 +76,7 @@ def get_instance_settings():
@logger.catch @logger.catch
def get_audio_file(track_uuid, listen_url=False, download=False, def get_audio_file(track_uuid, listen_url=False, download=False,
external_transcoding=get_config('external_transcoder_http_proxy_path'), external_transcoding=get_config('external_transcoder_http_proxy_path'),
transcoding=get_config('enable_server_transcoding'), to='ogg'): transcoding=get_config('enable_server_transcoding'), to='ogg'):
params = { params = {