Compare commits

..

No commits in common. "bd095da8ac00f57a37cbf7a956c65faa6345985c" and "c4aaab97bf5c601d36687e82e556fc3386a27c8f" have entirely different histories.

2 changed files with 5 additions and 37 deletions

View file

@ -1,4 +1,4 @@
from src.fw_api import s, select_instance, instance, federate_search_by_url, get_instance_settings
from src.fw_api import s, select_instance, instance, federate_search_by_url
from src.fw_radios import list_radios
from src.fw_artists import list_artists
from src.fw_albums import list_albums
@ -8,30 +8,14 @@ from src.fw_playlists import list_playlists
from src.fw_fav_tracks import list_favorites_tracks
import src.settings as settings
import src.mpv_control
import json, sys, time
from shlex import quote
import json, sys
from loguru import logger
from pyfzf.pyfzf import FzfPrompt
fzf = FzfPrompt()
def main():
while True:
support_message = ''
instance_title = ''
try:
ins_settings = get_instance_settings()
for i in ins_settings:
if i.get('name') == 'support_message':
support_message = i.get('value')
if i.get('name') == 'name':
instance_title = i.get('value')
main_menu_header = quote(f'''{instance_title}'''.strip())
except:
time.sleep(1)
main_menu_header = quote(f'''Connection failed'''.strip())
menu = ['Radios',
'Artists',
'Albums',
@ -43,11 +27,9 @@ def main():
'Switch instance']
if not s.headers.get('Authorization'):
menu.append('Sign in')
if support_message != '':
menu.append('Donate')
if not src.mpv_control.player.core_idle:
menu.insert(0, 'Player')
ids = fzf.prompt(menu, f"--header={main_menu_header}")
ids = fzf.prompt(menu)
selected = ids[0]
if selected == 'Radios':
@ -74,11 +56,8 @@ def main():
if selected == 'Switch instance':
with open('config.json', 'rt') as f:
conf = json.loads(f.read())
public_server_list_instances = settings.get_new_funkwhale_servers()
new_ins_count = len(settings.get_new_funkwhale_servers())
list_instances = conf.get('public_list_instances') + public_server_list_instances
instance = fzf.prompt(list_instances,
'--header='+quote(f'Select instance\nServer instances: +{new_ins_count}'))[0]
list_instances = conf.get('public_list_instances') + settings.get_new_funkwhale_servers()
instance = fzf.prompt(list_instances, '--header \'Select instance\'')[0]
select_instance(instance)
if selected == 'Sign in':
print(f'''
@ -99,10 +78,6 @@ Insert token from "Access token" here''')
del f
select_instance(instance)
if selected == 'Donate':
print('Support instance message:')
print(support_message)
input()
if selected == 'Player':
src.mpv_control.player_menu(storage=src.mpv_control.player_fw_storage.storage)

View file

@ -60,12 +60,6 @@ def select_instance(new_instance=None):
set_http_header(['Authorization: ' + 'Bearer ' + token])
@logger.catch
def get_instance_settings():
r = s.get(f'https://{instance}/api/v1/instance/settings')
return r.json()
@logger.catch
def get_audio_file(track_uuid, listen_url=False, download=False,
transcoding=get_config('enable_server_transcoding'), to='ogg'):
@ -99,7 +93,6 @@ def get_tracks(page=None, q=None, artist=None, album=None, favourites=None, incl
r = s.get(f'https://{instance}/api/v1/tracks', params=params)
return r.json()
@logger.catch
def get_favorires_tracks(page=None, q=None, scope=None, include_channels=None, pg=None):
'''This function get favorites tracks (not only for user)'''