Commit e39f7d88 authored by echel0n's avatar echel0n

Moved RSS cache updates to separate background task that executes every 15 minutes.

Parsed search results no longer grab their show id's from TheTVDB or Trackt since we only care about shows existing in library.
Search results returned for shows not existing in library are discarded.
parent 1207d889
......@@ -22,6 +22,5 @@ build:
- docker push $CONTAINER_IMAGE:latest
only:
- master
- develop
except:
- tags
\ No newline at end of file
# Changelog
- * 5b77ef1 - 2019-02-20: Release v9.4.61
- * 5ac1202 - 2019-02-23: Moved RSS cache updates to separate background task that executes every 15 minutes. Parsed search results no longer grab their show id's from TheTVDB or Trackt since we only care about shows existing in library. Search results returned for shows not existing in library are discarded.
- * 724fc6b - 2019-02-20: Release v9.4.61
- * 9467ad1 - 2019-02-20: Release v9.4.60
- * e9b99d5 - 2019-02-20: Only shows in library are cached. Calls to the API for caching provider results are now done in the background. Fixed cross-link device issues for version updater.
- * 13659fe - 2019-02-17: Release v9.4.59
......
......@@ -67,6 +67,7 @@ from sickrage.core.searchers.subtitle_searcher import SubtitleSearcher
from sickrage.core.searchers.trakt_searcher import TraktSearcher
from sickrage.core.tv.show import TVShow
from sickrage.core.ui import Notifications
from sickrage.core.updaters.rsscache_updater import RSSCacheUpdater
from sickrage.core.updaters.show_updater import ShowUpdater
from sickrage.core.updaters.tz_updater import TimeZoneUpdater
from sickrage.core.upnp import UPNPClient
......@@ -143,6 +144,7 @@ class Core(object):
self.version_updater = None
self.show_updater = None
self.tz_updater = None
self.rsscache_updater = None
self.daily_searcher = None
self.backlog_searcher = None
self.proper_searcher = None
......@@ -182,6 +184,7 @@ class Core(object):
self.version_updater = VersionUpdater()
self.show_updater = ShowUpdater()
self.tz_updater = TimeZoneUpdater()
self.rsscache_updater = RSSCacheUpdater()
self.daily_searcher = DailySearcher()
self.failed_snatch_searcher = FailedSnatchSearcher()
self.backlog_searcher = BacklogSearcher()
......@@ -374,6 +377,16 @@ class Core(object):
id=self.show_updater.name
)
# add rss cache updater job
self.scheduler.add_job(
self.rsscache_updater.run,
IntervalTrigger(
minutes=15,
),
name=self.rsscache_updater.name,
id=self.rsscache_updater.name
)
# add daily search job
self.scheduler.add_job(
self.daily_searcher.run,
......
......@@ -63,9 +63,9 @@ class TVCache(object):
def check_item(self, title, url):
return True
def update(self):
def update(self, force=False):
# check if we should update
if self.should_update():
if self.should_update() or force:
try:
data = self._get_rss_data()
if not self._check_auth(data):
......@@ -168,7 +168,8 @@ class TVCache(object):
})
def should_update(self):
if sickrage.app.developer: return True
if sickrage.app.developer:
return True
# if we've updated recently then skip the update
if datetime.datetime.today() - self.last_update < datetime.timedelta(minutes=self.min_time):
......
......@@ -395,6 +395,18 @@ def findCertainShow(indexerid, return_show_object=True):
raise MultipleShowObjectsException()
def search_showlist_by_name(term):
results = [show for show in sickrage.app.showlist if show.name.lower() == term.lower()]
if not results:
return None
if len(results) == 1:
return results[0]
raise MultipleShowObjectsException()
def makeDir(path):
"""
Make a directory on the filesystem
......
......@@ -28,13 +28,13 @@ from dateutil import parser
import sickrage
from sickrage.core.common import Quality
from sickrage.core.helpers import findCertainShow, full_sanitizeSceneName, remove_extension
from sickrage.core.exceptions import MultipleShowObjectsException
from sickrage.core.helpers import findCertainShow, remove_extension, search_showlist_by_name
from sickrage.core.helpers.encoding import strip_accents
from sickrage.core.nameparser import regexes
from sickrage.core.scene_exceptions import get_scene_exception_by_name
from sickrage.core.scene_numbering import get_absolute_number_from_season_and_episode, get_indexer_absolute_numbering, \
get_indexer_numbering
from sickrage.core.traktapi import srTraktAPI
from sickrage.indexers import IndexerApi
from sickrage.indexers.exceptions import indexer_episodenotfound, indexer_error
......@@ -71,10 +71,11 @@ class NameParser(object):
def scene_exception_lookup(term):
return get_scene_exception_by_name(term)[0]
def indexer_lookup(term):
show_id1 = int(IndexerApi().searchForShowID(full_sanitizeSceneName(term))[2])
show_id2 = int(srTraktAPI()['search'].query(full_sanitizeSceneName(term), 'show')[0].ids['tvdb'])
return (None, show_id1)[show_id1 == show_id2]
def showlist_lookup(term):
try:
return search_showlist_by_name(term).indexerid
except MultipleShowObjectsException:
return None
show_names.append(strip_accents(name))
show_names.append(strip_accents(name).replace("'", " "))
......@@ -83,7 +84,7 @@ class NameParser(object):
lookup_list = [
lambda: cache_lookup(show_name),
lambda: scene_exception_lookup(show_name),
lambda: indexer_lookup(show_name),
lambda: showlist_lookup(show_name),
]
# lookup show id
......
......@@ -173,7 +173,7 @@ class DailySearchQueueItem(srQueueItem):
# give the CPU a break
time.sleep(cpu_presets[sickrage.app.config.cpu_preset])
else:
sickrage.app.log.info("No needed episodes found during daily search for: [" + self.show.name + "]")
sickrage.app.log.info("Unable to find search results for: [" + self.show.name + "]")
except Exception:
sickrage.app.log.debug(traceback.format_exc())
finally:
......@@ -241,7 +241,7 @@ class BacklogQueueItem(srQueueItem):
try:
sickrage.app.log.info("Starting backlog search for: [" + self.show.name + "]")
search_result = searchProviders(self.show, self.segment, manualSearch=False, updateCache=False)
search_result = searchProviders(self.show, self.segment, manualSearch=False)
if search_result:
for result in search_result:
# just use the first result for now
......@@ -251,8 +251,7 @@ class BacklogQueueItem(srQueueItem):
# give the CPU a break
time.sleep(cpu_presets[sickrage.app.config.cpu_preset])
else:
sickrage.app.log.info(
"No needed episodes found during backlog search for: [" + self.show.name + "]")
sickrage.app.log.info("Unable to find search results for: [" + self.show.name + "]")
except Exception:
sickrage.app.log.debug(traceback.format_exc())
finally:
......
......@@ -305,7 +305,7 @@ def isFirstBestMatch(result):
return False
def searchProviders(show, episodes, manualSearch=False, downCurQuality=False, updateCache=True, cacheOnly=False):
def searchProviders(show, episodes, manualSearch=False, downCurQuality=False, cacheOnly=False):
"""
Walk providers for information on shows
......@@ -359,10 +359,6 @@ def searchProviders(show, episodes, manualSearch=False, downCurQuality=False, up
try:
threading.currentThread().setName(origThreadName + "::[" + providerObj.name + "]")
# update provider RSS cache
if sickrage.app.config.enable_rss_cache and updateCache:
providerObj.cache.update()
if len(episodes):
if search_mode == 'eponly':
sickrage.app.log.info("Performing episode search for " + show.name)
......
import threading
import sickrage
class RSSCacheUpdater(object):
def __init__(self):
self.name = "RSSCACHE-UPDATER"
self.lock = threading.Lock()
self.amActive = False
def run(self, force=False):
if self.amActive or (not sickrage.app.config.enable_rss_cache) and not force:
return
self.amActive = True
# set thread name
threading.currentThread().setName(self.name)
for providerID, providerObj in sickrage.app.search_providers.sort().items():
if providerObj.isEnabled:
sickrage.app.log.info("Updating RSS cache for provider: [{}]".format(providerObj.name))
threading.currentThread().setName(self.name + "::[" + providerObj.name + "]")
providerObj.cache.update(force)
threading.currentThread().setName(self.name)
sickrage.app.log.info("Updated RSS cache for provider: [{}]".format(providerObj.name))
self.amActive = False
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment