mirror of
https://gitea.phreedom.club/localhost_frssoft/funkwlmpv
synced 2024-11-27 18:59:20 +02:00
Compare commits
No commits in common. "b07d9624364eea2a0f85a0fa47e95ba2751f8992" and "8fa1773807f44094520d330a619565a6139ea243" have entirely different histories.
b07d962436
...
8fa1773807
|
@ -1,6 +1,5 @@
|
|||
import src.fw_artists
|
||||
from src.fw_api import get_artists, get_tracks, get_albums, get_audio_file
|
||||
from src.fw_libraries import libraries
|
||||
from src.settings import get_config
|
||||
from src.mpv_control import player, player_menu, track_url_to_uuid
|
||||
from pyfzf.pyfzf import FzfPrompt
|
||||
|
@ -10,13 +9,13 @@ fzf = FzfPrompt()
|
|||
|
||||
|
||||
@logger.catch
|
||||
def list_albums(albums=None, pg=None, search=None, artist=None, library=None, include_channels=None, refresh=False):
|
||||
def list_albums(albums=None, pg=None, search=None, artist=None, include_channels=None, refresh=False):
|
||||
show_artist_name_in_albums = get_config('show_artist_name_in_albums')
|
||||
albums_next = None
|
||||
albums_prev = None
|
||||
play_artist_albums = False
|
||||
if not albums:
|
||||
albums = get_albums(q=search, artist=artist, library=library,
|
||||
albums = get_albums(q=search, artist=artist,
|
||||
include_channels=include_channels, refresh=refresh, pg=pg)
|
||||
albums_next = albums.get('next')
|
||||
albums_prev = albums.get('previous')
|
||||
|
@ -26,7 +25,7 @@ def list_albums(albums=None, pg=None, search=None, artist=None, library=None, in
|
|||
else:
|
||||
play_artist_albums = True
|
||||
albums_results = albums
|
||||
view = ['Search', 'Library']
|
||||
view = ['Search']
|
||||
if play_artist_albums:
|
||||
view.append('Play all')
|
||||
if albums_next:
|
||||
|
@ -51,9 +50,6 @@ def list_albums(albums=None, pg=None, search=None, artist=None, library=None, in
|
|||
elif select == 'Search':
|
||||
print('Search by albums: ')
|
||||
list_albums(search=input())
|
||||
elif select == 'Library':
|
||||
select_lib = libraries()
|
||||
list_albums(library=select_lib)
|
||||
elif select == 'Play all':
|
||||
if artist:
|
||||
src.fw_artists.play_artist(artist)
|
||||
|
|
|
@ -88,7 +88,7 @@ def get_audio_file(track_uuid, listen_url=False, download=False,
|
|||
|
||||
|
||||
@logger.catch
|
||||
def get_tracks(page=None, q=None, artist=None, album=None, library=None,
|
||||
def get_tracks(page=None, q=None, artist=None, album=None,
|
||||
tag=None, favourites=None, include_channels=None, pg=None):
|
||||
'''This function get tracks by params'''
|
||||
params = {
|
||||
|
@ -98,7 +98,6 @@ def get_tracks(page=None, q=None, artist=None, album=None, library=None,
|
|||
'album': album,
|
||||
'tag': tag,
|
||||
'favourites': favourites,
|
||||
'library': library,
|
||||
'include_channels': include_channels
|
||||
}
|
||||
if pg:
|
||||
|
@ -127,15 +126,13 @@ def get_favorires_tracks(page=None, q=None, scope=None, include_channels=None, p
|
|||
|
||||
|
||||
@logger.catch
|
||||
def get_artists(page=None, q=None, artist=None, album=None,
|
||||
library=None, favourites=None, refresh=False, pg=None):
|
||||
def get_artists(page=None, q=None, artist=None, album=None, favourites=None, refresh=False, pg=None):
|
||||
'''This function get artists by params'''
|
||||
params = {
|
||||
'page': page,
|
||||
'q': q,
|
||||
'artist': artist,
|
||||
'album': album,
|
||||
'library': library,
|
||||
'favourites': favourites,
|
||||
'refresh': refresh
|
||||
}
|
||||
|
@ -148,13 +145,12 @@ def get_artists(page=None, q=None, artist=None, album=None,
|
|||
|
||||
|
||||
@logger.catch
|
||||
def get_albums(page=None, q=None, artist=None, library=None, include_channels=None, refresh=False, pg=None):
|
||||
def get_albums(page=None, q=None, artist=None, include_channels=None, refresh=False, pg=None):
|
||||
'''This function get artists by params'''
|
||||
params = {
|
||||
'page': page,
|
||||
'q': q,
|
||||
'artist': artist,
|
||||
'library': library,
|
||||
'include_channels': include_channels,
|
||||
'refresh': refresh
|
||||
}
|
||||
|
@ -249,25 +245,6 @@ def federate_search_by_url(object):
|
|||
return r.json()
|
||||
|
||||
|
||||
@logger.catch
|
||||
def federate_remote_library(fid):
|
||||
'''Fetch remote library for follow and scan'''
|
||||
params = {
|
||||
'fid': fid
|
||||
}
|
||||
r = current_instance.s.post(
|
||||
f'https://{current_instance.instance}/api/v1/federation/libraries/fetch', json=params)
|
||||
return r.json()
|
||||
|
||||
|
||||
@logger.catch
|
||||
def scan_remote_library(uuid):
|
||||
'''Scan remote library'''
|
||||
r = current_instance.s.post(
|
||||
f'https://{current_instance.instance}/api/v1/federation/libraries/{uuid}')
|
||||
return r.json()
|
||||
|
||||
|
||||
@logger.catch
|
||||
def record_track_in_history(track_id):
|
||||
params = {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
from src.fw_api import get_artists, get_tracks, get_audio_file
|
||||
from src.fw_albums import list_albums
|
||||
from src.fw_libraries import libraries
|
||||
from src.mpv_control import player, player_menu, track_url_to_uuid
|
||||
from pyfzf.pyfzf import FzfPrompt
|
||||
from loguru import logger
|
||||
|
@ -9,12 +8,12 @@ fzf = FzfPrompt()
|
|||
|
||||
|
||||
@logger.catch
|
||||
def list_artists(pg=None, search=None, library=None):
|
||||
artists = get_artists(q=search, library=library, pg=pg)
|
||||
def list_artists(pg=None, search=None):
|
||||
artists = get_artists(q=search, pg=pg)
|
||||
artists_next = artists.get('next')
|
||||
artists_prev = artists.get('previous')
|
||||
artists_results = artists.get('results')
|
||||
view = ['Search', 'Library']
|
||||
view = ['Search']
|
||||
if artists_next:
|
||||
view.append('Next page')
|
||||
if artists_prev:
|
||||
|
@ -32,9 +31,6 @@ def list_artists(pg=None, search=None, library=None):
|
|||
elif select == 'Search':
|
||||
print('Search by artist:')
|
||||
list_artists(search=input())
|
||||
elif select == 'Library':
|
||||
select_lib = libraries()
|
||||
list_artists(library=select_lib)
|
||||
else:
|
||||
albums = artists_results[int(select)].get('albums')
|
||||
if albums:
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
from src.fw_api import list_libraries, federate_remote_library, scan_remote_library
|
||||
from src.fw_api import list_libraries
|
||||
from pyfzf.pyfzf import FzfPrompt
|
||||
from loguru import logger
|
||||
import time
|
||||
|
||||
fzf = FzfPrompt()
|
||||
|
||||
|
||||
@logger.catch
|
||||
def libraries(pg=None, radio=False):
|
||||
def libraries(pg=None):
|
||||
libs_res = list_libraries(pg=pg)
|
||||
libs_count = libs_res.get('count')
|
||||
libs_next = libs_res.get('next')
|
||||
|
@ -18,9 +17,6 @@ def libraries(pg=None, radio=False):
|
|||
libraries_listing.append('Next')
|
||||
if libs_prev:
|
||||
libraries_listing.append('Prev')
|
||||
if radio == False:
|
||||
libraries_listing.append('Add remote library')
|
||||
|
||||
for lib_i in libs:
|
||||
index = libs.index(lib_i)
|
||||
lib_name = lib_i.get('name')
|
||||
|
@ -32,33 +28,8 @@ def libraries(pg=None, radio=False):
|
|||
return libraries(pg=libs_next)
|
||||
elif lib_select[0] == 'Prev':
|
||||
return libraries(pg=libs_prev)
|
||||
elif lib_select[0] == 'Add remote library':
|
||||
print('Search a remote library (url\\fid):')
|
||||
new_library = federate_remote_library(input())
|
||||
if new_library.get('detail'):
|
||||
logger.error(new_library['detail'])
|
||||
return
|
||||
if new_library.get('count') > 0:
|
||||
print('Library found')
|
||||
one_lib = new_library['results'][0]
|
||||
scan = scan_remote_library(one_lib['uuid'])
|
||||
if scan.get('detail'):
|
||||
logger.error(scan['detail'])
|
||||
return
|
||||
status = scan['status']
|
||||
if status == 'scheduled':
|
||||
print(f'Scanning {status}. Please wait few minutes for scan and open libraries menu again')
|
||||
else:
|
||||
print(f'Scan is {status}')
|
||||
time.sleep(3)
|
||||
return
|
||||
else:
|
||||
lib_addr = lib_select[0]
|
||||
lib_name = lib_select[1]
|
||||
lib_uuid = libs[int(lib_addr)]['uuid']
|
||||
lib_fid = libs[int(lib_addr)]['fid']
|
||||
if radio:
|
||||
return None, 'library', f'{lib_name}\n{lib_fid}', lib_uuid
|
||||
else:
|
||||
return lib_uuid
|
||||
|
||||
lib_uuid = libs[int(lib_addr)].get('uuid')
|
||||
return None, 'library', lib_name, lib_uuid
|
||||
|
|
|
@ -45,7 +45,7 @@ def list_radios():
|
|||
elif 'Random' in selected:
|
||||
radio_load(id_radio, 'random', name='totally random')
|
||||
elif 'Libraries' in selected:
|
||||
id_radio, type_radio, name_radio, related_obj = libraries(radio=True)
|
||||
id_radio, type_radio, name_radio, related_obj = libraries()
|
||||
radio_load(id_radio, type_radio, name_radio, related_obj)
|
||||
elif 'Users' in selected:
|
||||
libs = list_libraries()['results']
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
from src.fw_api import get_tracks, get_audio_file
|
||||
from src.fw_tags import list_tags
|
||||
from src.fw_libraries import libraries
|
||||
from src.mpv_control import player, player_menu, track_url_to_uuid, play_track
|
||||
from pyfzf.pyfzf import FzfPrompt
|
||||
from loguru import logger
|
||||
|
@ -9,12 +8,12 @@ fzf = FzfPrompt()
|
|||
|
||||
|
||||
@logger.catch
|
||||
def list_tracks(pg=None, search=None, tag=None, library=None):
|
||||
tracks = get_tracks(q=search, pg=pg, tag=tag, library=library)
|
||||
def list_tracks(pg=None, search=None, tag=None):
|
||||
tracks = get_tracks(q=search, pg=pg, tag=tag)
|
||||
tracks_next = tracks.get('next')
|
||||
tracks_prev = tracks.get('previous')
|
||||
tracks_results = tracks.get('results')
|
||||
view = ['Search', 'Tags', 'Library', 'Play this page']
|
||||
view = ['Search', 'Tags', 'Play this page']
|
||||
if tracks_next:
|
||||
view.append('Next page')
|
||||
if tracks_prev:
|
||||
|
@ -35,9 +34,6 @@ def list_tracks(pg=None, search=None, tag=None, library=None):
|
|||
elif select == 'Tags':
|
||||
select_tag = list_tags()
|
||||
list_tracks(tag=select_tag)
|
||||
elif select == 'Library':
|
||||
select_lib = libraries()
|
||||
list_tracks(library=select_lib)
|
||||
elif select == 'Play this page':
|
||||
for i in tracks_results:
|
||||
play_track(track=i, multi=True)
|
||||
|
|
|
@ -92,7 +92,7 @@ def universal_observer(_name, value):
|
|||
else:
|
||||
cache_speed = ''
|
||||
if player.playlist_count > -1:
|
||||
player_pos = f'{player.playlist_pos_1}/{player.playlist_count}'
|
||||
player_pos = f'{player.playlist_current_pos}/{player.playlist_count}'
|
||||
else:
|
||||
player_pos = '-/-'
|
||||
print_there(2, 2, f'\r'+' '*get_terminal_size().columns)
|
||||
|
|
Loading…
Reference in New Issue