mirror of
http://gitea.phreedom.club/localhost_frssoft/funkwlmpv
synced 2024-11-27 00:51:28 +00:00
Compare commits
2 commits
bd095da8ac
...
17607c7100
Author | SHA1 | Date | |
---|---|---|---|
localhost_frssoft | 17607c7100 | ||
localhost_frssoft | a65526443d |
|
@ -45,7 +45,7 @@ def main():
|
||||||
menu.append('Sign in')
|
menu.append('Sign in')
|
||||||
if support_message != '':
|
if support_message != '':
|
||||||
menu.append('Donate')
|
menu.append('Donate')
|
||||||
if not src.mpv_control.player.core_idle:
|
if src.mpv_control.player.playlist_playing_pos != -1:
|
||||||
menu.insert(0, 'Player')
|
menu.insert(0, 'Player')
|
||||||
ids = fzf.prompt(menu, f"--header={main_menu_header}")
|
ids = fzf.prompt(menu, f"--header={main_menu_header}")
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
from src.fw_api import get_favorires_tracks, get_audio_file
|
from src.fw_api import get_favorires_tracks, get_audio_file
|
||||||
from src.mpv_control import player, player_menu, track_url_to_uuid
|
from src.mpv_control import player, player_menu, track_url_to_uuid, player_fw_storage
|
||||||
from pyfzf.pyfzf import FzfPrompt
|
from pyfzf.pyfzf import FzfPrompt
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ def list_favorites_tracks(pg=None, search=None, scope=None):
|
||||||
tracks_next = tracks.get('next')
|
tracks_next = tracks.get('next')
|
||||||
tracks_prev = tracks.get('previous')
|
tracks_prev = tracks.get('previous')
|
||||||
tracks_results = tracks.get('results')
|
tracks_results = tracks.get('results')
|
||||||
view = ['Search', 'Limit by scope']
|
view = ['Search', 'Limit by scope', 'Play this page']
|
||||||
if tracks_next:
|
if tracks_next:
|
||||||
view.append('Next page')
|
view.append('Next page')
|
||||||
if tracks_prev:
|
if tracks_prev:
|
||||||
|
@ -22,15 +22,15 @@ def list_favorites_tracks(pg=None, search=None, scope=None):
|
||||||
track_name = i['track'].get('title')
|
track_name = i['track'].get('title')
|
||||||
who_user = i['user'].get('username')
|
who_user = i['user'].get('username')
|
||||||
view.append(f'{index}.{track_name} | liked: {who_user}')
|
view.append(f'{index}.{track_name} | liked: {who_user}')
|
||||||
select = fzf.prompt(view)[0].split('.', 1)[0]
|
select = fzf.prompt(view, '--multi')
|
||||||
if select == 'Next page':
|
if 'Next page' in select:
|
||||||
list_favorites_tracks(pg=tracks_next)
|
list_favorites_tracks(pg=tracks_next)
|
||||||
elif select == 'Prev page':
|
elif 'Prev page' in select:
|
||||||
list_favorites_tracks(pg=tracks_prev)
|
list_favorites_tracks(pg=tracks_prev)
|
||||||
elif select == 'Search':
|
elif 'Search' in select:
|
||||||
print('Search by track:')
|
print('Search by track:')
|
||||||
list_favorites_tracks(search=input())
|
list_favorites_tracks(search=input())
|
||||||
elif select == 'Limit by scope':
|
elif 'Limit by scope' in select:
|
||||||
print('''
|
print('''
|
||||||
Limit the results to a given user or pod:
|
Limit the results to a given user or pod:
|
||||||
|
|
||||||
|
@ -43,14 +43,22 @@ Limit the results to a given user or pod:
|
||||||
''')
|
''')
|
||||||
scope = input()
|
scope = input()
|
||||||
list_favorites_tracks(scope=scope, search=search)
|
list_favorites_tracks(scope=scope, search=search)
|
||||||
|
elif 'Play this page' in select:
|
||||||
|
for i in tracks_results:
|
||||||
|
play_track(track=i['track'], multi=True)
|
||||||
|
elif len(select) > 1:
|
||||||
|
for i in select:
|
||||||
|
play_track(track=tracks_results[int(i.split('.', 1)[0])]['track'], multi=True)
|
||||||
else:
|
else:
|
||||||
play_track(track=tracks_results[int(select)]['track'])
|
play_track(track=tracks_results[int(select[0].split('.', 1)[0])]['track'])
|
||||||
|
|
||||||
|
|
||||||
def play_track(track):
|
def play_track(track, multi=False):
|
||||||
storage = {}
|
|
||||||
listen_url = get_audio_file(track['listen_url'], True)
|
listen_url = get_audio_file(track['listen_url'], True)
|
||||||
storage[track_url_to_uuid(listen_url)] = track
|
player_fw_storage.storage[track_url_to_uuid(listen_url)] = track
|
||||||
player.loadfile(listen_url, 'append-play')
|
if multi:
|
||||||
track_name = track.get('title')
|
player.loadfile(listen_url, 'append-play')
|
||||||
player_menu(f"{track_name} playing...", storage)
|
else:
|
||||||
|
player.loadfile(listen_url, 'append-play')
|
||||||
|
track_name = track.get('title')
|
||||||
|
player_menu(f"{track_name} playing...", player_fw_storage.storage)
|
||||||
|
|
Loading…
Reference in a new issue