Compare commits

...

3 commits

5 changed files with 15 additions and 21 deletions

View file

@ -1,6 +1,6 @@
#!/usr/bin/env python3
from src.fw_api import current_instance, federate_search_by_url, get_instance_settings
from src.fw_api import current_instance, get_instance_settings
from src.fw_radios import list_radios
from src.fw_artists import list_artists
from src.fw_albums import list_albums
@ -13,7 +13,6 @@ import src.mpv_control
import json
import os
from shlex import quote
from loguru import logger
from pyfzf.pyfzf import FzfPrompt
fzf = FzfPrompt()
@ -32,7 +31,6 @@ def main():
'Playlists',
'Favorites',
'Recently listened',
'Search',
'About instance',
'Switch instance']
try:
@ -83,13 +81,6 @@ def main():
list_fav_or_history()
if selected == 'Recently listened':
list_fav_or_history(is_history_view=True)
if selected == 'Search':
search_type = fzf.prompt(('Federated', 'All types'))[0]
if search_type == 'Federated':
print('Input url:')
returned_obj = federate_search_by_url(input())
logger.info(str(returned_obj))
if selected == 'Switch instance':
with open('config.json', 'rt') as f:
conf = json.loads(f.read())

View file

@ -1,4 +1,4 @@
from src.fw_api import list_libraries, federate_remote_library, scan_remote_library
from src.fw_api import current_instance, list_libraries, federate_remote_library, scan_remote_library
from pyfzf.pyfzf import FzfPrompt
from loguru import logger
import time
@ -18,16 +18,18 @@ def libraries(pg=None, radio=False):
libraries_listing.append('Next')
if libs_prev:
libraries_listing.append('Prev')
if radio == False:
if current_instance.s.headers.get('Authorization'):
libraries_listing.append('Add remote library')
for lib_i in libs:
index = libs.index(lib_i)
lib_name = lib_i.get('name')
lib_tracks_count = lib_i.get('uploads_count')
lib_by = lib_i.get('actor').get('full_username')
libraries_listing.append(f'{index}.{lib_name} | by {lib_by}')
libraries_listing.append(f'{index}.{lib_name} | {lib_by} | {lib_tracks_count}')
lib_select = fzf.prompt(
libraries_listing, f'--header=\'found {libs_count} libraries\'')[0].split('.', 1)
libraries_listing,
f'--header=\'found {libs_count} libraries\nmap: library name | owner | tracks count\'')[0].split('.', 1)
if lib_select[0] == 'Next':
return libraries(pg=libs_next)
elif lib_select[0] == 'Prev':
@ -61,4 +63,3 @@ def libraries(pg=None, radio=False):
return None, 'library', f'{lib_name}\n{lib_fid}', lib_uuid
else:
return lib_uuid

View file

@ -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'])

View file

@ -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'])

View file

@ -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 <<EOF\n{output}')