mirror of
https://gitea.phreedom.club/localhost_frssoft/funkwlmpv
synced 2024-11-24 00:29:20 +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
|
@logger.catch
|
||||||
def get_artists(page=None, q=None, artist=None, album=None,
|
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'''
|
'''This function get artists by params'''
|
||||||
params = {
|
params = {
|
||||||
'page': page,
|
'page': page,
|
||||||
|
@ -167,6 +167,7 @@ def get_artists(page=None, q=None, artist=None, album=None,
|
||||||
'artist': artist,
|
'artist': artist,
|
||||||
'album': album,
|
'album': album,
|
||||||
'library': library,
|
'library': library,
|
||||||
|
'scope': scope,
|
||||||
'favourites': favourites,
|
'favourites': favourites,
|
||||||
'refresh': refresh
|
'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 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_albums import list_albums
|
||||||
from src.fw_libraries import libraries
|
from src.fw_libraries import libraries
|
||||||
from src.mpv_control import player, player_menu, track_url_to_uuid
|
from src.mpv_control import player, player_menu, track_url_to_uuid
|
||||||
|
@ -9,12 +10,12 @@ fzf = FzfPrompt()
|
||||||
|
|
||||||
|
|
||||||
@logger.catch
|
@logger.catch
|
||||||
def list_artists(pg=None, search=None, library=None):
|
def list_artists(pg=None, search=None, library=None, scope=None):
|
||||||
artists = get_artists(q=search, library=library, pg=pg)
|
artists = get_artists(q=search, library=library, pg=pg, scope=scope)
|
||||||
artists_next = artists.get('next')
|
artists_next = artists.get('next')
|
||||||
artists_prev = artists.get('previous')
|
artists_prev = artists.get('previous')
|
||||||
artists_results = artists.get('results')
|
artists_results = artists.get('results')
|
||||||
view = ['Search', 'Library']
|
view = ['Search', 'Library', 'Limit by scope']
|
||||||
if artists_next:
|
if artists_next:
|
||||||
view.append('Next page')
|
view.append('Next page')
|
||||||
if artists_prev:
|
if artists_prev:
|
||||||
|
@ -23,8 +24,9 @@ def list_artists(pg=None, search=None, library=None):
|
||||||
for i in artists_results:
|
for i in artists_results:
|
||||||
index = artists_results.index(i)
|
index = artists_results.index(i)
|
||||||
artist_name = i.get('name')
|
artist_name = i.get('name')
|
||||||
view.append(f'{index}.{artist_name}')
|
artist_tracks_count = i.get('tracks_count')
|
||||||
select = fzf.prompt(view)[0].split('.', 1)[0]
|
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':
|
if select == 'Next page':
|
||||||
list_artists(pg=artists_next)
|
list_artists(pg=artists_next)
|
||||||
elif select == 'Prev page':
|
elif select == 'Prev page':
|
||||||
|
@ -35,6 +37,10 @@ def list_artists(pg=None, search=None, library=None):
|
||||||
elif select == 'Library':
|
elif select == 'Library':
|
||||||
select_lib = libraries()
|
select_lib = libraries()
|
||||||
list_artists(library=select_lib)
|
list_artists(library=select_lib)
|
||||||
|
elif select == 'Limit by scope':
|
||||||
|
hint_scope()
|
||||||
|
scope = input()
|
||||||
|
list_artists(scope=scope)
|
||||||
else:
|
else:
|
||||||
albums = artists_results[int(select)].get('albums')
|
albums = artists_results[int(select)].get('albums')
|
||||||
if 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 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 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
|
||||||
|
@ -9,10 +10,10 @@ fzf = FzfPrompt()
|
||||||
@logger.catch
|
@logger.catch
|
||||||
def list_fav_or_history(pg=None, search=None, scope=None, is_history_view=False):
|
def list_fav_or_history(pg=None, search=None, scope=None, is_history_view=False):
|
||||||
if is_history_view:
|
if is_history_view:
|
||||||
caption = 'listened:'
|
action = 'listened'
|
||||||
tracks = get_recently_listened(q=search, scope=scope, pg=pg)
|
tracks = get_recently_listened(q=search, scope=scope, pg=pg)
|
||||||
else:
|
else:
|
||||||
caption = 'liked:'
|
action = 'liked'
|
||||||
tracks = get_favorires_tracks(q=search, scope=scope, pg=pg)
|
tracks = get_favorires_tracks(q=search, scope=scope, pg=pg)
|
||||||
tracks_next = tracks.get('next')
|
tracks_next = tracks.get('next')
|
||||||
tracks_prev = tracks.get('previous')
|
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)
|
index = tracks_results.index(i)
|
||||||
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} | {caption} {who_user}')
|
view.append(f'{index}.{track_name} | {who_user}')
|
||||||
select = fzf.prompt(view, '--multi')
|
select = fzf.prompt(view, f'--multi --header=\'map: track title | who {action}\'')
|
||||||
if 'Next page' in select:
|
if 'Next page' in select:
|
||||||
list_fav_or_history(pg=tracks_next, is_history_view=is_history_view)
|
list_fav_or_history(pg=tracks_next, is_history_view=is_history_view)
|
||||||
elif 'Prev page' in select:
|
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:')
|
print('Search by track:')
|
||||||
list_fav_or_history(search=input(), is_history_view=is_history_view)
|
list_fav_or_history(search=input(), is_history_view=is_history_view)
|
||||||
elif 'Limit by scope' in select:
|
elif 'Limit by scope' in select:
|
||||||
print('''
|
hint_scope()
|
||||||
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
|
|
||||||
|
|
||||||
''')
|
|
||||||
scope = input()
|
scope = input()
|
||||||
list_fav_or_history(scope=scope, search=search, is_history_view=is_history_view)
|
list_fav_or_history(scope=scope, search=search, is_history_view=is_history_view)
|
||||||
elif 'Play this page' in select:
|
elif 'Play this page' in select:
|
||||||
|
|
Loading…
Reference in New Issue