From ad3c24f95027a2f6c60b390d56033fa1d1effd3f Mon Sep 17 00:00:00 2001 From: Ruud Date: Sun, 30 Jun 2013 13:17:43 +0200 Subject: [PATCH] Improved "too early to search" calculations --- couchpotato/core/plugins/dashboard/main.py | 4 ++-- couchpotato/core/plugins/searcher/main.py | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/couchpotato/core/plugins/dashboard/main.py b/couchpotato/core/plugins/dashboard/main.py index 9836ef9..41d3551 100644 --- a/couchpotato/core/plugins/dashboard/main.py +++ b/couchpotato/core/plugins/dashboard/main.py @@ -70,9 +70,9 @@ class Dashboard(Plugin): coming_soon = False # Theater quality - if pp.get('theater') and fireEvent('searcher.could_be_released', True, eta, single = True): + if pp.get('theater') and fireEvent('searcher.could_be_released', True, eta, movie.library.year, single = True): coming_soon = True - if pp.get('dvd') and fireEvent('searcher.could_be_released', False, eta, single = True): + if pp.get('dvd') and fireEvent('searcher.could_be_released', False, eta, movie.library.year, single = True): coming_soon = True # Skip if movie is snatched/downloaded/available diff --git a/couchpotato/core/plugins/searcher/main.py b/couchpotato/core/plugins/searcher/main.py index 71077db..cc2774a 100644 --- a/couchpotato/core/plugins/searcher/main.py +++ b/couchpotato/core/plugins/searcher/main.py @@ -8,6 +8,7 @@ from couchpotato.core.logger import CPLog from couchpotato.core.plugins.base import Plugin from couchpotato.core.settings.model import Movie, Release, ReleaseInfo from couchpotato.environment import Env +from datetime import date from inspect import ismethod, isfunction from sqlalchemy.exc import InterfaceError import datetime @@ -164,7 +165,7 @@ class Searcher(Plugin): ret = False for quality_type in movie['profile']['types']: - if not self.conf('always_search') and not self.couldBeReleased(quality_type['quality']['identifier'] in pre_releases, release_dates): + if not self.conf('always_search') and not self.couldBeReleased(quality_type['quality']['identifier'] in pre_releases, release_dates, movie['library']['year']): too_early_to_search.append(quality_type['quality']['identifier']) continue @@ -558,11 +559,12 @@ class Searcher(Plugin): return False - def couldBeReleased(self, is_pre_release, dates): + def couldBeReleased(self, is_pre_release, dates, year = None): now = int(time.time()) + now_year = date.today().year - if not dates or (dates.get('theater', 0) == 0 and dates.get('dvd', 0) == 0): + if (year is None or year < now_year - 1) and (not dates or (dates.get('theater', 0) == 0 and dates.get('dvd', 0) == 0)): return True else: