fresh start

This commit is contained in:
2026-01-08 22:07:03 +01:00
commit 715be97289
30 changed files with 2302 additions and 0 deletions

29
downloadHelper.py Normal file
View File

@@ -0,0 +1,29 @@
import os
import shutil
import aiohttp
from exceptions import DOWNLOAD_FAIL
async def downloadFileToMemory(url, session : aiohttp.ClientSession):
print("Downloading", url)
try:
async with session.get(url) as resp:
result = await resp.read()
if len(result) == 0:
raise DOWNLOAD_FAIL("received 0 bytes")
else:
return result
except Exception as e:
print(url, e)
raise DOWNLOAD_FAIL(e)
async def save_to_file(url, out_file, session):
file_bytes = await downloadFileToMemory(url, session)
if os.path.exists(out_file):
shutil.copy(out_file, out_file + "_bck")
with open(out_file, "wb") as binary_file:
binary_file.write(file_bytes)
return file_bytes