scouring the api finished
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
3233741ab1
commit
b241245e9c
@ -68,7 +68,7 @@ api.add_resource(LoginApi, '/api/auth/login')
|
||||
api.add_resource(MeApi, '/api/auth/me')
|
||||
api.add_resource(ListsApi, '/api/lists')
|
||||
api.add_resource(SingleListApi, '/api/lists/<listid>')
|
||||
api.add_resource(TrackApi, '/api/lists/<listid>/<trackid>')
|
||||
api.add_resource(TrackApi, '/api/items/<itemid>')
|
||||
|
||||
app.add_url_rule("/healthz", "healthcheck", view_func=lambda: health.run())
|
||||
|
||||
|
@ -145,9 +145,9 @@ class SingleListApi(Resource):
|
||||
releaselist = []
|
||||
for release in currdata['release-list']:
|
||||
releasedata = {"id": release['id'], "album": release['title']}
|
||||
currlease = musicbrainzngs.get_release_by_id(release['id'], includes=['artists'])
|
||||
if 'artist-credit' in currlease['release'] and currlease['release']['artist-credit']:
|
||||
currartist = currlease['release']['artist-credit'][0]['artist']
|
||||
currrelease = musicbrainzngs.get_release_by_id(release['id'], includes=['artists'])
|
||||
if 'artist-credit' in currrelease['release'] and currrelease['release']['artist-credit']:
|
||||
currartist = currrelease['release']['artist-credit'][0]['artist']
|
||||
releasedata['artist'] = currartist['name']
|
||||
releaselist.append(releasedata)
|
||||
flaskred.set(release['id'], 'release'.encode('UTF-8'))
|
||||
@ -191,8 +191,48 @@ class SingleListApi(Resource):
|
||||
|
||||
class TrackApi(Resource):
|
||||
"""
|
||||
See: https://swagger.kmlabz.com/?urls.primaryName=onSpot%20Backend#/backend/getTrack
|
||||
See: https://swagger.kmlabz.com/?urls.primaryName=onSpot%20Backend#/backend/getItem
|
||||
"""
|
||||
encryptor = EncryptedUserRedis(ENCODED_SECRET_KEY)
|
||||
|
||||
def get(self, listid: str, trackid: str):
|
||||
pass
|
||||
def get(self, itemid: str):
|
||||
try:
|
||||
currcreds = self.encryptor.load(flaskred.get(request.headers.get('Authorization')).decode('UTF-8'))
|
||||
except Exception as e:
|
||||
current_app.logger.warning(e)
|
||||
abort(401, "unauthorized")
|
||||
try:
|
||||
item_type = flaskred.get(itemid).decode('UTF-8')
|
||||
except Exception as e:
|
||||
current_app.logger.warning(e)
|
||||
abort(404, "unknown list")
|
||||
musicbrainzngs.auth(currcreds['name'], currcreds['password'])
|
||||
|
||||
if item_type == 'release':
|
||||
currrelease = musicbrainzngs.get_release_by_id(itemid, includes=['artists'])['release']
|
||||
print(currrelease)
|
||||
retdata = {"id": itemid, "album": currrelease['title']}
|
||||
if 'artist-credit' in currrelease and currrelease['artist-credit']:
|
||||
retdata['artist'] = currrelease['artist-credit'][0]['artist']['name']
|
||||
elif item_type == 'artist':
|
||||
currartist = musicbrainzngs.get_artist_by_id(itemid)['artist']
|
||||
retdata = {"id": itemid, "artist": currartist['name']}
|
||||
elif item_type == 'work':
|
||||
currwork = musicbrainzngs.get_work_by_id(itemid)['work']
|
||||
retdata = {"id": itemid, "title": currwork['title']}
|
||||
elif item_type == 'recording':
|
||||
currrecording = musicbrainzngs.get_recording_by_id(itemid, includes=['artists', 'releases'])['recording']
|
||||
retdata = {"id": itemid, "title": currrecording['title']}
|
||||
if 'artist-credit' in currrecording and currrecording['artist-credit']:
|
||||
currartist = currrecording['artist-credit'][0]['artist']
|
||||
retdata['artist'] = currartist['name']
|
||||
if 'release-list' in currrecording and currrecording['release-list']:
|
||||
currrlease = currrecording['release-list'][0]
|
||||
retdata['album'] = currrlease['title']
|
||||
else:
|
||||
abort(417, "wrong type of item")
|
||||
|
||||
musicbrainzngs.auth(None, None)
|
||||
|
||||
retdata['type'] = item_type
|
||||
return retdata, 200
|
||||
|
Loading…
Reference in New Issue
Block a user