mirror of
https://github.com/Xevion/v1.xevion.dev.git
synced 2025-12-06 05:16:59 -06:00
status modifications with new validation and JSONifiation methods
This commit is contained in:
15
app/sound.py
15
app/sound.py
@@ -11,7 +11,7 @@ import subprocess
|
||||
# Retrieves the YouTubeAudio object relevant to the mediaid if available. If not, it facilitiates the creation and writing of one.
|
||||
# Also helps with access times.
|
||||
def get_youtube(mediaid):
|
||||
audio = YouTubeAudio.query.filter_by(id=mediaid).first()
|
||||
audio = YouTubeAudio.query.get(mediaid)
|
||||
if audio is not None:
|
||||
return audio # sets the access time to now
|
||||
audio = YouTubeAudio(id=mediaid)
|
||||
@@ -48,12 +48,19 @@ def duration(service, mediaid):
|
||||
else:
|
||||
return Response('Bad request', status=400, mimetype='text/plain')
|
||||
|
||||
# Returns the duration of a specific media
|
||||
# Returns a detailed JSON export of a specific database entry.
|
||||
# Will not create a new database entry where one didn't exist before.
|
||||
@app.route('/status/<service>/<mediaid>')
|
||||
def status(service, mediaid):
|
||||
if service == 'youtube':
|
||||
audio = get_youtube(mediaid).duration
|
||||
return Response(str(duration), status=200, mimetype='text/plain')
|
||||
audio = YouTubeAudio.query.get(mediaid)
|
||||
if audio is None:
|
||||
if YouTubeAudio.isValid(mediaid):
|
||||
return Response('Media not yet downloaded', status=400, mimetype='text/plain')
|
||||
else:
|
||||
return Response('Invalid ID', status=400, mimetype='text/plain')
|
||||
else:
|
||||
return Response(audio.toJSON(), status=200, mimetype='text/plain')
|
||||
elif service == 'soundcloud':
|
||||
return Response('Not implemented', status=501, mimetype='text/plain')
|
||||
elif service == 'spotify':
|
||||
|
||||
Reference in New Issue
Block a user