mirror of
https://gitea.phreedom.club/localhost_frssoft/funkwlmpv
synced 2024-12-22 18:23:34 +02:00
added related libraries track info
This commit is contained in:
parent
bcd6c220f3
commit
f4b029630d
2 changed files with 23 additions and 1 deletions
|
@ -274,6 +274,20 @@ def list_libraries(page=None, page_size=None, q=None, scope='all', pg=None):
|
|||
return r.json()
|
||||
|
||||
|
||||
@logger.catch
|
||||
def assigned_libraries_on_track(track_id, page=None, page_size=None, pg=None):
|
||||
params = {
|
||||
'page': page,
|
||||
'page_size': page_size,
|
||||
}
|
||||
if pg:
|
||||
r = current_instance.s.get(pg)
|
||||
else:
|
||||
r = current_instance.s.get(
|
||||
f'https://{current_instance.instance}/api/v1/tracks/{track_id}/libraries', params=params)
|
||||
return r.json()
|
||||
|
||||
|
||||
@logger.catch
|
||||
def get_tags(q=None, ordering='-creation_date', pg=None):
|
||||
params = {
|
||||
|
|
10
src/utils.py
10
src/utils.py
|
@ -63,10 +63,18 @@ def track_info_output(track):
|
|||
if k not in ('cover', 'uploads', 'listen_url', 'mbid', 'id', 'is_playable') and v is not None and v != []:
|
||||
if isinstance(v, dict):
|
||||
for i in ('title', 'name', 'fid'):
|
||||
if v.get(i):
|
||||
if v.get(i):
|
||||
val_override = v.get(i)
|
||||
output.append(f'{k}: {val_override}')
|
||||
else:
|
||||
output.append(f'{k}: {v}')
|
||||
output.append('Related Libraries:')
|
||||
try:
|
||||
assigned_libs = src.fw_api.assigned_libraries_on_track(track['id'])['results']
|
||||
for i in assigned_libs:
|
||||
for prop in ('fid', 'name', 'description', 'creation_date'):
|
||||
output.append(i.get(prop))
|
||||
except:
|
||||
output.append('Failed get related')
|
||||
output = '\n'.join(output)
|
||||
os.system(f'less <<EOF\n{output}\nEOF')
|
||||
|
|
Loading…
Reference in a new issue