Better logging
This commit is contained in:
1 parent
c026685b59
commit
a84f87c906
7 files changed
+59
-39
No files matched your search
@@ -1,3 +1,5 @@
|
||||
# main.py
|
||||
|
||||
import argparse
|
||||
import configparser
|
||||
import json
|
||||
@@ -71,15 +73,22 @@ def write_to_cache(manga: Manga) -> None:
|
||||
|
||||
def parse_cache(cache: dict) -> list[Manga]:
|
||||
if not cache:
|
||||
print("Cache is empty!")
|
||||
print("[yellow]Cache is empty![/yellow]", flush=True)
|
||||
exit()
|
||||
else:
|
||||
manga = list()
|
||||
for entry in cache.values():
|
||||
manga.append(
|
||||
Manga(parse_provider(s, entry.get("url")), entry.get("cached")) # type: ignore
|
||||
)
|
||||
return manga
|
||||
|
||||
total = len(cache)
|
||||
print(f"[bold cyan]Found {total} manga in cache. Fetching metadata...[/bold cyan]", flush=True)
|
||||
|
||||
manga = []
|
||||
for idx, (series_name, entry) in enumerate(cache.items(), start=1):
|
||||
print(f"[{idx}/{total}] Fetching info for: [bold]{series_name}[/bold]...", flush=True)
|
||||
provider = parse_provider(s, entry.get("url"))
|
||||
if provider:
|
||||
manga.append(Manga(provider, entry.get("cached", [])))
|
||||
else:
|
||||
print(f"[red]Failed to parse provider for:[/] {series_name}", flush=True)
|
||||
|
||||
return manga
|
||||
|
||||
|
||||
def get_cached_manga() -> list[Manga]:
|
||||
@@ -136,7 +145,12 @@ def main():
|
||||
else:
|
||||
list_of_manga = choose_manga()
|
||||
|
||||
print(f"[bold green]Starting check/download run for {len(list_of_manga)} manga...[/bold green]", flush=True)
|
||||
|
||||
for manga in list_of_manga:
|
||||
series = manga.info.get("series", "Unknown")
|
||||
print(f"\n[bold]Checking:[/] {series}", flush=True)
|
||||
|
||||
manga.choose_chapters(args.auto)
|
||||
manga.download(save_dir)
|
||||
write_to_cache(manga)
|
||||
|
||||
Reference in new issue
Block a user