added related libraries track info

This commit is contained in:
localhost_frssoft 2023-08-03 00:18:48 +03:00
parent bcd6c220f3
commit f4b029630d
2 changed files with 23 additions and 1 deletions

View file

@ -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 = {

View file

@ -68,5 +68,13 @@ def track_info_output(track):
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')