fix rule34 api url, guard against non-list responses
This commit is contained in:
@@ -55,7 +55,7 @@ SITES = {
|
|||||||
'post_url_fmt': 'https://yande.re/post/show/{post_id}',
|
'post_url_fmt': 'https://yande.re/post/show/{post_id}',
|
||||||
},
|
},
|
||||||
'rule34': {
|
'rule34': {
|
||||||
'base_url': 'https://rule34.xxx/',
|
'base_url': 'https://api.rule34.xxx/',
|
||||||
'endpoint': 'index.php?page=dapi&s=post&q=index&json=1',
|
'endpoint': 'index.php?page=dapi&s=post&q=index&json=1',
|
||||||
'per_page': 100,
|
'per_page': 100,
|
||||||
'threads': 20,
|
'threads': 20,
|
||||||
@@ -83,6 +83,8 @@ def fetch_all_posts(adapter, query, auth, limit):
|
|||||||
r.raise_for_status()
|
r.raise_for_status()
|
||||||
data = r.json()
|
data = r.json()
|
||||||
batch = data[adapter['envelope']] if adapter['envelope'] else data
|
batch = data[adapter['envelope']] if adapter['envelope'] else data
|
||||||
|
if not isinstance(batch, list):
|
||||||
|
raise RuntimeError(f'API returned unexpected response: {batch!r}')
|
||||||
if not batch:
|
if not batch:
|
||||||
break
|
break
|
||||||
posts.extend(batch)
|
posts.extend(batch)
|
||||||
|
|||||||
Reference in New Issue
Block a user