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() 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 @logger.catch
def get_tags(q=None, ordering='-creation_date', pg=None): def get_tags(q=None, ordering='-creation_date', pg=None):
params = { params = {

View File

@ -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 k not in ('cover', 'uploads', 'listen_url', 'mbid', 'id', 'is_playable') and v is not None and v != []:
if isinstance(v, dict): if isinstance(v, dict):
for i in ('title', 'name', 'fid'): for i in ('title', 'name', 'fid'):
if v.get(i): if v.get(i):
val_override = v.get(i) val_override = v.get(i)
output.append(f'{k}: {val_override}') output.append(f'{k}: {val_override}')
else: else:
output.append(f'{k}: {v}') 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) output = '\n'.join(output)
os.system(f'less <<EOF\n{output}\nEOF') os.system(f'less <<EOF\n{output}\nEOF')