mirror of
https://gitea.phreedom.club/localhost_frssoft/funkwlmpv
synced 2024-11-27 17:43:02 +00:00
Added partially working tracks list; Removed mpv logger func
This commit is contained in:
parent
522a6e36b8
commit
93380080d0
@ -2,6 +2,7 @@ from src.fw_api import s, select_instance, instance, federate_search_by_url
|
||||
from src.fw_radios import list_radios
|
||||
from src.fw_artists import list_artists
|
||||
from src.fw_albums import list_albums
|
||||
from src.fw_tracks import list_tracks
|
||||
from src.fw_channels import list_channels
|
||||
from src.fw_playlists import list_playlists
|
||||
import src.settings as settings
|
||||
@ -16,6 +17,7 @@ def main():
|
||||
menu = ['Radios',
|
||||
'Artists',
|
||||
'Albums',
|
||||
'Tracks',
|
||||
'Channels',
|
||||
'Playlists',
|
||||
'Search',
|
||||
@ -31,6 +33,8 @@ def main():
|
||||
list_artists()
|
||||
if selected == 'Albums':
|
||||
list_albums()
|
||||
if selected == 'Tracks':
|
||||
list_tracks()
|
||||
if selected == 'Channels':
|
||||
list_channels()
|
||||
if selected == 'Playlists':
|
||||
|
42
src/fw_tracks.py
Normal file
42
src/fw_tracks.py
Normal file
@ -0,0 +1,42 @@
|
||||
from src.fw_api import get_tracks, concatinate_endpoint
|
||||
from src.mpv_control import player, player_menu
|
||||
from pyfzf.pyfzf import FzfPrompt
|
||||
from loguru import logger
|
||||
|
||||
fzf = FzfPrompt()
|
||||
|
||||
@logger.catch
|
||||
def list_tracks(pg=None, search=None):
|
||||
tracks = get_tracks(q=search, pg=pg)
|
||||
tracks_next = tracks.get('next')
|
||||
tracks_prev = tracks.get('previous')
|
||||
tracks_results = tracks.get('results')
|
||||
view = ['Search']
|
||||
if tracks_next:
|
||||
view.append('Next page')
|
||||
if tracks_prev:
|
||||
view.append('Prev page')
|
||||
|
||||
for i in tracks_results:
|
||||
index = tracks_results.index(i)
|
||||
track_name = i.get('title')
|
||||
view.append(f'{index}.{track_name}')
|
||||
select = fzf.prompt(view)[0].split('.', 1)[0]
|
||||
if select == 'Next page':
|
||||
list_tracks(pg=tracks_next)
|
||||
elif select == 'Prev page':
|
||||
list_tracks(pg=tracks_prev)
|
||||
elif select == 'Search':
|
||||
print('Search by track:')
|
||||
list_tracks(search=input())
|
||||
else:
|
||||
play_track(track=tracks_results[int(select)])
|
||||
|
||||
|
||||
def play_track(track):
|
||||
storage = {}
|
||||
listen_url = concatinate_endpoint(track.get('listen_url'))
|
||||
storage[listen_url] = track
|
||||
player.loadfile(listen_url, 'append-play')
|
||||
track_name = track.get('title')
|
||||
player_menu(f"{track_name} playing...", storage)
|
@ -7,13 +7,6 @@ import mpv
|
||||
|
||||
fzf = FzfPrompt()
|
||||
|
||||
|
||||
def mpv_log(loglevel, component, message):
|
||||
if loglevel == 'info':
|
||||
logger.info(f'{component} {message}')
|
||||
elif loglevel == 'error':
|
||||
logger.error(f'{component} {message}')
|
||||
|
||||
player = mpv.MPV()
|
||||
player.ytdl = False # Prevent attempts load track with yt-dlp
|
||||
player.prefetch_playlist = get_config('prefetch_playlist') # Fast loading next track, but high network traffic
|
||||
|
Loading…
Reference in New Issue
Block a user