def get_music(artist, album, title):
'''Get a track tags or download it'''
page_format = request.args.get('format', 'html')
artist = unquote(artist)
album = unquote(album)
title = unquote(title)
collection = app.config['COLLECTION']
mf = MusicFilter(artists=[artist], albums=[album], titles=[title])
musics = webfilter(partial(collection.filter, cursor_factory=RealDictCursor), mf)
if len(musics) != 1:
return ('Music not found', 404)
music = musics[0]
if page_format == 'html':
return render_template("music.html", music=music)
elif page_format == 'json':
return dumps(music, sort_keys=True, indent=4, separators=(',', ': '))
return ('Invalid format, available: json,html', 400)
评论列表
文章目录