Browse Source

Removed the use of the 'searcher.get_media_searcher_id' event

pull/2523/head
Dean Gardiner 12 years ago
parent
commit
10a34f2b69
  1. 2
      couchpotato/core/helpers/variable.py
  2. 5
      couchpotato/core/media/_base/searcher/main.py
  3. 5
      couchpotato/core/media/movie/searcher/main.py
  4. 8
      couchpotato/core/media/show/searcher/main.py
  5. 4
      couchpotato/core/providers/base.py
  6. 2
      couchpotato/core/providers/info/base.py

2
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]

5
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

5
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

8
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()

4
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():

2
couchpotato/core/providers/info/base.py

@ -6,4 +6,4 @@ class MovieProvider(Provider):
class ShowProvider(Provider):
type = 'show'
type = ['season', 'episode']

Loading…
Cancel
Save