complain during fetch if a dlsite work isn't a manga or CG
This commit is contained in:
parent
21ad04f478
commit
3b1e212055
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in a new issue