mirror of
http://gitea.phreedom.club/localhost_frssoft/funkwlmpv
synced 2024-11-27 04:01:29 +00:00
Compare commits
No commits in common. "bd095da8ac00f57a37cbf7a956c65faa6345985c" and "c4aaab97bf5c601d36687e82e556fc3386a27c8f" have entirely different histories.
bd095da8ac
...
c4aaab97bf
|
@ -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_radios import list_radios
|
||||||
from src.fw_artists import list_artists
|
from src.fw_artists import list_artists
|
||||||
from src.fw_albums import list_albums
|
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
|
from src.fw_fav_tracks import list_favorites_tracks
|
||||||
import src.settings as settings
|
import src.settings as settings
|
||||||
import src.mpv_control
|
import src.mpv_control
|
||||||
import json, sys, time
|
import json, sys
|
||||||
from shlex import quote
|
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
from pyfzf.pyfzf import FzfPrompt
|
from pyfzf.pyfzf import FzfPrompt
|
||||||
|
|
||||||
fzf = FzfPrompt()
|
fzf = FzfPrompt()
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
||||||
while True:
|
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',
|
menu = ['Radios',
|
||||||
'Artists',
|
'Artists',
|
||||||
'Albums',
|
'Albums',
|
||||||
|
@ -43,11 +27,9 @@ def main():
|
||||||
'Switch instance']
|
'Switch instance']
|
||||||
if not s.headers.get('Authorization'):
|
if not s.headers.get('Authorization'):
|
||||||
menu.append('Sign in')
|
menu.append('Sign in')
|
||||||
if support_message != '':
|
|
||||||
menu.append('Donate')
|
|
||||||
if not src.mpv_control.player.core_idle:
|
if not src.mpv_control.player.core_idle:
|
||||||
menu.insert(0, 'Player')
|
menu.insert(0, 'Player')
|
||||||
ids = fzf.prompt(menu, f"--header={main_menu_header}")
|
ids = fzf.prompt(menu)
|
||||||
|
|
||||||
selected = ids[0]
|
selected = ids[0]
|
||||||
if selected == 'Radios':
|
if selected == 'Radios':
|
||||||
|
@ -74,11 +56,8 @@ def main():
|
||||||
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())
|
||||||
public_server_list_instances = settings.get_new_funkwhale_servers()
|
list_instances = conf.get('public_list_instances') + settings.get_new_funkwhale_servers()
|
||||||
new_ins_count = len(settings.get_new_funkwhale_servers())
|
instance = fzf.prompt(list_instances, '--header \'Select instance\'')[0]
|
||||||
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]
|
|
||||||
select_instance(instance)
|
select_instance(instance)
|
||||||
if selected == 'Sign in':
|
if selected == 'Sign in':
|
||||||
print(f'''
|
print(f'''
|
||||||
|
@ -99,10 +78,6 @@ Insert token from "Access token" here''')
|
||||||
del f
|
del f
|
||||||
|
|
||||||
select_instance(instance)
|
select_instance(instance)
|
||||||
if selected == 'Donate':
|
|
||||||
print('Support instance message:')
|
|
||||||
print(support_message)
|
|
||||||
input()
|
|
||||||
if selected == 'Player':
|
if selected == 'Player':
|
||||||
src.mpv_control.player_menu(storage=src.mpv_control.player_fw_storage.storage)
|
src.mpv_control.player_menu(storage=src.mpv_control.player_fw_storage.storage)
|
||||||
|
|
||||||
|
|
|
@ -60,12 +60,6 @@ def select_instance(new_instance=None):
|
||||||
set_http_header(['Authorization: ' + 'Bearer ' + token])
|
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
|
@logger.catch
|
||||||
def get_audio_file(track_uuid, listen_url=False, download=False,
|
def get_audio_file(track_uuid, listen_url=False, download=False,
|
||||||
transcoding=get_config('enable_server_transcoding'), to='ogg'):
|
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)
|
r = s.get(f'https://{instance}/api/v1/tracks', params=params)
|
||||||
return r.json()
|
return r.json()
|
||||||
|
|
||||||
|
|
||||||
@logger.catch
|
@logger.catch
|
||||||
def get_favorires_tracks(page=None, q=None, scope=None, include_channels=None, pg=None):
|
def get_favorires_tracks(page=None, q=None, scope=None, include_channels=None, pg=None):
|
||||||
'''This function get favorites tracks (not only for user)'''
|
'''This function get favorites tracks (not only for user)'''
|
||||||
|
|
Loading…
Reference in a new issue