properly figure out correct thumbnail url for fanza

main
xenofem 2024-03-22 21:28:54 -04:00
parent 158565e5a0
commit 566b934ca1
1 changed files with 10 additions and 1 deletions

View File

@ -229,7 +229,16 @@ async def fetch_async(args):
authors = db_row.pop('authors')
tags = db_row.pop('tags')
if FANZA_ID_REGEX.fullmatch(work_id):
thumbnail_url = f'https://doujin-assets.dmm.co.jp/digital/comic/{work_id}/{work_id}pl.jpg'
candidate_urls = [
f'https://doujin-assets.dmm.co.jp/digital/{work_type}/{work_id}/{work_id}pl.jpg'
for work_type in ['comic', 'cg']
]
thumbnail_url = None
for url in candidate_urls:
h = requests.head(url, allow_redirects=False)
if h.status_code == 200:
thumbnail_url = url
break
elif FAKKU_ID_REGEX.fullmatch(work_id):
thumbnail_url = None
else: