mirror of
https://codeberg.org/ashley/poke.git
synced 2024-11-23 10:08:07 +01:00
stop writing bundler output to disk
This commit is contained in:
parent
08271eb2b4
commit
6dafa572a4
1 changed files with 56 additions and 40 deletions
|
@ -16,6 +16,22 @@ def get_random_string(length):
|
||||||
result_str = "".join(random.choice(letters) for i in range(length))
|
result_str = "".join(random.choice(letters) for i in range(length))
|
||||||
return result_str
|
return result_str
|
||||||
|
|
||||||
|
async def run_command(cmd):
|
||||||
|
# Create subprocess
|
||||||
|
process = await asyncio.create_subprocess_shell(
|
||||||
|
cmd,
|
||||||
|
stdout=asyncio.subprocess.PIPE,
|
||||||
|
)
|
||||||
|
# Wait for the subprocess to finish
|
||||||
|
stdout, stderr = await process.communicate()
|
||||||
|
# Check for errors
|
||||||
|
if process.returncode!= 0:
|
||||||
|
# Log or handle the error
|
||||||
|
print(f"Command '{args}' failed with return code {process.returncode}")
|
||||||
|
return None
|
||||||
|
# Decode stdout and return
|
||||||
|
return stdout
|
||||||
|
|
||||||
async def merge(request):
|
async def merge(request):
|
||||||
# register params
|
# register params
|
||||||
job_id = request.rel_url.query["id"]
|
job_id = request.rel_url.query["id"]
|
||||||
|
@ -36,15 +52,15 @@ async def merge(request):
|
||||||
return web.FileResponse(
|
return web.FileResponse(
|
||||||
path=f"{job_id}.mp4"
|
path=f"{job_id}.mp4"
|
||||||
)
|
)
|
||||||
cmdline = f"ffmpeg -i \"https://eu-proxy.poketube.fun/latest_version?id={video_id}&itag={audio_itag}&local=true\" -i \"https://eu-proxy.poketube.fun/latest_version?id={video_id}&itag={video_itag}&local=true\" -c copy -f mp4 -movflags frag_keyframe+empty_moov {video_id}.mp4"
|
cmdline = f"ffmpeg -i \"https://eu-proxy.poketube.fun/latest_version?id={video_id}&itag={audio_itag}&local=true\" -i \"https://eu-proxy.poketube.fun/latest_version?id={video_id}&itag={video_itag}&local=true\" -c copy -f mp4 -movflags frag_keyframe+empty_moov -"
|
||||||
proc_ffmpeg = await asyncio.create_subprocess_shell(
|
#proc_ffmpeg = await asyncio.create_subprocess_shell(
|
||||||
cmdline,
|
# cmdline,
|
||||||
stdout=asyncio.subprocess.PIPE,
|
# stdout=asyncio.subprocess.PIPE
|
||||||
stderr=asyncio.subprocess.PIPE
|
#)
|
||||||
)
|
#print(f"ffmpeg -i \"https://eu-proxy.poketube.fun/latest_version?id={video_id}&itag={audio_itag}&local=true\" -i \"https://eu-proxy.poketube.fun/latest_version?id={video_id}&itag={video_itag}&local=true\" -c copy -f mp4 -movflags frag_keyframe+empty_moov -")
|
||||||
print(f"ffmpeg -i \"https://eu-proxy.poketube.fun/latest_version?id={video_id}&itag={audio_itag}&local=true\" -i \"https://eu-proxy.poketube.fun/latest_version?id={video_id}&itag={video_itag}&local=true\" -c copy -f mp4 -movflags frag_keyframe+empty_moov -")
|
#stdout, _ = await proc_ffmpeg.communicate()
|
||||||
stdout, stderr = await proc_ffmpeg.communicate()
|
iwannakillmyself = await run_command(cmdline)
|
||||||
response = FileResponse(f"{video_id}.mp4")
|
response = Response(body=iwannakillmyself, content_type="video/mp4", headers="")
|
||||||
return response
|
return response
|
||||||
|
|
||||||
async def ping(request):
|
async def ping(request):
|
||||||
|
|
Loading…
Reference in a new issue