mirror of
http://gitea.phreedom.club/localhost_frssoft/funkwlmpv
synced 2024-11-25 11:01:27 +00:00
Tags added
This commit is contained in:
parent
3124613c3a
commit
5d23553dd3
|
@ -83,13 +83,15 @@ def get_audio_file(track_uuid, listen_url=False, download=False,
|
||||||
|
|
||||||
|
|
||||||
@logger.catch
|
@logger.catch
|
||||||
def get_tracks(page=None, q=None, artist=None, album=None, favourites=None, include_channels=None, pg=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'''
|
'''This function get tracks by params'''
|
||||||
params = {
|
params = {
|
||||||
'page': page,
|
'page': page,
|
||||||
'q': q,
|
'q': q,
|
||||||
'artist': artist,
|
'artist': artist,
|
||||||
'album': album,
|
'album': album,
|
||||||
|
'tag': tag,
|
||||||
'favourites': favourites,
|
'favourites': favourites,
|
||||||
'include_channels': include_channels
|
'include_channels': include_channels
|
||||||
}
|
}
|
||||||
|
@ -206,6 +208,17 @@ def list_libraries(page=None, page_size=None, q=None, scope='all', pg=None):
|
||||||
r = s.get(f'https://{instance}/api/v1/libraries', params=params)
|
r = s.get(f'https://{instance}/api/v1/libraries', params=params)
|
||||||
return r.json()
|
return r.json()
|
||||||
|
|
||||||
|
@logger.catch
|
||||||
|
def get_tags(q=None, pg=None):
|
||||||
|
params = {
|
||||||
|
'q': q,
|
||||||
|
}
|
||||||
|
if pg:
|
||||||
|
r = s.get(pg)
|
||||||
|
else:
|
||||||
|
r = s.get(f'https://{instance}/api/v1/tags', params=params)
|
||||||
|
return r.json()
|
||||||
|
|
||||||
|
|
||||||
@logger.catch
|
@logger.catch
|
||||||
def federate_search_by_url(object):
|
def federate_search_by_url(object):
|
||||||
|
|
33
src/fw_tags.py
Normal file
33
src/fw_tags.py
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
from src.fw_api import get_tags
|
||||||
|
from pyfzf.pyfzf import FzfPrompt
|
||||||
|
from loguru import logger
|
||||||
|
|
||||||
|
fzf = FzfPrompt()
|
||||||
|
|
||||||
|
@logger.catch
|
||||||
|
def list_tags(pg=None, search=None):
|
||||||
|
tags = get_tags(q=search, pg=pg)
|
||||||
|
tags_next = tags.get('next')
|
||||||
|
tags_prev = tags.get('previous')
|
||||||
|
tags_results = tags.get('results')
|
||||||
|
view = ['Search']
|
||||||
|
if tags_next:
|
||||||
|
view.append('Next page')
|
||||||
|
if tags_prev:
|
||||||
|
view.append('Prev page')
|
||||||
|
|
||||||
|
for i in tags_results:
|
||||||
|
index = tags_results.index(i)
|
||||||
|
tag_name = i.get('name')
|
||||||
|
view.append(f'{index}.{tag_name}')
|
||||||
|
select = fzf.prompt(view)[0].split('.', 1)[0]
|
||||||
|
if select == 'Next page':
|
||||||
|
list_tags(pg=tags_next)
|
||||||
|
elif select == 'Prev page':
|
||||||
|
list_tags(pg=tags_prev)
|
||||||
|
elif select == 'Search':
|
||||||
|
print('Search by tag:')
|
||||||
|
list_tags(search=input())
|
||||||
|
else:
|
||||||
|
return tags_results[int(select)].get('name')
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
from src.fw_api import get_tracks, get_audio_file
|
from src.fw_api import get_tracks, get_audio_file
|
||||||
|
from src.fw_tags import list_tags
|
||||||
from src.mpv_control import player, player_menu, track_url_to_uuid
|
from src.mpv_control import player, player_menu, track_url_to_uuid
|
||||||
from pyfzf.pyfzf import FzfPrompt
|
from pyfzf.pyfzf import FzfPrompt
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
|
@ -6,12 +7,12 @@ from loguru import logger
|
||||||
fzf = FzfPrompt()
|
fzf = FzfPrompt()
|
||||||
|
|
||||||
@logger.catch
|
@logger.catch
|
||||||
def list_tracks(pg=None, search=None):
|
def list_tracks(pg=None, search=None, tag=None):
|
||||||
tracks = get_tracks(q=search, pg=pg)
|
tracks = get_tracks(q=search, pg=pg, tag=tag)
|
||||||
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']
|
view = ['Search', 'Tags']
|
||||||
if tracks_next:
|
if tracks_next:
|
||||||
view.append('Next page')
|
view.append('Next page')
|
||||||
if tracks_prev:
|
if tracks_prev:
|
||||||
|
@ -29,6 +30,9 @@ def list_tracks(pg=None, search=None):
|
||||||
elif select == 'Search':
|
elif select == 'Search':
|
||||||
print('Search by track:')
|
print('Search by track:')
|
||||||
list_tracks(search=input())
|
list_tracks(search=input())
|
||||||
|
elif select == 'Tags':
|
||||||
|
select_tag = list_tags()
|
||||||
|
list_tracks(tag=select_tag)
|
||||||
else:
|
else:
|
||||||
play_track(track=tracks_results[int(select)])
|
play_track(track=tracks_results[int(select)])
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue