diff --git a/couchpotato/core/media/show/searcher/episode.py b/couchpotato/core/media/show/searcher/episode.py index ace9768..7e92537 100755 --- a/couchpotato/core/media/show/searcher/episode.py +++ b/couchpotato/core/media/show/searcher/episode.py @@ -1,6 +1,6 @@ from couchpotato import fireEvent, get_db, Env from couchpotato.api import addApiView -from couchpotato.core.event import addEvent +from couchpotato.core.event import addEvent, fireEventAsync from couchpotato.core.logger import CPLog from couchpotato.core.media._base.searcher.base import SearcherBase from couchpotato.core.media._base.searcher.main import SearchSetupError @@ -19,11 +19,26 @@ class EpisodeSearcher(SearcherBase, ShowTypeBase): def __init__(self): super(EpisodeSearcher, self).__init__() + addEvent('%s.searcher.all' % self.getType(), self.searchAll) addEvent('%s.searcher.single' % self.getType(), self.single) addEvent('searcher.correct_release', self.correctRelease) + addApiView('%s.searcher.full_search' % self.getType(), self.searchAllView, docs = { + 'desc': 'Starts a full search for all wanted shows', + }) + addApiView('%s.searcher.single' % self.getType(), self.singleView) + def searchAllView(self, **kwargs): + fireEventAsync('%s.searcher.all' % self.getType(), manual = True) + + return { + 'success': not self.in_progress + } + + def searchAll(self, manual = False): + pass + def singleView(self, media_id, **kwargs): db = get_db() media = db.get('id', media_id) diff --git a/couchpotato/core/media/show/searcher/season.py b/couchpotato/core/media/show/searcher/season.py old mode 100644 new mode 100755 index 64fd263..b1fe630 --- a/couchpotato/core/media/show/searcher/season.py +++ b/couchpotato/core/media/show/searcher/season.py @@ -1,4 +1,5 @@ -from couchpotato.core.event import addEvent +from couchpotato.api import addApiView +from couchpotato.core.event import addEvent, fireEventAsync from couchpotato.core.logger import CPLog from couchpotato.core.media._base.searcher.base import SearcherBase from couchpotato.core.media.show import ShowTypeBase @@ -16,8 +17,23 @@ class SeasonSearcher(SearcherBase, ShowTypeBase): def __init__(self): super(SeasonSearcher, self).__init__() + addEvent('%s.searcher.all' % self.getType(), self.searchAll) addEvent('%s.searcher.single' % self.getType(), self.single) + addApiView('%s.searcher.full_search' % self.getType(), self.searchAllView, docs = { + 'desc': 'Starts a full search for all wanted seasons', + }) + + def searchAllView(self, **kwargs): + fireEventAsync('%s.searcher.all' % self.getType(), manual = True) + + return { + 'success': not self.in_progress + } + + def searchAll(self, manual = False): + pass + def single(self, media, show, profile): # Check if any episode is already snatched diff --git a/couchpotato/core/media/show/searcher/show.py b/couchpotato/core/media/show/searcher/show.py old mode 100644 new mode 100755 index 49fb775..07d644b --- a/couchpotato/core/media/show/searcher/show.py +++ b/couchpotato/core/media/show/searcher/show.py @@ -1,5 +1,6 @@ from couchpotato import get_db -from couchpotato.core.event import fireEvent, addEvent +from couchpotato.api import addApiView +from couchpotato.core.event import fireEvent, addEvent, fireEventAsync from couchpotato.core.helpers.variable import getTitle from couchpotato.core.logger import CPLog from couchpotato.core.media._base.searcher.base import SearcherBase @@ -19,10 +20,24 @@ class ShowSearcher(SearcherBase, ShowTypeBase): def __init__(self): super(ShowSearcher, self).__init__() + addEvent('%s.searcher.all' % self.getType(), self.searchAll) addEvent('%s.searcher.single' % self.getType(), self.single) - addEvent('searcher.get_search_title', self.getSearchTitle) + addApiView('%s.searcher.full_search' % self.getType(), self.searchAllView, docs = { + 'desc': 'Starts a full search for all wanted episodes', + }) + + def searchAllView(self, **kwargs): + fireEventAsync('%s.searcher.all' % self.getType(), manual = True) + + return { + 'success': not self.in_progress + } + + def searchAll(self, manual = False): + pass + def single(self, media, search_protocols = None, manual = False): # Find out search type try: