mirror of
https://gitea.phreedom.club/localhost_frssoft/funkwlmpv
synced 2024-12-22 05:39:48 +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_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_libraries import libraries
|
||||||
from src.fw_tags import list_tags
|
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.mpv_control import player, track_url_to_uuid, player_fw_storage
|
||||||
from src.settings import get_config
|
from src.settings import get_config
|
||||||
from pyfzf.pyfzf import FzfPrompt
|
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)
|
name_downloaded = download_track(player.stream_open_filename)
|
||||||
elif select == 'Info':
|
elif select == 'Info':
|
||||||
track = player_fw_storage.storage.get(track_url_to_uuid())
|
track = player_fw_storage.storage.get(track_url_to_uuid())
|
||||||
for i in ('title', 'fid', 'license', 'album', 'artist'):
|
track_info_output(track)
|
||||||
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)
|
|
||||||
print('Direct link: ' + player.stream_open_filename)
|
print('Direct link: ' + player.stream_open_filename)
|
||||||
input()
|
input()
|
||||||
elif select == 'Like':
|
elif select == 'Like':
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import src.fw_api
|
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 src.settings import get_config
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
from pyfzf.pyfzf import FzfPrompt
|
from pyfzf.pyfzf import FzfPrompt
|
||||||
@ -147,15 +147,7 @@ def player_menu(header='', storage={}):
|
|||||||
name_downloaded = download_track(player.stream_open_filename)
|
name_downloaded = download_track(player.stream_open_filename)
|
||||||
elif select == 'Info':
|
elif select == 'Info':
|
||||||
track = player_fw_storage.storage.get(track_url_to_uuid())
|
track = player_fw_storage.storage.get(track_url_to_uuid())
|
||||||
for i in track.keys():
|
track_info_output(track)
|
||||||
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)
|
|
||||||
print('Direct link: ' + player.stream_open_filename)
|
print('Direct link: ' + player.stream_open_filename)
|
||||||
input()
|
input()
|
||||||
elif select == 'Like':
|
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):
|
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.write("\x1b7\x1b[%d;%df%s\x1b8" % (x, y, text))
|
||||||
sys.stdout.flush()
|
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 New Issue
Block a user