From 3b1e2120552f4e65ac4fdc519f2aa5dabd66f058 Mon Sep 17 00:00:00 2001 From: xenofem Date: Mon, 1 Apr 2024 22:47:07 -0400 Subject: [PATCH] complain during fetch if a dlsite work isn't a manga or CG --- dlibrary/dlibrary.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/dlibrary/dlibrary.py b/dlibrary/dlibrary.py index 08288a1..e4d8867 100755 --- a/dlibrary/dlibrary.py +++ b/dlibrary/dlibrary.py @@ -18,7 +18,7 @@ import unicodedata from urllib.parse import urlparse import zipfile -from dlsite_async import DlsiteAPI +import dlsite_async import fitz from libsixel import * from PIL import Image @@ -207,6 +207,8 @@ def manual_input_metadata(work_id): } async def fetch_async(args): + any_warnings = False + con = sqlite3.connect(args.destdir / 'meta.db') cur = con.cursor() @@ -217,7 +219,7 @@ async def fetch_async(args): thumbnails_dir = args.destdir / 'site' / 'thumbnails' thumbnails_dir.mkdir(parents=True, exist_ok=True) - async with DlsiteAPI(locale=args.locale) as api: + async with dlsite_async.DlsiteAPI(locale=args.locale) as api: for work_path in (args.destdir / 'extract').iterdir(): work_id = work_path.name @@ -228,6 +230,10 @@ async def fetch_async(args): if DLSITE_ID_REGEX.fullmatch(work_id): print(f'Fetching DLSite metadata for {work_id}') dlsite_metadata = await api.get_work(work_id) + if dlsite_metadata.work_type not in [dlsite_async.WorkType.MANGA, dlsite_async.WorkType.CG_ILLUSTRATIONS]: + print(f'Work {work_id} is not a manga or CG set, skipping') + any_warnings = True + continue db_row = { "id": work_id, "title": dlsite_metadata.work_name, @@ -287,12 +293,14 @@ async def fetch_async(args): con.close() + return any_warnings + def url_file_ext(url): return splitext(urlparse(url).path)[1] def fetch(args): - asyncio.run(fetch_async(args)) - if args.auto: + any_warnings = asyncio.run(fetch_async(args)) + if args.auto and not any_warnings: parser_collate.parse_args(args=[], namespace=args) collate(args)