Skip to content

Commit

Permalink
Ensure user specified domain_delay overrides any built in limiters.
Browse files Browse the repository at this point in the history
  • Loading branch information
gazpachoking committed Nov 19, 2023
1 parent e9a39a6 commit 8e05b8b
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 9 deletions.
3 changes: 1 addition & 2 deletions flexget/components/sites/sites/awesomehd.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ def search(self, task, entry, config):
config = self.prepare_config(config)

# set a domain limit, but allow the user to overwrite it
if 'awesome-hd.me' not in task.requests.domain_limiters:
task.requests.add_domain_limiter(TimedLimiter('awesome-hd.me', '5 seconds'))
task.requests.add_domain_limiter(TimedLimiter('awesome-hd.me', '5 seconds'), replace=False)

entries = set()

Expand Down
2 changes: 1 addition & 1 deletion flexget/components/sites/sites/btn.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def prepare_config(self, config):
return config

def search(self, task, entry, config):
task.requests.add_domain_limiter(self.request_limiter)
task.requests.add_domain_limiter(self.request_limiter, replace=False)
config = self.prepare_config(config)
api_key = config['api_key']

Expand Down
6 changes: 2 additions & 4 deletions flexget/components/sites/sites/iptorrents.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,8 @@ def search(self, task, entry, config=None):

entries = set()

if not task.requests.domain_limiters.get(DOMAIN, None):
logger.debug('limiting requests with a delay of {}', DELAY)
rate_limiter = requests.TokenBucketLimiter(DOMAIN, 1, DELAY, True)
task.requests.add_domain_limiter(rate_limiter)
rate_limiter = requests.TokenBucketLimiter(DOMAIN, 1, DELAY, True)
task.requests.add_domain_limiter(rate_limiter, replace=False)

for search_string in entry.get('search_strings', [entry['title']]):
search_params = dict(category_params.items())
Expand Down
4 changes: 3 additions & 1 deletion flexget/components/sites/sites/passthepopcorn.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,9 @@ def search(self, task, entry, config):
f"Searching for '{entry['title']}' ignoring non numeric movie_year: '{entry['movie_year']}'"
)

task.requests.add_domain_limiter(TimedLimiter('passthepopcorn.me', '5 seconds'))
task.requests.add_domain_limiter(
TimedLimiter('passthepopcorn.me', '5 seconds'), replace=False
)

for search_string in search_strings:
params['searchstr'] = search_string
Expand Down
2 changes: 1 addition & 1 deletion flexget/plugins/operate/domain_delay.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class DomainDelay:
def on_task_start(self, task, config):
for domain, delay in config.items():
logger.debug('Adding minimum interval of {} between requests to {}', delay, domain)
task.requests.add_domain_limiter(TimedLimiter(domain, delay))
task.requests.add_domain_limiter(TimedLimiter(domain, delay), replace=True)


@event('plugin.register')
Expand Down

0 comments on commit 8e05b8b

Please sign in to comment.