Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/delay downloads #3360

Merged
merged 18 commits into from
Dec 15, 2017
Merged
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion medusa/search/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,8 @@ def search_for_needed_episodes(force=False):
# fail_over_delay time (hours) skipp it. For this we need to check if the result has already been
# stored in the provider cache db, and if it's still younger then the providers attribute fail_over_delay.
if cur_provider.fail_over_enabled and cur_provider.fail_over_hours:
log.debug('DELAY: Provider {provider} delay enabled, with an expiration of {delay}',
{'provider': cur_provider.name, 'delay': cur_provider.fail_over_hours})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe add hours here? or the correct unit?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ooh yeah sure.

from medusa.search.manual import get_provider_cache_results
results = get_provider_cache_results(
cur_ep.series.indexer, show_all_results=False, perform_search=False, show=cur_ep.series.indexerid,
Expand All @@ -485,13 +487,23 @@ def search_for_needed_episodes(force=False):
if first_result['date_added'] + cur_provider.fail_over_hours * 3600 > int(time.time()):
# The provider's fail over cooldown time hasn't expired yet. We're holding back the snatch.
log.debug(
u'Holding back best result {name} for provider {provider}. The provider is waiting'
u'DELAY: Holding back best result {name} for provider {provider}. The provider is waiting'
u' {fail_over_hours} hours, before accepting the release.', {'name': first_result['name'],
'provider': cur_provider.name,
'fail_over_hours': cur_provider.fail_over_hours
}
)
continue
else:
log.debug(
u'DELAY: Provider {provider}, found a result in cache, but the delay has not yet expired. '
u'Timestamp of first result: {first_result}. Time left: {left} hours',
{'provider': cur_provider.name, 'first_result': first_result['date_added'],
'left': int((int(time.time()) + (first_result['date_added'] - cur_provider.fail_over_hours * 3600)) / 3600)}
)
else:
log.debug(u'DELAY: Provider {provider}, searched cache but could not get any results for: {season}x{episode}',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you use the episode_num instead of this?

from medusa.helper.common import episode_num
episode_num(season=None, episode=None, numbering='standard'):

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also add show name

{'provider': cur_provider.name, 'season': cur_ep.season, 'episode': cur_ep.episode})

found_results[cur_ep] = best_result

Expand Down