From 309f19574d348b228bc23ba1b6b0f305c2da4a11 Mon Sep 17 00:00:00 2001 From: xenofem Date: Mon, 29 Jan 2024 03:01:35 -0500 Subject: [PATCH] don't try to fetch dlsite metadata for non-dlsite works --- dlibrary/dlibrary.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/dlibrary/dlibrary.py b/dlibrary/dlibrary.py index 3d49ca0..acc71b0 100755 --- a/dlibrary/dlibrary.py +++ b/dlibrary/dlibrary.py @@ -20,6 +20,8 @@ import requests NUMBER_REGEX = re.compile('[0-9]+') +DLSITE_ID_REGEX = re.compile('^[BR]J[0-9]+$') + IMAGE_FILE_EXTENSIONS = ['.png', '.jpg', '.jpeg', '.gif', '.tiff'] IGNOREABLE_FILES = ['Thumbs.db', '__MACOSX', '.DS_Store'] @@ -69,6 +71,10 @@ async def fetch_async(args): if res.fetchone() is not None: continue + if not DLSITE_ID_REGEX.fullmatch(work_id): + print(f"{work_id} doesn't seem to be from DLSite, not attempting to fetch metadata") + continue + print(f'Fetching metadata for {work_id}') metadata = await api.get_work(work_id)