mirror of
https://gitea.phreedom.club/localhost_frssoft/funkwlmpv
synced 2024-11-27 09:33:01 +00:00
Correct integration shared player storage for tracks
This commit is contained in:
parent
55fe364842
commit
06fd6308fe
@ -2,7 +2,7 @@ from src.fw_api import current_instance, get_radios, post_radio_session, get_tra
|
|||||||
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
|
||||||
from src.mpv_control import player, track_url_to_uuid
|
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
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
@ -11,7 +11,6 @@ import time
|
|||||||
|
|
||||||
fzf = FzfPrompt()
|
fzf = FzfPrompt()
|
||||||
|
|
||||||
audio_info = {}
|
|
||||||
|
|
||||||
@logger.catch
|
@logger.catch
|
||||||
def list_radios():
|
def list_radios():
|
||||||
@ -131,7 +130,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)
|
||||||
print(f'Downloaded: {name_downloaded}')
|
print(f'Downloaded: {name_downloaded}')
|
||||||
elif select == 'Info':
|
elif select == 'Info':
|
||||||
track = audio_info.get(track_url_to_uuid())
|
track = player_fw_storage.storage.get(track_url_to_uuid())
|
||||||
for i in ('title', 'fid', 'license', 'album', 'artist'):
|
for i in ('title', 'fid', 'license', 'album', 'artist'):
|
||||||
if i in ('album', 'artist'):
|
if i in ('album', 'artist'):
|
||||||
name_aa = track.get(i).get('name')
|
name_aa = track.get(i).get('name')
|
||||||
@ -143,7 +142,7 @@ def radio_load(id_radio=None, type_radio='custom', name=None, related_object=Non
|
|||||||
print(i + ': ' + key)
|
print(i + ': ' + key)
|
||||||
input()
|
input()
|
||||||
elif select == 'Like':
|
elif select == 'Like':
|
||||||
favorite_track(audio_info.get(track_url_to_uuid())['id'])
|
favorite_track(player_fw_storage.storage.get(track_url_to_uuid())['id'])
|
||||||
elif select == 'Exit':
|
elif select == 'Exit':
|
||||||
try:
|
try:
|
||||||
radio_event_gen.clear()
|
radio_event_gen.clear()
|
||||||
@ -152,6 +151,7 @@ def radio_load(id_radio=None, type_radio='custom', name=None, related_object=Non
|
|||||||
pass
|
pass
|
||||||
player.playlist_clear()
|
player.playlist_clear()
|
||||||
player.stop()
|
player.stop()
|
||||||
|
player_fw_storage.storage = {}
|
||||||
break
|
break
|
||||||
except:
|
except:
|
||||||
try:
|
try:
|
||||||
@ -161,6 +161,7 @@ def radio_load(id_radio=None, type_radio='custom', name=None, related_object=Non
|
|||||||
pass
|
pass
|
||||||
player.playlist_clear()
|
player.playlist_clear()
|
||||||
player.stop()
|
player.stop()
|
||||||
|
player_fw_storage.storage = {}
|
||||||
logger.exception('Radio force stopped')
|
logger.exception('Radio force stopped')
|
||||||
break
|
break
|
||||||
|
|
||||||
@ -180,7 +181,7 @@ def radio_get_track(radio_session_id):
|
|||||||
else:
|
else:
|
||||||
track = radio_context.get('track')
|
track = radio_context.get('track')
|
||||||
listen_url = track['listen_url']
|
listen_url = track['listen_url']
|
||||||
audio_info[track_url_to_uuid(listen_url)] = track
|
player_fw_storage.storage[track_url_to_uuid(listen_url)] = track
|
||||||
player.loadfile(get_audio_file(listen_url, listen_url=True), 'append-play')
|
player.loadfile(get_audio_file(listen_url, listen_url=True), 'append-play')
|
||||||
|
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ def track_url_to_uuid(listen_url=None):
|
|||||||
|
|
||||||
@logger.catch
|
@logger.catch
|
||||||
def player_menu(header='', storage={}):
|
def player_menu(header='', storage={}):
|
||||||
player_fw_storage.storage = storage
|
player_fw_storage.storage.update(storage)
|
||||||
player.volume = get_config("mpv_volume")
|
player.volume = get_config("mpv_volume")
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
@ -61,7 +61,7 @@ def player_menu(header='', storage={}):
|
|||||||
name_downloaded = download_track(player.stream_open_filename)
|
name_downloaded = download_track(player.stream_open_filename)
|
||||||
print(f'Downloaded: {name_downloaded}')
|
print(f'Downloaded: {name_downloaded}')
|
||||||
elif select == 'Info':
|
elif select == 'Info':
|
||||||
track = storage.get(track_url_to_uuid())
|
track = player_fw_storage.storage.get(track_url_to_uuid())
|
||||||
for i in track.keys():
|
for i in track.keys():
|
||||||
if i in ('album', 'artist'):
|
if i in ('album', 'artist'):
|
||||||
name_aa = track.get(i).get('name')
|
name_aa = track.get(i).get('name')
|
||||||
@ -73,13 +73,14 @@ def player_menu(header='', storage={}):
|
|||||||
print(i + ': ' + key)
|
print(i + ': ' + key)
|
||||||
input()
|
input()
|
||||||
elif select == 'Like':
|
elif select == 'Like':
|
||||||
src.fw_api.favorite_track(storage.get(track_url_to_uuid())['id'])
|
src.fw_api.favorite_track(player_fw_storage.storage.get(track_url_to_uuid())['id'])
|
||||||
elif select == 'Hide artist':
|
elif select == 'Hide artist':
|
||||||
track = storage.get(track_url_to_uuid())
|
track = player_fw_storage.storage.get(track_url_to_uuid())
|
||||||
src.fw_api.hide_content({'target': {'id': track.get('artist').get('id'), 'type': 'artist'}})
|
src.fw_api.hide_content({'target': {'id': track.get('artist').get('id'), 'type': 'artist'}})
|
||||||
elif select == 'Exit':
|
elif select == 'Exit':
|
||||||
player.playlist_clear()
|
player.playlist_clear()
|
||||||
player.stop()
|
player.stop()
|
||||||
|
player_fw_storage.storage = {}
|
||||||
break
|
break
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
break
|
break
|
||||||
|
Loading…
Reference in New Issue
Block a user