mirror of
http://gitea.phreedom.club/localhost_frssoft/funkwlmpv
synced 2024-11-24 09:41:27 +00:00
Check tracks count before return tag
This commit is contained in:
parent
859247021a
commit
c56b68bb0c
|
@ -111,12 +111,13 @@ def get_audio_file(track_uuid, listen_url=False, download=False,
|
||||||
|
|
||||||
|
|
||||||
@logger.catch
|
@logger.catch
|
||||||
def get_tracks(page=None, ordering=None, q=None,
|
def get_tracks(page=None, ordering=None, q=None, page_size=None,
|
||||||
artist=None, album=None, library=None,
|
artist=None, album=None, library=None,
|
||||||
tag=None, favourites=None, include_channels=None, pg=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,
|
||||||
|
'page_size': page_size,
|
||||||
'ordering': ordering,
|
'ordering': ordering,
|
||||||
'q': q,
|
'q': q,
|
||||||
'artist': artist,
|
'artist': artist,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from src.fw_api import get_tags
|
from src.fw_api import get_tags, get_tracks
|
||||||
from pyfzf.pyfzf import FzfPrompt
|
from pyfzf.pyfzf import FzfPrompt
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ fzf = FzfPrompt()
|
||||||
|
|
||||||
|
|
||||||
@logger.catch
|
@logger.catch
|
||||||
def list_tags(pg=None, search=None):
|
def list_tags(pg=None, search=None, error_given=''):
|
||||||
tags = get_tags(q=search, pg=pg)
|
tags = get_tags(q=search, pg=pg)
|
||||||
tags_next = tags.get('next')
|
tags_next = tags.get('next')
|
||||||
tags_prev = tags.get('previous')
|
tags_prev = tags.get('previous')
|
||||||
|
@ -21,7 +21,7 @@ def list_tags(pg=None, search=None):
|
||||||
index = tags_results.index(i)
|
index = tags_results.index(i)
|
||||||
tag_name = i.get('name')
|
tag_name = i.get('name')
|
||||||
view.append(f'{index}.{tag_name}')
|
view.append(f'{index}.{tag_name}')
|
||||||
select = fzf.prompt(view)[0].split('.', 1)[0]
|
select = fzf.prompt(view, f"--header=\'{error_given}\'")[0].split('.', 1)[0]
|
||||||
if select == 'Next page':
|
if select == 'Next page':
|
||||||
return list_tags(pg=tags_next)
|
return list_tags(pg=tags_next)
|
||||||
elif select == 'Prev page':
|
elif select == 'Prev page':
|
||||||
|
@ -30,4 +30,7 @@ def list_tags(pg=None, search=None):
|
||||||
print('Search by tag:')
|
print('Search by tag:')
|
||||||
return list_tags(search=input())
|
return list_tags(search=input())
|
||||||
else:
|
else:
|
||||||
return tags_results[int(select)].get('name')
|
selected_tag = tags_results[int(select)].get('name')
|
||||||
|
if get_tracks(tag=selected_tag, page_size=1)['count'] == 0:
|
||||||
|
return list_tags(pg=pg, search=search, error_given='This tag no contain tracks, select another')
|
||||||
|
return selected_tag
|
||||||
|
|
Loading…
Reference in a new issue