From 4ab9f2db2dedeb62192177552284afee280cb1db Mon Sep 17 00:00:00 2001 From: localhost_frssoft Date: Wed, 14 Jun 2023 17:37:36 +0300 Subject: [PATCH] Print info about track in less --- src/fw_radios.py | 3 +-- src/mpv_control.py | 3 +-- src/utils.py | 8 ++++++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/fw_radios.py b/src/fw_radios.py index 2d6f6a4..456287a 100644 --- a/src/fw_radios.py +++ b/src/fw_radios.py @@ -148,9 +148,8 @@ 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()) + track['direct_url'] = player.stream_open_filename track_info_output(track) - print('Direct link: ' + player.stream_open_filename) - input() elif select == 'Like': favorite_track(player_fw_storage.storage.get( track_url_to_uuid())['id']) diff --git a/src/mpv_control.py b/src/mpv_control.py index 15c2790..d57acf1 100644 --- a/src/mpv_control.py +++ b/src/mpv_control.py @@ -155,9 +155,8 @@ 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()) + track['direct_url'] = player.stream_open_filename track_info_output(track) - print('Direct link: ' + player.stream_open_filename) - input() elif select == 'Like': src.fw_api.favorite_track( player_fw_storage.storage.get(track_url_to_uuid())['id']) diff --git a/src/utils.py b/src/utils.py index 1d7391e..a1e70d6 100644 --- a/src/utils.py +++ b/src/utils.py @@ -1,5 +1,6 @@ import src.fw_api +import os import sys import shutil from urllib.parse import unquote @@ -57,12 +58,15 @@ def print_there(x, y, text): def track_info_output(track): + output = [] 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}') + output.append(f'{k}: {val_override}') else: - print(f'{k}: {v}') + output.append(f'{k}: {v}') + output = '\n'.join(output) + os.system(f'less <