Merge pull request #2681 from fuzeman/tv_searcher
[TV] Cleanup retrieval of media query and title
This commit is contained in:
@@ -1,13 +1,6 @@
|
|||||||
from couchpotato.core.event import addEvent
|
from .main import Library
|
||||||
from couchpotato.core.plugins.base import Plugin
|
|
||||||
|
|
||||||
|
def start():
|
||||||
|
return Library()
|
||||||
|
|
||||||
class LibraryBase(Plugin):
|
config = []
|
||||||
|
|
||||||
_type = None
|
|
||||||
|
|
||||||
def initType(self):
|
|
||||||
addEvent('library.types', self.getType)
|
|
||||||
|
|
||||||
def getType(self):
|
|
||||||
return self._type
|
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
from couchpotato.core.event import addEvent
|
||||||
|
from couchpotato.core.plugins.base import Plugin
|
||||||
|
|
||||||
|
|
||||||
|
class LibraryBase(Plugin):
|
||||||
|
|
||||||
|
_type = None
|
||||||
|
|
||||||
|
def initType(self):
|
||||||
|
addEvent('library.types', self.getType)
|
||||||
|
|
||||||
|
def getType(self):
|
||||||
|
return self._type
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
from couchpotato.core.event import addEvent, fireEvent
|
||||||
|
from couchpotato.core.media._base.library.base import LibraryBase
|
||||||
|
|
||||||
|
|
||||||
|
class Library(LibraryBase):
|
||||||
|
def __init__(self):
|
||||||
|
addEvent('library.title', self.title)
|
||||||
|
|
||||||
|
def title(self, library):
|
||||||
|
return fireEvent(
|
||||||
|
'library.query',
|
||||||
|
library,
|
||||||
|
|
||||||
|
condense = False,
|
||||||
|
include_year = False,
|
||||||
|
include_identifier = False,
|
||||||
|
single = True
|
||||||
|
)
|
||||||
@@ -171,7 +171,7 @@ class Searcher(SearcherBase):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def correctWords(self, rel_name, media):
|
def correctWords(self, rel_name, media):
|
||||||
media_title = fireEvent('searcher.get_search_title', media['library'], single = True)
|
media_title = fireEvent('library.title', media['library'], single = True)
|
||||||
media_words = re.split('\W+', simplifyString(media_title))
|
media_words = re.split('\W+', simplifyString(media_title))
|
||||||
|
|
||||||
rel_name = simplifyString(rel_name)
|
rel_name = simplifyString(rel_name)
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ from couchpotato import get_session
|
|||||||
from couchpotato.core.event import addEvent, fireEventAsync, fireEvent
|
from couchpotato.core.event import addEvent, fireEventAsync, fireEvent
|
||||||
from couchpotato.core.helpers.encoding import toUnicode, simplifyString
|
from couchpotato.core.helpers.encoding import toUnicode, simplifyString
|
||||||
from couchpotato.core.logger import CPLog
|
from couchpotato.core.logger import CPLog
|
||||||
from couchpotato.core.media._base.library import LibraryBase
|
from couchpotato.core.media._base.library.base import LibraryBase
|
||||||
from couchpotato.core.settings.model import Library, LibraryTitle, File
|
from couchpotato.core.settings.model import Library, LibraryTitle, File
|
||||||
from string import ascii_letters
|
from string import ascii_letters
|
||||||
import time
|
import time
|
||||||
@@ -16,10 +16,26 @@ class MovieLibraryPlugin(LibraryBase):
|
|||||||
default_dict = {'titles': {}, 'files':{}}
|
default_dict = {'titles': {}, 'files':{}}
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
addEvent('library.query', self.query)
|
||||||
addEvent('library.add.movie', self.add)
|
addEvent('library.add.movie', self.add)
|
||||||
addEvent('library.update.movie', self.update)
|
addEvent('library.update.movie', self.update)
|
||||||
addEvent('library.update.movie.release_date', self.updateReleaseDate)
|
addEvent('library.update.movie.release_date', self.updateReleaseDate)
|
||||||
|
|
||||||
|
def query(self, library, first = True, include_year = True, **kwargs):
|
||||||
|
if library.get('type') != 'movie':
|
||||||
|
return
|
||||||
|
|
||||||
|
titles = [title['title'] for title in library['titles']]
|
||||||
|
|
||||||
|
# Add year identifier to titles
|
||||||
|
if include_year:
|
||||||
|
titles = [title + (' %s' % str(library['year'])) for title in titles]
|
||||||
|
|
||||||
|
if first:
|
||||||
|
return titles[0] if titles else None
|
||||||
|
|
||||||
|
return titles
|
||||||
|
|
||||||
def add(self, attrs = {}, update_after = True):
|
def add(self, attrs = {}, update_after = True):
|
||||||
# movies don't yet contain these, so lets make sure to set defaults
|
# movies don't yet contain these, so lets make sure to set defaults
|
||||||
type = attrs.get('type', 'movie')
|
type = attrs.get('type', 'movie')
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ class MovieSearcher(SearcherBase, MovieTypeBase):
|
|||||||
addEvent('movie.searcher.try_next_release', self.tryNextRelease)
|
addEvent('movie.searcher.try_next_release', self.tryNextRelease)
|
||||||
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)
|
|
||||||
|
|
||||||
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',
|
||||||
@@ -210,7 +209,7 @@ class MovieSearcher(SearcherBase, MovieTypeBase):
|
|||||||
|
|
||||||
if media.get('type') != 'movie': return
|
if media.get('type') != 'movie': return
|
||||||
|
|
||||||
media_title = fireEvent('searcher.get_search_title', media['library'], single = True)
|
media_title = fireEvent('library.title', media['library'], single = True)
|
||||||
|
|
||||||
imdb_results = kwargs.get('imdb_results', False)
|
imdb_results = kwargs.get('imdb_results', False)
|
||||||
retention = Env.setting('retention', section = 'nzb')
|
retention = Env.setting('retention', section = 'nzb')
|
||||||
@@ -343,15 +342,5 @@ class MovieSearcher(SearcherBase, MovieTypeBase):
|
|||||||
log.error('Failed searching for next release: %s', traceback.format_exc())
|
log.error('Failed searching for next release: %s', traceback.format_exc())
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def getSearchTitle(self, library, include_identifier = False):
|
|
||||||
if library['type'] == 'movie':
|
|
||||||
title = getTitle(library)
|
|
||||||
|
|
||||||
# Use year as identifier
|
|
||||||
if include_identifier:
|
|
||||||
title += ' %s' % str(library['year'])
|
|
||||||
|
|
||||||
return title
|
|
||||||
|
|
||||||
class SearchSetupError(Exception):
|
class SearchSetupError(Exception):
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ from couchpotato.core.event import addEvent, fireEventAsync, fireEvent
|
|||||||
from couchpotato.core.helpers.encoding import toUnicode, simplifyString
|
from couchpotato.core.helpers.encoding import toUnicode, simplifyString
|
||||||
from couchpotato.core.logger import CPLog
|
from couchpotato.core.logger import CPLog
|
||||||
from couchpotato.core.settings.model import EpisodeLibrary, SeasonLibrary, LibraryTitle, File
|
from couchpotato.core.settings.model import EpisodeLibrary, SeasonLibrary, LibraryTitle, File
|
||||||
from couchpotato.core.media._base.library import LibraryBase
|
from couchpotato.core.media._base.library.base import LibraryBase
|
||||||
from couchpotato.core.helpers.variable import tryInt
|
from couchpotato.core.helpers.variable import tryInt
|
||||||
from string import ascii_letters
|
from string import ascii_letters
|
||||||
import time
|
import time
|
||||||
@@ -17,11 +17,44 @@ class EpisodeLibraryPlugin(LibraryBase):
|
|||||||
default_dict = {'titles': {}, 'files':{}}
|
default_dict = {'titles': {}, 'files':{}}
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
addEvent('library.query', self.query)
|
||||||
addEvent('library.identifier', self.identifier)
|
addEvent('library.identifier', self.identifier)
|
||||||
addEvent('library.add.episode', self.add)
|
addEvent('library.add.episode', self.add)
|
||||||
addEvent('library.update.episode', self.update)
|
addEvent('library.update.episode', self.update)
|
||||||
addEvent('library.update.episode_release_date', self.updateReleaseDate)
|
addEvent('library.update.episode_release_date', self.updateReleaseDate)
|
||||||
|
|
||||||
|
def query(self, library, first = True, condense = True, include_identifier = True, **kwargs):
|
||||||
|
if library is list or library.get('type') != 'episode':
|
||||||
|
return
|
||||||
|
|
||||||
|
# Get the titles of the season
|
||||||
|
if not library.get('related_libraries', {}).get('season', []):
|
||||||
|
log.warning('Invalid library, unable to determine title.')
|
||||||
|
return
|
||||||
|
|
||||||
|
titles = fireEvent(
|
||||||
|
'library.query',
|
||||||
|
library['related_libraries']['season'][0],
|
||||||
|
first=False,
|
||||||
|
include_identifier=include_identifier,
|
||||||
|
condense=condense,
|
||||||
|
|
||||||
|
single=True
|
||||||
|
)
|
||||||
|
|
||||||
|
identifier = fireEvent('library.identifier', library, single = True)
|
||||||
|
|
||||||
|
# Add episode identifier to titles
|
||||||
|
if include_identifier and identifier.get('episode'):
|
||||||
|
titles = [title + ('E%02d' % identifier['episode']) for title in titles]
|
||||||
|
|
||||||
|
|
||||||
|
if first:
|
||||||
|
return titles[0] if titles else None
|
||||||
|
|
||||||
|
return titles
|
||||||
|
|
||||||
|
|
||||||
def identifier(self, library):
|
def identifier(self, library):
|
||||||
if library.get('type') != 'episode':
|
if library.get('type') != 'episode':
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ from couchpotato.core.event import addEvent, fireEventAsync, fireEvent
|
|||||||
from couchpotato.core.helpers.encoding import toUnicode, simplifyString
|
from couchpotato.core.helpers.encoding import toUnicode, simplifyString
|
||||||
from couchpotato.core.logger import CPLog
|
from couchpotato.core.logger import CPLog
|
||||||
from couchpotato.core.settings.model import SeasonLibrary, ShowLibrary, LibraryTitle, File
|
from couchpotato.core.settings.model import SeasonLibrary, ShowLibrary, LibraryTitle, File
|
||||||
from couchpotato.core.media._base.library import LibraryBase
|
from couchpotato.core.media._base.library.base import LibraryBase
|
||||||
from couchpotato.core.helpers.variable import tryInt
|
from couchpotato.core.helpers.variable import tryInt
|
||||||
from string import ascii_letters
|
from string import ascii_letters
|
||||||
import time
|
import time
|
||||||
@@ -17,11 +17,52 @@ class SeasonLibraryPlugin(LibraryBase):
|
|||||||
default_dict = {'titles': {}, 'files':{}}
|
default_dict = {'titles': {}, 'files':{}}
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
addEvent('library.query', self.query)
|
||||||
addEvent('library.identifier', self.identifier)
|
addEvent('library.identifier', self.identifier)
|
||||||
addEvent('library.add.season', self.add)
|
addEvent('library.add.season', self.add)
|
||||||
addEvent('library.update.season', self.update)
|
addEvent('library.update.season', self.update)
|
||||||
addEvent('library.update.season_release_date', self.updateReleaseDate)
|
addEvent('library.update.season_release_date', self.updateReleaseDate)
|
||||||
|
|
||||||
|
def query(self, library, first = True, condense = True, include_identifier = True, **kwargs):
|
||||||
|
if library is list or library.get('type') != 'season':
|
||||||
|
return
|
||||||
|
|
||||||
|
# Get the titles of the show
|
||||||
|
if not library.get('related_libraries', {}).get('show', []):
|
||||||
|
log.warning('Invalid library, unable to determine title.')
|
||||||
|
return
|
||||||
|
|
||||||
|
titles = fireEvent(
|
||||||
|
'library.query',
|
||||||
|
library['related_libraries']['show'][0],
|
||||||
|
first=False,
|
||||||
|
condense=condense,
|
||||||
|
|
||||||
|
single=True
|
||||||
|
)
|
||||||
|
|
||||||
|
# Add season map_names if they exist
|
||||||
|
if 'map_names' in library['info']:
|
||||||
|
season_names = library['info']['map_names'].get(str(library['season_number']), {})
|
||||||
|
|
||||||
|
# Add titles from all locations
|
||||||
|
# TODO only add name maps from a specific location
|
||||||
|
for location, names in season_names.items():
|
||||||
|
titles += [name for name in names if name and name not in titles]
|
||||||
|
|
||||||
|
|
||||||
|
identifier = fireEvent('library.identifier', library, single = True)
|
||||||
|
|
||||||
|
# Add season identifier to titles
|
||||||
|
if include_identifier and identifier.get('season') is not None:
|
||||||
|
titles = [title + (' S%02d' % identifier['season']) for title in titles]
|
||||||
|
|
||||||
|
|
||||||
|
if first:
|
||||||
|
return titles[0] if titles else None
|
||||||
|
|
||||||
|
return titles
|
||||||
|
|
||||||
def identifier(self, library):
|
def identifier(self, library):
|
||||||
if library.get('type') != 'season':
|
if library.get('type') != 'season':
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -3,7 +3,9 @@ from couchpotato.core.event import addEvent, fireEventAsync, fireEvent
|
|||||||
from couchpotato.core.helpers.encoding import toUnicode, simplifyString
|
from couchpotato.core.helpers.encoding import toUnicode, simplifyString
|
||||||
from couchpotato.core.logger import CPLog
|
from couchpotato.core.logger import CPLog
|
||||||
from couchpotato.core.settings.model import ShowLibrary, LibraryTitle, File
|
from couchpotato.core.settings.model import ShowLibrary, LibraryTitle, File
|
||||||
from couchpotato.core.media._base.library import LibraryBase
|
from couchpotato.core.media._base.library.base import LibraryBase
|
||||||
|
from qcond.helpers import simplify
|
||||||
|
from qcond import QueryCondenser
|
||||||
from string import ascii_letters
|
from string import ascii_letters
|
||||||
import time
|
import time
|
||||||
import traceback
|
import traceback
|
||||||
@@ -16,10 +18,35 @@ class ShowLibraryPlugin(LibraryBase):
|
|||||||
default_dict = {'titles': {}, 'files':{}}
|
default_dict = {'titles': {}, 'files':{}}
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
self.query_condenser = QueryCondenser()
|
||||||
|
|
||||||
|
addEvent('library.query', self.query)
|
||||||
addEvent('library.add.show', self.add)
|
addEvent('library.add.show', self.add)
|
||||||
addEvent('library.update.show', self.update)
|
addEvent('library.update.show', self.update)
|
||||||
addEvent('library.update.show_release_date', self.updateReleaseDate)
|
addEvent('library.update.show_release_date', self.updateReleaseDate)
|
||||||
|
|
||||||
|
def query(self, library, first = True, condense = True, **kwargs):
|
||||||
|
if library is list or library.get('type') != 'show':
|
||||||
|
return
|
||||||
|
|
||||||
|
titles = [title['title'] for title in library['titles']]
|
||||||
|
|
||||||
|
if condense:
|
||||||
|
# Use QueryCondenser to build a list of optimal search titles
|
||||||
|
condensed_titles = self.query_condenser.distinct(titles)
|
||||||
|
|
||||||
|
if condensed_titles:
|
||||||
|
# Use condensed titles if we got a valid result
|
||||||
|
titles = condensed_titles
|
||||||
|
else:
|
||||||
|
# Fallback to simplifying titles
|
||||||
|
titles = [simplify(title) for title in titles]
|
||||||
|
|
||||||
|
if first:
|
||||||
|
return titles[0] if titles else None
|
||||||
|
|
||||||
|
return titles
|
||||||
|
|
||||||
def add(self, attrs = {}, update_after = True):
|
def add(self, attrs = {}, update_after = True):
|
||||||
type = attrs.get('type', 'show')
|
type = attrs.get('type', 'show')
|
||||||
primary_provider = attrs.get('primary_provider', 'thetvdb')
|
primary_provider = attrs.get('primary_provider', 'thetvdb')
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ class ShowSearcher(Plugin):
|
|||||||
for type in toIterable(self.type):
|
for type in toIterable(self.type):
|
||||||
addEvent('%s.searcher.single' % type, self.single)
|
addEvent('%s.searcher.single' % type, self.single)
|
||||||
|
|
||||||
addEvent('searcher.get_search_title', self.getSearchTitle)
|
|
||||||
addEvent('searcher.correct_release', self.correctRelease)
|
addEvent('searcher.correct_release', self.correctRelease)
|
||||||
|
|
||||||
def single(self, media, search_protocols = None, manual = False):
|
def single(self, media, search_protocols = None, manual = False):
|
||||||
@@ -61,7 +60,7 @@ class ShowSearcher(Plugin):
|
|||||||
found_releases = []
|
found_releases = []
|
||||||
too_early_to_search = []
|
too_early_to_search = []
|
||||||
|
|
||||||
default_title = self.getSearchTitle(media['library'])
|
default_title = fireEvent('library.query', media['library'], condense = False, single=True)
|
||||||
if not default_title:
|
if not default_title:
|
||||||
log.error('No proper info found for episode, removing it from library to cause it from having more issues.')
|
log.error('No proper info found for episode, removing it from library to cause it from having more issues.')
|
||||||
#fireEvent('episode.delete', episode['id'], single = True)
|
#fireEvent('episode.delete', episode['id'], single = True)
|
||||||
@@ -145,61 +144,6 @@ class ShowSearcher(Plugin):
|
|||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
def getSearchTitle(self, library, include_identifier = False):
|
|
||||||
if library['type'] not in ['show', 'season', 'episode']:
|
|
||||||
return
|
|
||||||
|
|
||||||
show, season, episode = self.getLibraries(library)
|
|
||||||
|
|
||||||
if not show:
|
|
||||||
return None
|
|
||||||
|
|
||||||
titles = []
|
|
||||||
|
|
||||||
# Add season map_names if they exist
|
|
||||||
if season is not None and 'map_names' in show['info']:
|
|
||||||
season_names = show['info']['map_names'].get(str(season['season_number']), {})
|
|
||||||
|
|
||||||
# Add titles from all locations
|
|
||||||
# TODO only add name maps from a specific location
|
|
||||||
for location, names in season_names.items():
|
|
||||||
titles += [name for name in names if name not in titles]
|
|
||||||
|
|
||||||
# Add show titles
|
|
||||||
titles += [title['title'] for title in show['titles'] if title['title'] not in titles]
|
|
||||||
|
|
||||||
# Use QueryCondenser to build a list of optimal search titles
|
|
||||||
condensed_titles = self.query_condenser.distinct(titles)
|
|
||||||
|
|
||||||
title = None
|
|
||||||
|
|
||||||
# TODO try other titles if searching doesn't return results
|
|
||||||
|
|
||||||
if len(condensed_titles):
|
|
||||||
# Return the first condensed title if one exists
|
|
||||||
title = condensed_titles[0]
|
|
||||||
elif len(titles):
|
|
||||||
# Fallback to first raw title
|
|
||||||
title = simplify(titles[0])
|
|
||||||
else:
|
|
||||||
return None
|
|
||||||
|
|
||||||
# Return show title if we aren't including the identifier
|
|
||||||
if not include_identifier:
|
|
||||||
return title
|
|
||||||
|
|
||||||
# Add the identifier to search title
|
|
||||||
identifier = fireEvent('library.identifier', library, single = True)
|
|
||||||
|
|
||||||
# TODO this needs to support other identifier formats
|
|
||||||
if identifier['season']:
|
|
||||||
title += ' S%02d' % identifier['season']
|
|
||||||
|
|
||||||
if identifier.get('episode'):
|
|
||||||
title += 'E%02d' % identifier['episode']
|
|
||||||
|
|
||||||
return title
|
|
||||||
|
|
||||||
def correctRelease(self, release = None, media = None, quality = None, **kwargs):
|
def correctRelease(self, release = None, media = None, quality = None, **kwargs):
|
||||||
|
|
||||||
if media.get('type') not in ['season', 'episode']: return
|
if media.get('type') not in ['season', 'episode']: return
|
||||||
|
|||||||
@@ -207,7 +207,7 @@ class YarrProvider(Provider):
|
|||||||
self._search(media, quality, results)
|
self._search(media, quality, results)
|
||||||
# Search possible titles
|
# Search possible titles
|
||||||
else:
|
else:
|
||||||
media_title = fireEvent('searcher.get_search_title', media['library'], include_identifier = True, single = True)
|
media_title = fireEvent('library.query', media['library'], single = True)
|
||||||
|
|
||||||
for title in possibleTitles(media_title):
|
for title in possibleTitles(media_title):
|
||||||
self._searchOnTitle(title, media, quality, results)
|
self._searchOnTitle(title, media, quality, results)
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ class Movie(MovieProvider, Base):
|
|||||||
|
|
||||||
def buildUrl(self, media, quality):
|
def buildUrl(self, media, quality):
|
||||||
query = tryUrlencode({
|
query = tryUrlencode({
|
||||||
'q': media['library']['identifier'],
|
'q': media['library']['identifier'], # TODO should this use library.title?
|
||||||
'm': 'n',
|
'm': 'n',
|
||||||
'max': 400,
|
'max': 400,
|
||||||
'adv_age': Env.setting('retention', 'nzb'),
|
'adv_age': Env.setting('retention', 'nzb'),
|
||||||
@@ -117,7 +117,7 @@ class Season(SeasonProvider, Base):
|
|||||||
|
|
||||||
def buildUrl(self, media, quality):
|
def buildUrl(self, media, quality):
|
||||||
query = tryUrlencode({
|
query = tryUrlencode({
|
||||||
'q': fireEvent('searcher.get_search_title', media['library'], include_identifier = True, single = True),
|
'q': fireEvent('library.query', media['library'], single = True),
|
||||||
'm': 'n',
|
'm': 'n',
|
||||||
'max': 400,
|
'max': 400,
|
||||||
'adv_age': Env.setting('retention', 'nzb'),
|
'adv_age': Env.setting('retention', 'nzb'),
|
||||||
@@ -133,7 +133,7 @@ class Episode(EpisodeProvider, Base):
|
|||||||
|
|
||||||
def buildUrl(self, media, quality):
|
def buildUrl(self, media, quality):
|
||||||
query = tryUrlencode({
|
query = tryUrlencode({
|
||||||
'q': fireEvent('searcher.get_search_title', media['library'], include_identifier = True, single = True),
|
'q': fireEvent('library.query', media['library'], single = True),
|
||||||
'm': 'n',
|
'm': 'n',
|
||||||
'max': 400,
|
'max': 400,
|
||||||
'adv_age': Env.setting('retention', 'nzb'),
|
'adv_age': Env.setting('retention', 'nzb'),
|
||||||
|
|||||||
@@ -200,7 +200,7 @@ class Movie(MovieProvider, Base):
|
|||||||
class Season(SeasonProvider, Base):
|
class Season(SeasonProvider, Base):
|
||||||
|
|
||||||
def buildUrl(self, media, api_key):
|
def buildUrl(self, media, api_key):
|
||||||
search_title = fireEvent('searcher.get_search_title', media['library'], single = True)
|
search_title = fireEvent('library.query', media['library'], include_identifier = False, single = True)
|
||||||
identifier = fireEvent('library.identifier', media['library'], single = True)
|
identifier = fireEvent('library.identifier', media['library'], single = True)
|
||||||
|
|
||||||
query = tryUrlencode({
|
query = tryUrlencode({
|
||||||
@@ -215,7 +215,7 @@ class Season(SeasonProvider, Base):
|
|||||||
class Episode(EpisodeProvider, Base):
|
class Episode(EpisodeProvider, Base):
|
||||||
|
|
||||||
def buildUrl(self, media, api_key):
|
def buildUrl(self, media, api_key):
|
||||||
search_title = fireEvent('searcher.get_search_title', media['library'], single = True)
|
search_title = fireEvent('library.query', media['library'], include_identifier = False, single = True)
|
||||||
identifier = fireEvent('library.identifier', media['library'], single = True)
|
identifier = fireEvent('library.identifier', media['library'], single = True)
|
||||||
|
|
||||||
query = tryUrlencode({
|
query = tryUrlencode({
|
||||||
|
|||||||
@@ -80,8 +80,7 @@ class Movie(MovieProvider, Base):
|
|||||||
|
|
||||||
def buildUrl(self, media):
|
def buildUrl(self, media):
|
||||||
query = tryUrlencode({
|
query = tryUrlencode({
|
||||||
'q': '"%s %s"' % (fireEvent('searcher.get_search_title', media['library'], include_identifier = True,
|
'q': '"%s"' % fireEvent('library.query', media['library'], single = True),
|
||||||
single = True), media['library']['year']),
|
|
||||||
'ig': 1,
|
'ig': 1,
|
||||||
'rpp': 200,
|
'rpp': 200,
|
||||||
'st': 5,
|
'st': 5,
|
||||||
@@ -94,7 +93,7 @@ class Season(SeasonProvider, Base):
|
|||||||
|
|
||||||
def buildUrl(self, media):
|
def buildUrl(self, media):
|
||||||
query = tryUrlencode({
|
query = tryUrlencode({
|
||||||
'q': fireEvent('searcher.get_search_title', media['library'], include_identifier = True, single = True),
|
'q': fireEvent('library.query', media['library'], single = True),
|
||||||
'ig': 1,
|
'ig': 1,
|
||||||
'rpp': 200,
|
'rpp': 200,
|
||||||
'st': 5,
|
'st': 5,
|
||||||
@@ -107,7 +106,7 @@ class Episode(EpisodeProvider, Base):
|
|||||||
|
|
||||||
def buildUrl(self, media):
|
def buildUrl(self, media):
|
||||||
query = tryUrlencode({
|
query = tryUrlencode({
|
||||||
'q': fireEvent('searcher.get_search_title', media['library'], include_identifier = True, single = True),
|
'q': fireEvent('library.query', media['library'], single = True),
|
||||||
'ig': 1,
|
'ig': 1,
|
||||||
'rpp': 200,
|
'rpp': 200,
|
||||||
'st': 5,
|
'st': 5,
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ class Base(NZBProvider, RSS):
|
|||||||
class Movie(MovieProvider, Base):
|
class Movie(MovieProvider, Base):
|
||||||
|
|
||||||
def buildUrl(self, media, quality):
|
def buildUrl(self, media, quality):
|
||||||
title = fireEvent('searcher.get_search_title', media['library'], single = True)
|
title = fireEvent('library.query', media['library'], include_year = False, single = True)
|
||||||
year = media['library']['year']
|
year = media['library']['year']
|
||||||
|
|
||||||
query = tryUrlencode({
|
query = tryUrlencode({
|
||||||
@@ -124,7 +124,7 @@ class Season(SeasonProvider, Base):
|
|||||||
|
|
||||||
def buildUrl(self, media, quality):
|
def buildUrl(self, media, quality):
|
||||||
query = tryUrlencode({
|
query = tryUrlencode({
|
||||||
'q': fireEvent('searcher.get_search_title', media['library'], include_identifier = True, single = True),
|
'q': fireEvent('library.query', media['library'], single = True),
|
||||||
'age': Env.setting('retention', 'nzb'),
|
'age': Env.setting('retention', 'nzb'),
|
||||||
'sort': 'agedesc',
|
'sort': 'agedesc',
|
||||||
'minsize': quality.get('size_min'),
|
'minsize': quality.get('size_min'),
|
||||||
@@ -140,7 +140,7 @@ class Episode(EpisodeProvider, Base):
|
|||||||
|
|
||||||
def buildUrl(self, media, quality):
|
def buildUrl(self, media, quality):
|
||||||
query = tryUrlencode({
|
query = tryUrlencode({
|
||||||
'q': fireEvent('searcher.get_search_title', media['library'], include_identifier = True, single = True),
|
'q': fireEvent('library.query', media['library'], single = True),
|
||||||
'age': Env.setting('retention', 'nzb'),
|
'age': Env.setting('retention', 'nzb'),
|
||||||
'sort': 'agedesc',
|
'sort': 'agedesc',
|
||||||
'minsize': quality.get('size_min'),
|
'minsize': quality.get('size_min'),
|
||||||
|
|||||||
@@ -95,8 +95,7 @@ class Movie(MovieProvider, Base):
|
|||||||
|
|
||||||
def buildUrl(self, media):
|
def buildUrl(self, media):
|
||||||
query = tryUrlencode({
|
query = tryUrlencode({
|
||||||
'search': fireEvent('searcher.get_search_title', media['library'],
|
'search': fireEvent('library.query', media['library'], single = True),
|
||||||
include_identifier = True, single = True),
|
|
||||||
'cat': 7 # Movie cat
|
'cat': 7 # Movie cat
|
||||||
})
|
})
|
||||||
return query
|
return query
|
||||||
@@ -105,8 +104,7 @@ class Season(SeasonProvider, Base):
|
|||||||
|
|
||||||
def buildUrl(self, media):
|
def buildUrl(self, media):
|
||||||
query = tryUrlencode({
|
query = tryUrlencode({
|
||||||
'search': fireEvent('searcher.get_search_title', media['library'],
|
'search': fireEvent('library.query', media['library'], single = True),
|
||||||
include_identifier = True, single = True),
|
|
||||||
'cat': 12 # Season cat
|
'cat': 12 # Season cat
|
||||||
})
|
})
|
||||||
return query
|
return query
|
||||||
@@ -115,8 +113,7 @@ class Episode(EpisodeProvider, Base):
|
|||||||
|
|
||||||
def buildUrl(self, media):
|
def buildUrl(self, media):
|
||||||
query = tryUrlencode({
|
query = tryUrlencode({
|
||||||
'search': fireEvent('searcher.get_search_title', media['library'],
|
'search': fireEvent('library.query', media['library'], single = True),
|
||||||
include_identifier = True, single = True),
|
|
||||||
'cat': 10 # Episode cat
|
'cat': 10 # Episode cat
|
||||||
})
|
})
|
||||||
return query
|
return query
|
||||||
@@ -113,9 +113,10 @@ class Movie(MovieProvider, Base):
|
|||||||
|
|
||||||
def buildUrl(self, media, quality):
|
def buildUrl(self, media, quality):
|
||||||
query = tryUrlencode({
|
query = tryUrlencode({
|
||||||
'search': '"%s" %s' % (fireEvent('searcher.get_search_title',
|
'search': '"%s" %s' % (
|
||||||
media['library'], include_identifier = False, single = True),
|
fireEvent('library.query', media['library'], include_year = False, single = True),
|
||||||
media['library']['year']),
|
media['library']['year']
|
||||||
|
),
|
||||||
'cat': self.getCatId(quality['identifier'])[0],
|
'cat': self.getCatId(quality['identifier'])[0],
|
||||||
})
|
})
|
||||||
return query
|
return query
|
||||||
@@ -124,8 +125,7 @@ class Season(SeasonProvider, Base):
|
|||||||
# For season bundles, bitsoup currently only has one category
|
# For season bundles, bitsoup currently only has one category
|
||||||
def buildUrl(self, media, quality):
|
def buildUrl(self, media, quality):
|
||||||
query = tryUrlencode({
|
query = tryUrlencode({
|
||||||
'search': fireEvent('searcher.get_search_title', media['library'],
|
'search': fireEvent('library.query', media['library'], single = True),
|
||||||
include_identifier = True, single = True),
|
|
||||||
'cat': 45 # TV-Packs Category
|
'cat': 45 # TV-Packs Category
|
||||||
})
|
})
|
||||||
return query
|
return query
|
||||||
@@ -139,8 +139,7 @@ class Episode(EpisodeProvider, Base):
|
|||||||
|
|
||||||
def buildUrl(self, media, quality):
|
def buildUrl(self, media, quality):
|
||||||
query = tryUrlencode({
|
query = tryUrlencode({
|
||||||
'search': fireEvent('searcher.get_search_title', media['library'],
|
'search': fireEvent('library.query', media['library'], single = True),
|
||||||
include_identifier = True, single = True),
|
|
||||||
'cat': self.getCatId(quality['identifier'])[0],
|
'cat': self.getCatId(quality['identifier'])[0],
|
||||||
})
|
})
|
||||||
return query
|
return query
|
||||||
|
|||||||
@@ -99,14 +99,14 @@ class Base(TorrentMagnetProvider):
|
|||||||
class Movie(MovieProvider, Base):
|
class Movie(MovieProvider, Base):
|
||||||
|
|
||||||
def buildUrl(self, media):
|
def buildUrl(self, media):
|
||||||
return fireEvent('searcher.get_search_title', media['library'], include_identifier = True, single = True)
|
return fireEvent('library.query', media['library'], single = True)
|
||||||
|
|
||||||
class Season(SeasonProvider, Base):
|
class Season(SeasonProvider, Base):
|
||||||
|
|
||||||
def buildUrl(self, media):
|
def buildUrl(self, media):
|
||||||
return fireEvent('searcher.get_search_title', media['library'], include_identifier = True, single = True)
|
return fireEvent('library.query', media['library'], single = True)
|
||||||
|
|
||||||
class Episode(EpisodeProvider, Base):
|
class Episode(EpisodeProvider, Base):
|
||||||
|
|
||||||
def buildUrl(self, media):
|
def buildUrl(self, media):
|
||||||
return fireEvent('searcher.get_search_title', media['library'], include_identifier = True, single = True)
|
return fireEvent('library.query', media['library'], single = True)
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ class Movie(MovieProvider, Base):
|
|||||||
)
|
)
|
||||||
|
|
||||||
arguments = tryUrlencode({
|
arguments = tryUrlencode({
|
||||||
'search': fireEvent('searcher.get_search_title', media['library'], include_identifier = True, single = True),
|
'search': fireEvent('library.query', media['library'], single = True),
|
||||||
'method': 2,
|
'method': 2,
|
||||||
})
|
})
|
||||||
query = "%s&%s" % (url, arguments)
|
query = "%s&%s" % (url, arguments)
|
||||||
@@ -124,7 +124,7 @@ class Season(SeasonProvider, Base):
|
|||||||
)
|
)
|
||||||
|
|
||||||
arguments = tryUrlencode({
|
arguments = tryUrlencode({
|
||||||
'search': fireEvent('searcher.get_search_title', media['library'], include_identifier = True, single = True),
|
'search': fireEvent('library.query', media['library'], single = True),
|
||||||
'method': 2,
|
'method': 2,
|
||||||
})
|
})
|
||||||
query = "%s&%s" % (url, arguments)
|
query = "%s&%s" % (url, arguments)
|
||||||
@@ -145,7 +145,7 @@ class Episode(EpisodeProvider, Base):
|
|||||||
)
|
)
|
||||||
|
|
||||||
arguments = tryUrlencode({
|
arguments = tryUrlencode({
|
||||||
'search': fireEvent('searcher.get_search_title', media['library'], include_identifier = True, single = True),
|
'search': fireEvent('library.query', media['library'], single = True),
|
||||||
'method': 2,
|
'method': 2,
|
||||||
})
|
})
|
||||||
query = "%s&%s" % (url, arguments)
|
query = "%s&%s" % (url, arguments)
|
||||||
|
|||||||
@@ -130,8 +130,11 @@ class Movie(MovieProvider, Base):
|
|||||||
]
|
]
|
||||||
|
|
||||||
def buildUrl(self, media, page, cats):
|
def buildUrl(self, media, page, cats):
|
||||||
return tryUrlencode('"%s"' % fireEvent('searcher.get_search_title', media['library'],
|
return (
|
||||||
include_identifier = True, single = True)), page, ','.join(str(x) for x in cats)
|
tryUrlencode('"%s"' % fireEvent('library.query', media['library'], single = True)),
|
||||||
|
page,
|
||||||
|
','.join(str(x) for x in cats)
|
||||||
|
)
|
||||||
|
|
||||||
class Season(SeasonProvider, Base):
|
class Season(SeasonProvider, Base):
|
||||||
|
|
||||||
@@ -141,8 +144,11 @@ class Season(SeasonProvider, Base):
|
|||||||
]
|
]
|
||||||
|
|
||||||
def buildUrl(self, media, page, cats):
|
def buildUrl(self, media, page, cats):
|
||||||
return tryUrlencode('"%s"' % fireEvent('searcher.get_search_title', media['library'],
|
return (
|
||||||
include_identifier = True, single = True)), page, ','.join(str(x) for x in cats)
|
tryUrlencode('"%s"' % fireEvent('library.query', media['library'], single = True)),
|
||||||
|
page,
|
||||||
|
','.join(str(x) for x in cats)
|
||||||
|
)
|
||||||
|
|
||||||
class Episode(EpisodeProvider, Base):
|
class Episode(EpisodeProvider, Base):
|
||||||
|
|
||||||
@@ -152,5 +158,8 @@ class Episode(EpisodeProvider, Base):
|
|||||||
]
|
]
|
||||||
|
|
||||||
def buildUrl(self, media, page, cats):
|
def buildUrl(self, media, page, cats):
|
||||||
return tryUrlencode('"%s"' % fireEvent('searcher.get_search_title', media['library'],
|
return (
|
||||||
include_identifier = True, single = True)), page, ','.join(str(x) for x in cats)
|
tryUrlencode('"%s"' % fireEvent('library.query', media['library'], single = True)),
|
||||||
|
page,
|
||||||
|
','.join(str(x) for x in cats)
|
||||||
|
)
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ class Movie(MovieProvider, Base):
|
|||||||
([5], ['bd50']),
|
([5], ['bd50']),
|
||||||
]
|
]
|
||||||
def buildUrl(self, media):
|
def buildUrl(self, media):
|
||||||
return fireEvent('searcher.get_search_title', media['library'], include_identifier = True, single = True)
|
return fireEvent('library.query', media['library'], single = True)
|
||||||
|
|
||||||
class Season(SeasonProvider, Base):
|
class Season(SeasonProvider, Base):
|
||||||
|
|
||||||
@@ -84,7 +84,7 @@ class Season(SeasonProvider, Base):
|
|||||||
([14], ['hdtv_sd', 'hdtv_720p', 'webdl_720p', 'webdl_1080p']),
|
([14], ['hdtv_sd', 'hdtv_720p', 'webdl_720p', 'webdl_1080p']),
|
||||||
]
|
]
|
||||||
def buildUrl(self, media):
|
def buildUrl(self, media):
|
||||||
return fireEvent('searcher.get_search_title', media['library'], include_identifier = True, single = True)
|
return fireEvent('library.query', media['library'], single = True)
|
||||||
|
|
||||||
class Episode(EpisodeProvider, Base):
|
class Episode(EpisodeProvider, Base):
|
||||||
cat_ids = [
|
cat_ids = [
|
||||||
@@ -92,5 +92,5 @@ class Episode(EpisodeProvider, Base):
|
|||||||
([2], [24], [26], ['hdtv_sd'])
|
([2], [24], [26], ['hdtv_sd'])
|
||||||
]
|
]
|
||||||
def buildUrl(self, media):
|
def buildUrl(self, media):
|
||||||
return fireEvent('searcher.get_search_title', media['library'], include_identifier = True, single = True)
|
return fireEvent('library.query', media['library'], single = True)
|
||||||
|
|
||||||
|
|||||||
@@ -90,8 +90,10 @@ class Movie(MovieProvider, Base):
|
|||||||
]
|
]
|
||||||
|
|
||||||
def buildUrl(self, media, quality):
|
def buildUrl(self, media, quality):
|
||||||
return (tryUrlencode('%s' % fireEvent('searcher.get_search_title',
|
return (
|
||||||
media['library'], include_identifier = True, single = True)), self.getCatId(quality['identifier'])[0])
|
tryUrlencode(fireEvent('library.query', media['library'], single = True)),
|
||||||
|
self.getCatId(quality['identifier'])[0]
|
||||||
|
)
|
||||||
|
|
||||||
class Season(SeasonProvider, Base):
|
class Season(SeasonProvider, Base):
|
||||||
|
|
||||||
@@ -100,8 +102,10 @@ class Season(SeasonProvider, Base):
|
|||||||
]
|
]
|
||||||
|
|
||||||
def buildUrl(self, media, quality):
|
def buildUrl(self, media, quality):
|
||||||
return (tryUrlencode('%s' % fireEvent('searcher.get_search_title',
|
return (
|
||||||
media['library'], include_identifier = True, single = True)), self.getCatId(quality['identifier'])[0])
|
tryUrlencode(fireEvent('library.query', media['library'], single = True)),
|
||||||
|
self.getCatId(quality['identifier'])[0]
|
||||||
|
)
|
||||||
|
|
||||||
class Episode(EpisodeProvider, Base):
|
class Episode(EpisodeProvider, Base):
|
||||||
|
|
||||||
@@ -111,5 +115,7 @@ class Episode(EpisodeProvider, Base):
|
|||||||
]
|
]
|
||||||
|
|
||||||
def buildUrl(self, media, quality):
|
def buildUrl(self, media, quality):
|
||||||
return (tryUrlencode('%s' % fireEvent('searcher.get_search_title',
|
return (
|
||||||
media['library'], include_identifier = True, single = True)), self.getCatId(quality['identifier'])[0])
|
tryUrlencode(fireEvent('library.query', media['library'], single = True)),
|
||||||
|
self.getCatId(quality['identifier'])[0]
|
||||||
|
)
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ class Season(SeasonProvider, Base):
|
|||||||
arguments = tryUrlencode({
|
arguments = tryUrlencode({
|
||||||
'user': host['name'],
|
'user': host['name'],
|
||||||
'passkey': host['pass_key'],
|
'passkey': host['pass_key'],
|
||||||
'search': fireEvent('searcher.get_search_title', media['library'], include_identifier = True, single = True)
|
'search': fireEvent('library.query', media['library'], single = True)
|
||||||
})
|
})
|
||||||
return '%s?%s' % (host['host'], arguments)
|
return '%s?%s' % (host['host'], arguments)
|
||||||
|
|
||||||
@@ -154,6 +154,6 @@ class Episode(EpisodeProvider, Base):
|
|||||||
arguments = tryUrlencode({
|
arguments = tryUrlencode({
|
||||||
'user': host['name'],
|
'user': host['name'],
|
||||||
'passkey': host['pass_key'],
|
'passkey': host['pass_key'],
|
||||||
'search': fireEvent('searcher.get_search_title', media['library'], include_identifier = True, single = True)
|
'search': fireEvent('library.query', media['library'], single = True)
|
||||||
})
|
})
|
||||||
return '%s?%s' % (host['host'], arguments)
|
return '%s?%s' % (host['host'], arguments)
|
||||||
|
|||||||
@@ -97,8 +97,7 @@ class Movie(MovieProvider, Base):
|
|||||||
cat_backup_id = 400
|
cat_backup_id = 400
|
||||||
|
|
||||||
def buildUrl(self, media, quality):
|
def buildUrl(self, media, quality):
|
||||||
query = (tryUrlencode('%s' % fireEvent('searcher.get_search_title',
|
query = (tryUrlencode(fireEvent('library.query', media['library'], single = True)),
|
||||||
media['library'], include_identifier = True, single = True)),
|
|
||||||
self.getCatId(quality['identifier'])[0],
|
self.getCatId(quality['identifier'])[0],
|
||||||
self.getSceneOnly())
|
self.getSceneOnly())
|
||||||
return query
|
return query
|
||||||
@@ -116,8 +115,7 @@ class Season(SeasonProvider, Base):
|
|||||||
cat_backup_id = 980
|
cat_backup_id = 980
|
||||||
|
|
||||||
def buildUrl(self, media, quality):
|
def buildUrl(self, media, quality):
|
||||||
query = (tryUrlencode('%s' % fireEvent('searcher.get_search_title',
|
query = (tryUrlencode(fireEvent('library.query', media['library'], single = True)),
|
||||||
media['library'], include_identifier = True, single = True)),
|
|
||||||
self.getCatId(quality['identifier'])[0],
|
self.getCatId(quality['identifier'])[0],
|
||||||
self.getSceneOnly())
|
self.getSceneOnly())
|
||||||
return query
|
return query
|
||||||
@@ -134,8 +132,7 @@ class Episode(EpisodeProvider, Base):
|
|||||||
cat_backup_id = 620
|
cat_backup_id = 620
|
||||||
|
|
||||||
def buildUrl(self, media, quality):
|
def buildUrl(self, media, quality):
|
||||||
query = (tryUrlencode('%s' % fireEvent('searcher.get_search_title',
|
query = (tryUrlencode(fireEvent('library.query', media['library'], single = True)),
|
||||||
media['library'], include_identifier = True, single = True)),
|
|
||||||
self.getCatId(quality['identifier'])[0],
|
self.getCatId(quality['identifier'])[0],
|
||||||
self.getSceneOnly())
|
self.getSceneOnly())
|
||||||
return query
|
return query
|
||||||
|
|||||||
@@ -184,6 +184,15 @@ class Library(Entity):
|
|||||||
root_library = related_libraries.get(root_key)
|
root_library = related_libraries.get(root_key)
|
||||||
orig_dict['root_library'] = root_library[0] if root_library else None
|
orig_dict['root_library'] = root_library[0] if root_library else None
|
||||||
|
|
||||||
|
# Add references to children
|
||||||
|
for key, libraries in related_libraries.items():
|
||||||
|
for library in libraries:
|
||||||
|
# Add related_libraries
|
||||||
|
library['related_libraries'] = orig_dict['related_libraries']
|
||||||
|
|
||||||
|
# Add root_library
|
||||||
|
library['root_library'] = orig_dict['root_library']
|
||||||
|
|
||||||
return orig_dict
|
return orig_dict
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user