mirror of
https://gitea.phreedom.club/localhost_frssoft/funkwlmpv
synced 2024-11-23 23:19:21 +02:00
Compare commits
4 Commits
d39a86a2a9
...
88d619f304
Author | SHA1 | Date | |
---|---|---|---|
localhost_frssoft | 88d619f304 | ||
localhost_frssoft | 6a816ea853 | ||
localhost_frssoft | 7ab1058937 | ||
localhost_frssoft | f401700e78 |
|
@ -159,7 +159,7 @@ def get_recently_listened(page=None, q=None, scope=None, include_channels=None,
|
|||
|
||||
@logger.catch
|
||||
def get_artists(page=None, q=None, artist=None, album=None,
|
||||
library=None, favourites=None, refresh=False, pg=None):
|
||||
library=None, scope=None, favourites=None, refresh=False, pg=None):
|
||||
'''This function get artists by params'''
|
||||
params = {
|
||||
'page': page,
|
||||
|
@ -167,6 +167,7 @@ def get_artists(page=None, q=None, artist=None, album=None,
|
|||
'artist': artist,
|
||||
'album': album,
|
||||
'library': library,
|
||||
'scope': scope,
|
||||
'favourites': favourites,
|
||||
'refresh': refresh
|
||||
}
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
def hint_scope():
|
||||
print(
|
||||
'''Limit the results to a given user or pod:
|
||||
Use all (or do not specify the property to disable scope filtering)
|
||||
Use me to retrieve content relative to the current user
|
||||
Use subscribed to retrieve content in libraries you follow
|
||||
Use actor:alice@example.com to retrieve content relative to the account `alice@example.com
|
||||
Use domain:example.com to retrieve content relative to the domain `example.com
|
||||
You can specify multiple coma separated scopes, e.g me,subscribed to retrieve content matching either scopes
|
||||
''')
|
|
@ -1,4 +1,5 @@
|
|||
from src.fw_api import get_artists, get_tracks, get_audio_file
|
||||
from src.fw_api_hints import hint_scope
|
||||
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
|
||||
|
@ -9,12 +10,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, library=None, scope=None):
|
||||
artists = get_artists(q=search, library=library, pg=pg, scope=scope)
|
||||
artists_next = artists.get('next')
|
||||
artists_prev = artists.get('previous')
|
||||
artists_results = artists.get('results')
|
||||
view = ['Search', 'Library']
|
||||
view = ['Search', 'Library', 'Limit by scope']
|
||||
if artists_next:
|
||||
view.append('Next page')
|
||||
if artists_prev:
|
||||
|
@ -23,8 +24,9 @@ def list_artists(pg=None, search=None, library=None):
|
|||
for i in artists_results:
|
||||
index = artists_results.index(i)
|
||||
artist_name = i.get('name')
|
||||
view.append(f'{index}.{artist_name}')
|
||||
select = fzf.prompt(view)[0].split('.', 1)[0]
|
||||
artist_tracks_count = i.get('tracks_count')
|
||||
view.append(f'{index}.{artist_name} | {artist_tracks_count}')
|
||||
select = fzf.prompt(view, '--header=\'map: artist | tracks count\'')[0].split('.', 1)[0]
|
||||
if select == 'Next page':
|
||||
list_artists(pg=artists_next)
|
||||
elif select == 'Prev page':
|
||||
|
@ -35,6 +37,10 @@ def list_artists(pg=None, search=None, library=None):
|
|||
elif select == 'Library':
|
||||
select_lib = libraries()
|
||||
list_artists(library=select_lib)
|
||||
elif select == 'Limit by scope':
|
||||
hint_scope()
|
||||
scope = input()
|
||||
list_artists(scope=scope)
|
||||
else:
|
||||
albums = artists_results[int(select)].get('albums')
|
||||
if albums:
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
from src.fw_api import get_favorires_tracks, get_recently_listened, get_audio_file
|
||||
from src.fw_api_hints import hint_scope
|
||||
from src.mpv_control import player, player_menu, track_url_to_uuid, player_fw_storage
|
||||
from pyfzf.pyfzf import FzfPrompt
|
||||
from loguru import logger
|
||||
|
@ -9,10 +10,10 @@ fzf = FzfPrompt()
|
|||
@logger.catch
|
||||
def list_fav_or_history(pg=None, search=None, scope=None, is_history_view=False):
|
||||
if is_history_view:
|
||||
caption = 'listened:'
|
||||
action = 'listened'
|
||||
tracks = get_recently_listened(q=search, scope=scope, pg=pg)
|
||||
else:
|
||||
caption = 'liked:'
|
||||
action = 'liked'
|
||||
tracks = get_favorires_tracks(q=search, scope=scope, pg=pg)
|
||||
tracks_next = tracks.get('next')
|
||||
tracks_prev = tracks.get('previous')
|
||||
|
@ -27,8 +28,8 @@ def list_fav_or_history(pg=None, search=None, scope=None, is_history_view=False)
|
|||
index = tracks_results.index(i)
|
||||
track_name = i['track'].get('title')
|
||||
who_user = i['user'].get('username')
|
||||
view.append(f'{index}.{track_name} | {caption} {who_user}')
|
||||
select = fzf.prompt(view, '--multi')
|
||||
view.append(f'{index}.{track_name} | {who_user}')
|
||||
select = fzf.prompt(view, f'--multi --header=\'map: track title | who {action}\'')
|
||||
if 'Next page' in select:
|
||||
list_fav_or_history(pg=tracks_next, is_history_view=is_history_view)
|
||||
elif 'Prev page' in select:
|
||||
|
@ -37,16 +38,7 @@ def list_fav_or_history(pg=None, search=None, scope=None, is_history_view=False)
|
|||
print('Search by track:')
|
||||
list_fav_or_history(search=input(), is_history_view=is_history_view)
|
||||
elif 'Limit by scope' in select:
|
||||
print('''
|
||||
Limit the results to a given user or pod:
|
||||
|
||||
Use all (or do not specify the property to disable scope filtering)
|
||||
Use me to retrieve content relative to the current user
|
||||
Use subscribed to retrieve content in libraries you follow
|
||||
Use actor:alice@example.com to retrieve content relative to the account `alice@example.com
|
||||
Use domain:example.com to retrieve content relative to the domain `example.com
|
||||
|
||||
''')
|
||||
hint_scope()
|
||||
scope = input()
|
||||
list_fav_or_history(scope=scope, search=search, is_history_view=is_history_view)
|
||||
elif 'Play this page' in select:
|
||||
|
|
Loading…
Reference in New Issue