Przeglądaj źródła

Export archive download/analysis to a function

jherve 1 rok temu
rodzic
commit
4ea9edc9ed
1 zmienionych plików z 9 dodań i 4 usunięć
  1. 9 4
      src/de_quoi_parle_le_monde/main.py

+ 9 - 4
src/de_quoi_parle_le_monde/main.py

@@ -92,10 +92,8 @@ class ArchiveDownloader:
             return
 
 
-async def main():
-    http_client = HttpClient()
-    storage = await Storage.create()
-    dts = ArchiveDownloader.last_n_days_at_hours(10, [18])
+async def download_all(http_client: HttpClient, storage: Storage, n_days: int, hours: list[int]):
+    dts = ArchiveDownloader.last_n_days_at_hours(n_days, hours)
 
     async with http_client.session() as session:
         ia = InternetArchiveClient(session)
@@ -106,4 +104,11 @@ async def main():
         )
 
 
+async def main():
+    http_client = HttpClient()
+    storage = await Storage.create()
+
+    await download_all(http_client, storage, 10, [18])
+
+
 asyncio.run(main())