This commit is contained in:
parent
ed08fd3cbb
commit
95be4734a8
@ -12,7 +12,7 @@ services:
|
||||
- ONSPOT_REDIS_URL="redis://db:6379/0"
|
||||
- ONSPOT_ENCODED_SECRET_KEY="emdlc2RmYnZoa2xyYWl3ZmJkdmtzZ2Vhd2ZiaWx2a3M="
|
||||
ports:
|
||||
- "127.0.0.1:6379:6379"
|
||||
- "127.0.0.1:8080:8080"
|
||||
networks:
|
||||
- backend
|
||||
db:
|
||||
|
@ -14,7 +14,7 @@ __version__text__ = "1"
|
||||
|
||||
def get_standard_error_handler(code: int):
|
||||
def error_handler(err):
|
||||
musicbrainzngs.user(None, None)
|
||||
musicbrainzngs.auth(None, None)
|
||||
return {"msg": str(err)}, code
|
||||
|
||||
return error_handler
|
||||
|
@ -41,7 +41,7 @@ class LoginApi(Resource):
|
||||
|
||||
try:
|
||||
musicbrainzngs.auth(userobj['name'], userobj['password'])
|
||||
musicbrainzngs.get_collections()
|
||||
print(musicbrainzngs.get_collections())
|
||||
musicbrainzngs.auth(None, None)
|
||||
except Exception as e:
|
||||
current_app.logger.warning(e)
|
||||
@ -87,14 +87,45 @@ class ListsApi(Resource):
|
||||
"""
|
||||
See: https://swagger.kmlabz.com/?urls.primaryName=onSpot%20Backend#/backend/getAllLists
|
||||
"""
|
||||
encryptor = EncryptedUserRedis(ENCODED_SECRET_KEY)
|
||||
|
||||
def get(self):
|
||||
pass
|
||||
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")
|
||||
|
||||
musicbrainzngs.auth(currcreds['name'], currcreds['password'])
|
||||
collections = musicbrainzngs.get_collections()
|
||||
musicbrainzngs.auth(None, None)
|
||||
elementlist = []
|
||||
for collection in collections['collection-list']:
|
||||
if collection['entity-type'] == 'release':
|
||||
count = collection['release-count']
|
||||
elif collection['entity-type'] == 'artist':
|
||||
count = collection['artist-count']
|
||||
elif collection['entity-type'] == 'work':
|
||||
count = collection['work-count']
|
||||
elif collection['entity-type'] == 'recording':
|
||||
count = collection['recording-count']
|
||||
elif collection['entity-type'] == 'release_group':
|
||||
elementlist.append({"id": collection['id'], "name": collection['name']})
|
||||
continue
|
||||
else:
|
||||
continue
|
||||
elementlist.append({"id": collection['id'], "name": collection['name'], "element_count": count})
|
||||
returndict = {"count": collections['collection-count'],
|
||||
"ids": elementlist}
|
||||
|
||||
return returndict, 200
|
||||
|
||||
|
||||
class SingleListApi(Resource):
|
||||
"""
|
||||
See: https://swagger.kmlabz.com/?urls.primaryName=onSpot%20Backend#/backend/getList
|
||||
"""
|
||||
|
||||
def get(self, listid: str):
|
||||
pass
|
||||
|
||||
@ -103,5 +134,6 @@ class TrackApi(Resource):
|
||||
"""
|
||||
See: https://swagger.kmlabz.com/?urls.primaryName=onSpot%20Backend#/backend/getTrack
|
||||
"""
|
||||
|
||||
def get(self, listid: str, trackid: str):
|
||||
pass
|
||||
|
Loading…
Reference in New Issue
Block a user