Don't run aria2c under asyncio, further improve progress updates

I've removed asyncio usage as it's generally unnecessary. If you want to run aria2c under a thread, run it under a thread. In the case for devine, this would take another thread, and would be another thread layer deep. Pointless. Would affect speed.

With this change I've been able to improve the aria2c progress capture code quite a bit.
This commit is contained in:
rlaphoenix
2023-02-28 08:18:30 +00:00
parent d427ec8472
commit ce53a1b636
4 changed files with 54 additions and 73 deletions

View File

@@ -1,6 +1,5 @@
from __future__ import annotations
import asyncio
import logging
import re
import sys
@@ -289,13 +288,13 @@ class HLS:
segment_save_path.parent.mkdir(parents=True, exist_ok=True)
segment_save_path.write_bytes(res.content)
else:
asyncio.run(aria2c(
segment.uri,
segment_save_path,
session.headers,
proxy,
aria2c(
uri=segment.uri,
out=segment_save_path,
headers=session.headers,
proxy=proxy,
silent=True
))
)
data_size = segment_save_path.stat().st_size