funapi / routes /ytApi /getFull.py
imperialwool's picture
???
7814f6f
raw
history blame
No virus
1.3 kB
import ffmpeg
from .get import *
from .. import helpers
def getFull(request):
answer = get(request, "full")
try:
if answer['status'] == "error": return answer
if answer['error']: return answer
except KeyError: pass
except Exception as e: return {"status": "error", "details": { "error_code": 123, "error_details": e }}
urlcode = answer['urlcode']
bitrate = answer['bitrate']
quality = answer['quality']
error_code = answer['ytdlp-code']
config = helpers.configFile()
if answer['done-or-not']:
return {"status": "pass", "details": {"code": error_code, "name":"{}.ogg".format(urlcode), "result": f"{config['url']}/static/full/{urlcode}.ogg"}}
try:
audio_input = ffmpeg.input(answer['path'])
audio_output = ffmpeg.output(audio_input.audio, f"{config['full-path']}/{urlcode}.ogg", audio_bitrate=bitrate)
ffmpeg.run(audio_output)
helpers.deleteAudio(f"temp/{urlcode}.ogg")
except Exception as e: return {"status": "error", "details": {"error_code": 102, "error_details": str(e), "result": f"{config['url']}/static/temp/{urlcode}.ogg"}}
return {"status": "pass", "details": {"code": error_code, "name":"{}.ogg".format(urlcode), "result": f"{config['url']}/static/full/{urlcode}.ogg"}}