mirror of
http://gitea.phreedom.club/localhost_frssoft/funkwlmpv
synced 2024-11-21 18:41:28 +00:00
Track info output refactor
This commit is contained in:
parent
3327ec41c6
commit
abf0b7f4c0
|
@ -1,7 +1,7 @@
|
|||
from src.fw_api import current_instance, get_radios, post_radio_session, get_track_radio, list_libraries, favorite_track, get_audio_file, hide_content
|
||||
from src.fw_libraries import libraries
|
||||
from src.fw_tags import list_tags
|
||||
from src.utils import download_track
|
||||
from src.utils import download_track, track_info_output
|
||||
from src.mpv_control import player, track_url_to_uuid, player_fw_storage
|
||||
from src.settings import get_config
|
||||
from pyfzf.pyfzf import FzfPrompt
|
||||
|
@ -148,15 +148,7 @@ def radio_load(id_radio=None, type_radio='custom', name=None, related_object=Non
|
|||
name_downloaded = download_track(player.stream_open_filename)
|
||||
elif select == 'Info':
|
||||
track = player_fw_storage.storage.get(track_url_to_uuid())
|
||||
for i in ('title', 'fid', 'license', 'album', 'artist'):
|
||||
if i in ('album', 'artist'):
|
||||
name_aa = track.get(i).get('name')
|
||||
if not name_aa:
|
||||
name_aa = track[i]['title']
|
||||
print(i + ': ' + name_aa)
|
||||
key = track.get(i)
|
||||
if key and isinstance(key, str):
|
||||
print(i + ': ' + key)
|
||||
track_info_output(track)
|
||||
print('Direct link: ' + player.stream_open_filename)
|
||||
input()
|
||||
elif select == 'Like':
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import src.fw_api
|
||||
from src.utils import download_track, print_there
|
||||
from src.utils import download_track, print_there, track_info_output
|
||||
from src.settings import get_config
|
||||
from loguru import logger
|
||||
from pyfzf.pyfzf import FzfPrompt
|
||||
|
@ -147,15 +147,7 @@ def player_menu(header='', storage={}):
|
|||
name_downloaded = download_track(player.stream_open_filename)
|
||||
elif select == 'Info':
|
||||
track = player_fw_storage.storage.get(track_url_to_uuid())
|
||||
for i in track.keys():
|
||||
if i in ('album', 'artist'):
|
||||
name_aa = track.get(i).get('name')
|
||||
if not name_aa:
|
||||
name_aa = track.get(i).get('title')
|
||||
print(i + ': ' + name_aa)
|
||||
key = track.get(i)
|
||||
if key and isinstance(key, str):
|
||||
print(i + ': ' + key)
|
||||
track_info_output(track)
|
||||
print('Direct link: ' + player.stream_open_filename)
|
||||
input()
|
||||
elif select == 'Like':
|
||||
|
|
14
src/utils.py
14
src/utils.py
|
@ -51,6 +51,18 @@ def copy_from_cache(url_file):
|
|||
|
||||
|
||||
def print_there(x, y, text):
|
||||
'''Print at position x, y caption in terminal (? Linux only)'''
|
||||
'''Print at position x, y caption in terminal (Linux only)'''
|
||||
sys.stdout.write("\x1b7\x1b[%d;%df%s\x1b8" % (x, y, text))
|
||||
sys.stdout.flush()
|
||||
|
||||
|
||||
def track_info_output(track):
|
||||
for k, v in track.items():
|
||||
if k not in ('cover', 'uploads', 'listen_url', 'mbid', 'id', 'is_playable') and v is not None and v != []:
|
||||
if isinstance(v, dict):
|
||||
for i in ('title', 'name', 'fid'):
|
||||
if v.get(i):
|
||||
val_override = v.get(i)
|
||||
print(f'{k}: {val_override}')
|
||||
else:
|
||||
print(f'{k}: {v}')
|
||||
|
|
Loading…
Reference in a new issue