[AO3Bridge] Add fetch limit to reduce requests (#4328)

This commit is contained in:
July 2024-11-23 12:47:08 -05:00 committed by GitHub
parent 6c86e2c1f7
commit 2294dac3f1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -27,6 +27,7 @@ class AO3Bridge extends BridgeAbstract
'Entire work' => 'all',
],
],
'limit' => self::LIMIT,
],
'Bookmarks' => [
'user' => [
@ -84,6 +85,8 @@ class AO3Bridge extends BridgeAbstract
}
$this->title = $heading->plaintext;
$limit = $this->getInput('limit') ?? 3;
$count = 0;
foreach ($html->find('.index.group > li') as $element) {
$item = [];
@ -118,7 +121,7 @@ class AO3Bridge extends BridgeAbstract
$item['uid'] = $item['uri'] . "/$strdate/$chapters";
// Fetch workskin of desired chapter(s) in list
if ($this->getInput('range')) {
if ($this->getInput('range') && ($limit == 0 || $count++ < $limit)) {
$url = $item['uri'];
switch ($this->getInput('range')) {
case ('all'):