mirror of
https://gitea.phreedom.club/localhost_frssoft/funkwlmpv
synced 2024-11-22 22:59:19 +02:00
Instance title and donate button when starting
This commit is contained in:
parent
c4aaab97bf
commit
67aa2257cb
|
@ -1,4 +1,4 @@
|
||||||
from src.fw_api import s, select_instance, instance, federate_search_by_url
|
from src.fw_api import s, select_instance, instance, federate_search_by_url, get_instance_settings
|
||||||
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,14 +8,30 @@ 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
|
import json, sys, time
|
||||||
|
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',
|
||||||
|
@ -27,9 +43,11 @@ 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)
|
ids = fzf.prompt(menu, f"--header={main_menu_header}")
|
||||||
|
|
||||||
selected = ids[0]
|
selected = ids[0]
|
||||||
if selected == 'Radios':
|
if selected == 'Radios':
|
||||||
|
@ -78,6 +96,10 @@ 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,6 +60,12 @@ 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'):
|
||||||
|
@ -93,6 +99,7 @@ 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 New Issue