diff --git a/couchpotato/core/helpers/variable.py b/couchpotato/core/helpers/variable.py index 7d35b997..ff63938e 100644 --- a/couchpotato/core/helpers/variable.py +++ b/couchpotato/core/helpers/variable.py @@ -167,7 +167,7 @@ def natcmp(a, b): return cmp(natsortKey(a), natsortKey(b)) def toIterable(value): - if isinstance(value, collections.Iterable): + if type(value) in [list, tuple]: return value return [value] diff --git a/couchpotato/core/media/_base/searcher/main.py b/couchpotato/core/media/_base/searcher/main.py index f7df9569..ba7ba2fd 100644 --- a/couchpotato/core/media/_base/searcher/main.py +++ b/couchpotato/core/media/_base/searcher/main.py @@ -157,11 +157,8 @@ class Searcher(SearcherBase): def search(self, protocols, media, quality): results = [] - # TODO could this be handled better? (removing the need for 'searcher.get_media_searcher_id') - searcher_id = fireEvent('searcher.get_media_searcher_id', media['type'], single = True) - for search_protocol in protocols: - protocol_results = fireEvent('provider.search.%s.%s' % (search_protocol, searcher_id), media, quality, merge = True) + protocol_results = fireEvent('provider.search.%s.%s' % (search_protocol, media['type']), media, quality, merge = True) if protocol_results: results += protocol_results diff --git a/couchpotato/core/media/movie/searcher/main.py b/couchpotato/core/media/movie/searcher/main.py index b23fcceb..f80f63fe 100644 --- a/couchpotato/core/media/movie/searcher/main.py +++ b/couchpotato/core/media/movie/searcher/main.py @@ -31,7 +31,6 @@ class MovieSearcher(SearcherBase, MovieTypeBase): addEvent('movie.searcher.could_be_released', self.couldBeReleased) addEvent('searcher.correct_release', self.correctRelease) addEvent('searcher.get_search_title', self.getSearchTitle) - addEvent('searcher.get_media_searcher_id', self.getMediaSearcherId) addApiView('movie.searcher.try_next', self.tryNextReleaseView, docs = { 'desc': 'Marks the snatched results as ignored and try the next best release', @@ -348,9 +347,5 @@ class MovieSearcher(SearcherBase, MovieTypeBase): if media['type'] == 'movie': return getTitle(media['library']) - def getMediaSearcherId(self, media_type): - if media_type == 'movie': - return 'movie' - class SearchSetupError(Exception): pass diff --git a/couchpotato/core/media/show/searcher/main.py b/couchpotato/core/media/show/searcher/main.py index 3aa1294c..16327cc0 100644 --- a/couchpotato/core/media/show/searcher/main.py +++ b/couchpotato/core/media/show/searcher/main.py @@ -37,7 +37,6 @@ class ShowSearcher(Plugin): addEvent('searcher.get_media_identifier', self.getMediaIdentifier) addEvent('searcher.get_media_root', self.getMediaRoot) - addEvent('searcher.get_media_searcher_id', self.getMediaSearcherId) def single(self, media, search_protocols = None, manual = False): if media['type'] == 'show': @@ -224,6 +223,7 @@ class ShowSearcher(Plugin): return True + # TODO move this somewhere else def getMediaIdentifier(self, media_library): if media_library['type'] not in ['show', 'season', 'episode']: return None @@ -253,6 +253,7 @@ class ShowSearcher(Plugin): return identifier + # TODO move this somewhere else def getMediaRoot(self, media): if media['type'] not in ['show', 'season', 'episode']: return None @@ -264,10 +265,7 @@ class ShowSearcher(Plugin): return show.to_dict() - def getMediaSearcherId(self, media_type): - if media_type in ['show', 'season', 'episode']: - return 'show' - + # TODO move this somewhere else def getMedia(self, media): db = get_session() diff --git a/couchpotato/core/providers/base.py b/couchpotato/core/providers/base.py index 1476ef77..3cbd382d 100644 --- a/couchpotato/core/providers/base.py +++ b/couchpotato/core/providers/base.py @@ -118,7 +118,9 @@ class YarrProvider(Provider): def __init__(self): addEvent('provider.enabled_protocols', self.getEnabledProtocol) addEvent('provider.belongs_to', self.belongsTo) - addEvent('provider.search.%s.%s' % (self.protocol, self.type), self.search) + + for type in toIterable(self.type): + addEvent('provider.search.%s.%s' % (self.protocol, type), self.search) def getEnabledProtocol(self): if self.isEnabled(): diff --git a/couchpotato/core/providers/info/base.py b/couchpotato/core/providers/info/base.py index efb16621..8d06c322 100644 --- a/couchpotato/core/providers/info/base.py +++ b/couchpotato/core/providers/info/base.py @@ -6,4 +6,4 @@ class MovieProvider(Provider): class ShowProvider(Provider): - type = 'show' + type = ['season', 'episode']