mirror of
https://github.com/Xevion/v1.xevion.dev.git
synced 2025-12-06 05:16:59 -06:00
remove decode, proper return application/json mimetype, fix url being null
should have put in the url filling a long time ago, I just didn't wanna open up the massive JSON response and locate the key required. also, with this I'll have to clear the databases with new URLs (or maybe I should refresh all metadata?)
This commit is contained in:
@@ -60,7 +60,7 @@ def status(service, mediaid):
|
||||
else:
|
||||
return Response('Invalid ID', status=400, mimetype='text/plain')
|
||||
else:
|
||||
return Response(audio.toJSON(), status=200, mimetype='text/plain')
|
||||
return Response(audio.toJSON(), status=200, mimetype='application/json')
|
||||
elif service == 'soundcloud':
|
||||
return Response('Not implemented', status=501, mimetype='text/plain')
|
||||
elif service == 'spotify':
|
||||
|
||||
@@ -39,9 +39,10 @@ class YouTubeAudio(db.Model):
|
||||
print(f'Filename acquired for {self.id}')
|
||||
processJSON = subprocess.Popen(f'youtube-dl -4 -x --audio-format mp3 --restrict-filenames --dump-json {self.id}'.split(' '),
|
||||
encoding='utf-8', stdout=subprocess.PIPE)
|
||||
data = json.loads(processJSON.communicate()[0].decode())
|
||||
data = json.loads(processJSON.communicate()[0])
|
||||
print(f'JSON acquired for {self.id}, beginning to fill.')
|
||||
self.duration = data['duration']
|
||||
self.url = data['webpage_url'] # Could be created, but we'll just infer from JSON response
|
||||
self.creator = data['creator'] or data['uploader']
|
||||
self.uploader = data['uploader'] or data['creator']
|
||||
self.title = data['title'] or data['alt_title'] # Do not trust alt-title ; it is volatile and uploader set, e.x. https://i.imgur.com/Tgff4rI.png
|
||||
|
||||
Reference in New Issue
Block a user