Removed the use of the 'searcher.get_media_searcher_id' event
This commit is contained in:
1 parent
cc3ebd79e8
commit
10a34f2b69
6 files changed
+9
-17
No files matched your search
@@ -167,7 +167,7 @@ def natcmp(a, b):
|
|||||||
return cmp(natsortKey(a), natsortKey(b))
|
return cmp(natsortKey(a), natsortKey(b))
|
||||||
|
|
||||||
def toIterable(value):
|
def toIterable(value):
|
||||||
if isinstance(value, collections.Iterable):
|
if type(value) in [list, tuple]:
|
||||||
return value
|
return value
|
||||||
return [value]
|
return [value]
|
||||||
|
|
||||||
|
|||||||
@@ -157,11 +157,8 @@ class Searcher(SearcherBase):
|
|||||||
def search(self, protocols, media, quality):
|
def search(self, protocols, media, quality):
|
||||||
results = []
|
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:
|
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:
|
if protocol_results:
|
||||||
results += protocol_results
|
results += protocol_results
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ class MovieSearcher(SearcherBase, MovieTypeBase):
|
|||||||
addEvent('movie.searcher.could_be_released', self.couldBeReleased)
|
addEvent('movie.searcher.could_be_released', self.couldBeReleased)
|
||||||
addEvent('searcher.correct_release', self.correctRelease)
|
addEvent('searcher.correct_release', self.correctRelease)
|
||||||
addEvent('searcher.get_search_title', self.getSearchTitle)
|
addEvent('searcher.get_search_title', self.getSearchTitle)
|
||||||
addEvent('searcher.get_media_searcher_id', self.getMediaSearcherId)
|
|
||||||
|
|
||||||
addApiView('movie.searcher.try_next', self.tryNextReleaseView, docs = {
|
addApiView('movie.searcher.try_next', self.tryNextReleaseView, docs = {
|
||||||
'desc': 'Marks the snatched results as ignored and try the next best release',
|
'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':
|
if media['type'] == 'movie':
|
||||||
return getTitle(media['library'])
|
return getTitle(media['library'])
|
||||||
|
|
||||||
def getMediaSearcherId(self, media_type):
|
|
||||||
if media_type == 'movie':
|
|
||||||
return 'movie'
|
|
||||||
|
|
||||||
class SearchSetupError(Exception):
|
class SearchSetupError(Exception):
|
||||||
pass
|
pass
|
||||||
@@ -37,7 +37,6 @@ class ShowSearcher(Plugin):
|
|||||||
|
|
||||||
addEvent('searcher.get_media_identifier', self.getMediaIdentifier)
|
addEvent('searcher.get_media_identifier', self.getMediaIdentifier)
|
||||||
addEvent('searcher.get_media_root', self.getMediaRoot)
|
addEvent('searcher.get_media_root', self.getMediaRoot)
|
||||||
addEvent('searcher.get_media_searcher_id', self.getMediaSearcherId)
|
|
||||||
|
|
||||||
def single(self, media, search_protocols = None, manual = False):
|
def single(self, media, search_protocols = None, manual = False):
|
||||||
if media['type'] == 'show':
|
if media['type'] == 'show':
|
||||||
@@ -224,6 +223,7 @@ class ShowSearcher(Plugin):
|
|||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
# TODO move this somewhere else
|
||||||
def getMediaIdentifier(self, media_library):
|
def getMediaIdentifier(self, media_library):
|
||||||
if media_library['type'] not in ['show', 'season', 'episode']:
|
if media_library['type'] not in ['show', 'season', 'episode']:
|
||||||
return None
|
return None
|
||||||
@@ -253,6 +253,7 @@ class ShowSearcher(Plugin):
|
|||||||
|
|
||||||
return identifier
|
return identifier
|
||||||
|
|
||||||
|
# TODO move this somewhere else
|
||||||
def getMediaRoot(self, media):
|
def getMediaRoot(self, media):
|
||||||
if media['type'] not in ['show', 'season', 'episode']:
|
if media['type'] not in ['show', 'season', 'episode']:
|
||||||
return None
|
return None
|
||||||
@@ -264,10 +265,7 @@ class ShowSearcher(Plugin):
|
|||||||
|
|
||||||
return show.to_dict()
|
return show.to_dict()
|
||||||
|
|
||||||
def getMediaSearcherId(self, media_type):
|
# TODO move this somewhere else
|
||||||
if media_type in ['show', 'season', 'episode']:
|
|
||||||
return 'show'
|
|
||||||
|
|
||||||
def getMedia(self, media):
|
def getMedia(self, media):
|
||||||
db = get_session()
|
db = get_session()
|
||||||
|
|
||||||
|
|||||||
@@ -118,7 +118,9 @@ class YarrProvider(Provider):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
addEvent('provider.enabled_protocols', self.getEnabledProtocol)
|
addEvent('provider.enabled_protocols', self.getEnabledProtocol)
|
||||||
addEvent('provider.belongs_to', self.belongsTo)
|
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):
|
def getEnabledProtocol(self):
|
||||||
if self.isEnabled():
|
if self.isEnabled():
|
||||||
|
|||||||
@@ -6,4 +6,4 @@ class MovieProvider(Provider):
|
|||||||
|
|
||||||
|
|
||||||
class ShowProvider(Provider):
|
class ShowProvider(Provider):
|
||||||
type = 'show'
|
type = ['season', 'episode']
|
||||||
Reference in new issue
Block a user