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 couchpotato.core.plugins.base import Plugin
|
||||
from .main import Library
|
||||
|
||||
def start():
|
||||
return Library()
|
||||
|
||||
class LibraryBase(Plugin):
|
||||
|
||||
_type = None
|
||||
|
||||
def initType(self):
|
||||
addEvent('library.types', self.getType)
|
||||
|
||||
def getType(self):
|
||||
return self._type
|
||||
config = []
|
||||
|
||||
13
couchpotato/core/media/_base/library/base.py
Normal file
13
couchpotato/core/media/_base/library/base.py
Normal file
@@ -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
|
||||
18
couchpotato/core/media/_base/library/main.py
Normal file
18
couchpotato/core/media/_base/library/main.py
Normal file
@@ -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
|
||||
|
||||
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))
|
||||
|
||||
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.helpers.encoding import toUnicode, simplifyString
|
||||
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 string import ascii_letters
|
||||
import time
|
||||
@@ -16,10 +16,26 @@ class MovieLibraryPlugin(LibraryBase):
|
||||
default_dict = {'titles': {}, 'files':{}}
|
||||
|
||||
def __init__(self):
|
||||
addEvent('library.query', self.query)
|
||||
addEvent('library.add.movie', self.add)
|
||||
addEvent('library.update.movie', self.update)
|
||||
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):
|
||||
# movies don't yet contain these, so lets make sure to set defaults
|
||||
type = attrs.get('type', 'movie')
|
||||
|
||||
@@ -30,7 +30,6 @@ class MovieSearcher(SearcherBase, MovieTypeBase):
|
||||
addEvent('movie.searcher.try_next_release', self.tryNextRelease)
|
||||
addEvent('movie.searcher.could_be_released', self.couldBeReleased)
|
||||
addEvent('searcher.correct_release', self.correctRelease)
|
||||
addEvent('searcher.get_search_title', self.getSearchTitle)
|
||||
|
||||
addApiView('movie.searcher.try_next', self.tryNextReleaseView, docs = {
|
||||
'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
|
||||
|
||||
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)
|
||||
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())
|
||||
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):
|
||||
pass
|
||||
|
||||
@@ -3,7 +3,7 @@ from couchpotato.core.event import addEvent, fireEventAsync, fireEvent
|
||||
from couchpotato.core.helpers.encoding import toUnicode, simplifyString
|
||||
from couchpotato.core.logger import CPLog
|
||||
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 string import ascii_letters
|
||||
import time
|
||||
@@ -17,11 +17,44 @@ class EpisodeLibraryPlugin(LibraryBase):
|
||||
default_dict = {'titles': {}, 'files':{}}
|
||||
|
||||
def __init__(self):
|
||||
addEvent('library.query', self.query)
|
||||
addEvent('library.identifier', self.identifier)
|
||||
addEvent('library.add.episode', self.add)
|
||||
addEvent('library.update.episode', self.update)
|
||||
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):
|
||||
if library.get('type') != 'episode':
|
||||
return
|
||||
|
||||
@@ -3,7 +3,7 @@ from couchpotato.core.event import addEvent, fireEventAsync, fireEvent
|
||||
from couchpotato.core.helpers.encoding import toUnicode, simplifyString
|
||||
from couchpotato.core.logger import CPLog
|
||||
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 string import ascii_letters
|
||||
import time
|
||||
@@ -17,11 +17,52 @@ class SeasonLibraryPlugin(LibraryBase):
|
||||
default_dict = {'titles': {}, 'files':{}}
|
||||
|
||||
def __init__(self):
|
||||
addEvent('library.query', self.query)
|
||||
addEvent('library.identifier', self.identifier)
|
||||
addEvent('library.add.season', self.add)
|
||||
addEvent('library.update.season', self.update)
|
||||
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):
|
||||
if library.get('type') != 'season':
|
||||
return
|
||||
|
||||
@@ -3,7 +3,9 @@ from couchpotato.core.event import addEvent, fireEventAsync, fireEvent
|
||||
from couchpotato.core.helpers.encoding import toUnicode, simplifyString
|
||||
from couchpotato.core.logger import CPLog
|
||||
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
|
||||
import time
|
||||
import traceback
|
||||
@@ -16,10 +18,35 @@ class ShowLibraryPlugin(LibraryBase):
|
||||
default_dict = {'titles': {}, 'files':{}}
|
||||
|
||||
def __init__(self):
|
||||
self.query_condenser = QueryCondenser()
|
||||
|
||||
addEvent('library.query', self.query)
|
||||
addEvent('library.add.show', self.add)
|
||||
addEvent('library.update.show', self.update)
|
||||
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):
|
||||
type = attrs.get('type', 'show')
|
||||
primary_provider = attrs.get('primary_provider', 'thetvdb')
|
||||
|
||||
@@ -26,7 +26,6 @@ class ShowSearcher(Plugin):
|
||||
for type in toIterable(self.type):
|
||||
addEvent('%s.searcher.single' % type, self.single)
|
||||
|
||||
addEvent('searcher.get_search_title', self.getSearchTitle)
|
||||
addEvent('searcher.correct_release', self.correctRelease)
|
||||
|
||||
def single(self, media, search_protocols = None, manual = False):
|
||||
@@ -61,7 +60,7 @@ class ShowSearcher(Plugin):
|
||||
found_releases = []
|
||||
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:
|
||||
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)
|
||||
@@ -145,61 +144,6 @@ class ShowSearcher(Plugin):
|
||||
|
||||
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):
|
||||
|
||||
if media.get('type') not in ['season', 'episode']: return
|
||||
|
||||
@@ -207,7 +207,7 @@ class YarrProvider(Provider):
|
||||
self._search(media, quality, results)
|
||||
# Search possible titles
|
||||
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):
|
||||
self._searchOnTitle(title, media, quality, results)
|
||||
|
||||
@@ -101,7 +101,7 @@ class Movie(MovieProvider, Base):
|
||||
|
||||
def buildUrl(self, media, quality):
|
||||
query = tryUrlencode({
|
||||
'q': media['library']['identifier'],
|
||||
'q': media['library']['identifier'], # TODO should this use library.title?
|
||||
'm': 'n',
|
||||
'max': 400,
|
||||
'adv_age': Env.setting('retention', 'nzb'),
|
||||
@@ -117,7 +117,7 @@ class Season(SeasonProvider, Base):
|
||||
|
||||
def buildUrl(self, media, quality):
|
||||
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',
|
||||
'max': 400,
|
||||
'adv_age': Env.setting('retention', 'nzb'),
|
||||
@@ -133,7 +133,7 @@ class Episode(EpisodeProvider, Base):
|
||||
|
||||
def buildUrl(self, media, quality):
|
||||
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',
|
||||
'max': 400,
|
||||
'adv_age': Env.setting('retention', 'nzb'),
|
||||
|
||||
@@ -200,7 +200,7 @@ class Movie(MovieProvider, Base):
|
||||
class Season(SeasonProvider, Base):
|
||||
|
||||
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)
|
||||
|
||||
query = tryUrlencode({
|
||||
@@ -215,7 +215,7 @@ class Season(SeasonProvider, Base):
|
||||
class Episode(EpisodeProvider, Base):
|
||||
|
||||
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)
|
||||
|
||||
query = tryUrlencode({
|
||||
|
||||
@@ -80,8 +80,7 @@ class Movie(MovieProvider, Base):
|
||||
|
||||
def buildUrl(self, media):
|
||||
query = tryUrlencode({
|
||||
'q': '"%s %s"' % (fireEvent('searcher.get_search_title', media['library'], include_identifier = True,
|
||||
single = True), media['library']['year']),
|
||||
'q': '"%s"' % fireEvent('library.query', media['library'], single = True),
|
||||
'ig': 1,
|
||||
'rpp': 200,
|
||||
'st': 5,
|
||||
@@ -94,7 +93,7 @@ class Season(SeasonProvider, Base):
|
||||
|
||||
def buildUrl(self, media):
|
||||
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,
|
||||
'rpp': 200,
|
||||
'st': 5,
|
||||
@@ -107,7 +106,7 @@ class Episode(EpisodeProvider, Base):
|
||||
|
||||
def buildUrl(self, media):
|
||||
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,
|
||||
'rpp': 200,
|
||||
'st': 5,
|
||||
|
||||
@@ -104,7 +104,7 @@ class Base(NZBProvider, RSS):
|
||||
class Movie(MovieProvider, Base):
|
||||
|
||||
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']
|
||||
|
||||
query = tryUrlencode({
|
||||
@@ -124,7 +124,7 @@ class Season(SeasonProvider, Base):
|
||||
|
||||
def buildUrl(self, media, quality):
|
||||
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'),
|
||||
'sort': 'agedesc',
|
||||
'minsize': quality.get('size_min'),
|
||||
@@ -140,7 +140,7 @@ class Episode(EpisodeProvider, Base):
|
||||
|
||||
def buildUrl(self, media, quality):
|
||||
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'),
|
||||
'sort': 'agedesc',
|
||||
'minsize': quality.get('size_min'),
|
||||
|
||||
@@ -95,8 +95,7 @@ class Movie(MovieProvider, Base):
|
||||
|
||||
def buildUrl(self, media):
|
||||
query = tryUrlencode({
|
||||
'search': fireEvent('searcher.get_search_title', media['library'],
|
||||
include_identifier = True, single = True),
|
||||
'search': fireEvent('library.query', media['library'], single = True),
|
||||
'cat': 7 # Movie cat
|
||||
})
|
||||
return query
|
||||
@@ -105,8 +104,7 @@ class Season(SeasonProvider, Base):
|
||||
|
||||
def buildUrl(self, media):
|
||||
query = tryUrlencode({
|
||||
'search': fireEvent('searcher.get_search_title', media['library'],
|
||||
include_identifier = True, single = True),
|
||||
'search': fireEvent('library.query', media['library'], single = True),
|
||||
'cat': 12 # Season cat
|
||||
})
|
||||
return query
|
||||
@@ -115,8 +113,7 @@ class Episode(EpisodeProvider, Base):
|
||||
|
||||
def buildUrl(self, media):
|
||||
query = tryUrlencode({
|
||||
'search': fireEvent('searcher.get_search_title', media['library'],
|
||||
include_identifier = True, single = True),
|
||||
'search': fireEvent('library.query', media['library'], single = True),
|
||||
'cat': 10 # Episode cat
|
||||
})
|
||||
return query
|
||||
@@ -113,9 +113,10 @@ class Movie(MovieProvider, Base):
|
||||
|
||||
def buildUrl(self, media, quality):
|
||||
query = tryUrlencode({
|
||||
'search': '"%s" %s' % (fireEvent('searcher.get_search_title',
|
||||
media['library'], include_identifier = False, single = True),
|
||||
media['library']['year']),
|
||||
'search': '"%s" %s' % (
|
||||
fireEvent('library.query', media['library'], include_year = False, single = True),
|
||||
media['library']['year']
|
||||
),
|
||||
'cat': self.getCatId(quality['identifier'])[0],
|
||||
})
|
||||
return query
|
||||
@@ -124,8 +125,7 @@ class Season(SeasonProvider, Base):
|
||||
# For season bundles, bitsoup currently only has one category
|
||||
def buildUrl(self, media, quality):
|
||||
query = tryUrlencode({
|
||||
'search': fireEvent('searcher.get_search_title', media['library'],
|
||||
include_identifier = True, single = True),
|
||||
'search': fireEvent('library.query', media['library'], single = True),
|
||||
'cat': 45 # TV-Packs Category
|
||||
})
|
||||
return query
|
||||
@@ -139,8 +139,7 @@ class Episode(EpisodeProvider, Base):
|
||||
|
||||
def buildUrl(self, media, quality):
|
||||
query = tryUrlencode({
|
||||
'search': fireEvent('searcher.get_search_title', media['library'],
|
||||
include_identifier = True, single = True),
|
||||
'search': fireEvent('library.query', media['library'], single = True),
|
||||
'cat': self.getCatId(quality['identifier'])[0],
|
||||
})
|
||||
return query
|
||||
|
||||
@@ -99,14 +99,14 @@ class Base(TorrentMagnetProvider):
|
||||
class Movie(MovieProvider, Base):
|
||||
|
||||
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):
|
||||
|
||||
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):
|
||||
|
||||
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({
|
||||
'search': fireEvent('searcher.get_search_title', media['library'], include_identifier = True, single = True),
|
||||
'search': fireEvent('library.query', media['library'], single = True),
|
||||
'method': 2,
|
||||
})
|
||||
query = "%s&%s" % (url, arguments)
|
||||
@@ -124,7 +124,7 @@ class Season(SeasonProvider, Base):
|
||||
)
|
||||
|
||||
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,
|
||||
})
|
||||
query = "%s&%s" % (url, arguments)
|
||||
@@ -145,7 +145,7 @@ class Episode(EpisodeProvider, Base):
|
||||
)
|
||||
|
||||
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,
|
||||
})
|
||||
query = "%s&%s" % (url, arguments)
|
||||
|
||||
@@ -130,8 +130,11 @@ class Movie(MovieProvider, Base):
|
||||
]
|
||||
|
||||
def buildUrl(self, media, page, cats):
|
||||
return tryUrlencode('"%s"' % fireEvent('searcher.get_search_title', media['library'],
|
||||
include_identifier = True, single = True)), page, ','.join(str(x) for x in cats)
|
||||
return (
|
||||
tryUrlencode('"%s"' % fireEvent('library.query', media['library'], single = True)),
|
||||
page,
|
||||
','.join(str(x) for x in cats)
|
||||
)
|
||||
|
||||
class Season(SeasonProvider, Base):
|
||||
|
||||
@@ -141,8 +144,11 @@ class Season(SeasonProvider, Base):
|
||||
]
|
||||
|
||||
def buildUrl(self, media, page, cats):
|
||||
return tryUrlencode('"%s"' % fireEvent('searcher.get_search_title', media['library'],
|
||||
include_identifier = True, single = True)), page, ','.join(str(x) for x in cats)
|
||||
return (
|
||||
tryUrlencode('"%s"' % fireEvent('library.query', media['library'], single = True)),
|
||||
page,
|
||||
','.join(str(x) for x in cats)
|
||||
)
|
||||
|
||||
class Episode(EpisodeProvider, Base):
|
||||
|
||||
@@ -152,5 +158,8 @@ class Episode(EpisodeProvider, Base):
|
||||
]
|
||||
|
||||
def buildUrl(self, media, page, cats):
|
||||
return tryUrlencode('"%s"' % fireEvent('searcher.get_search_title', media['library'],
|
||||
include_identifier = True, single = True)), page, ','.join(str(x) for x in cats)
|
||||
return (
|
||||
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']),
|
||||
]
|
||||
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):
|
||||
|
||||
@@ -84,7 +84,7 @@ class Season(SeasonProvider, Base):
|
||||
([14], ['hdtv_sd', 'hdtv_720p', 'webdl_720p', 'webdl_1080p']),
|
||||
]
|
||||
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):
|
||||
cat_ids = [
|
||||
@@ -92,5 +92,5 @@ class Episode(EpisodeProvider, Base):
|
||||
([2], [24], [26], ['hdtv_sd'])
|
||||
]
|
||||
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):
|
||||
return (tryUrlencode('%s' % fireEvent('searcher.get_search_title',
|
||||
media['library'], include_identifier = True, single = True)), self.getCatId(quality['identifier'])[0])
|
||||
return (
|
||||
tryUrlencode(fireEvent('library.query', media['library'], single = True)),
|
||||
self.getCatId(quality['identifier'])[0]
|
||||
)
|
||||
|
||||
class Season(SeasonProvider, Base):
|
||||
|
||||
@@ -100,8 +102,10 @@ class Season(SeasonProvider, Base):
|
||||
]
|
||||
|
||||
def buildUrl(self, media, quality):
|
||||
return (tryUrlencode('%s' % fireEvent('searcher.get_search_title',
|
||||
media['library'], include_identifier = True, single = True)), self.getCatId(quality['identifier'])[0])
|
||||
return (
|
||||
tryUrlencode(fireEvent('library.query', media['library'], single = True)),
|
||||
self.getCatId(quality['identifier'])[0]
|
||||
)
|
||||
|
||||
class Episode(EpisodeProvider, Base):
|
||||
|
||||
@@ -111,5 +115,7 @@ class Episode(EpisodeProvider, Base):
|
||||
]
|
||||
|
||||
def buildUrl(self, media, quality):
|
||||
return (tryUrlencode('%s' % fireEvent('searcher.get_search_title',
|
||||
media['library'], include_identifier = True, single = True)), self.getCatId(quality['identifier'])[0])
|
||||
return (
|
||||
tryUrlencode(fireEvent('library.query', media['library'], single = True)),
|
||||
self.getCatId(quality['identifier'])[0]
|
||||
)
|
||||
|
||||
@@ -144,7 +144,7 @@ class Season(SeasonProvider, Base):
|
||||
arguments = tryUrlencode({
|
||||
'user': host['name'],
|
||||
'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)
|
||||
|
||||
@@ -154,6 +154,6 @@ class Episode(EpisodeProvider, Base):
|
||||
arguments = tryUrlencode({
|
||||
'user': host['name'],
|
||||
'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)
|
||||
|
||||
@@ -97,8 +97,7 @@ class Movie(MovieProvider, Base):
|
||||
cat_backup_id = 400
|
||||
|
||||
def buildUrl(self, media, quality):
|
||||
query = (tryUrlencode('%s' % fireEvent('searcher.get_search_title',
|
||||
media['library'], include_identifier = True, single = True)),
|
||||
query = (tryUrlencode(fireEvent('library.query', media['library'], single = True)),
|
||||
self.getCatId(quality['identifier'])[0],
|
||||
self.getSceneOnly())
|
||||
return query
|
||||
@@ -116,8 +115,7 @@ class Season(SeasonProvider, Base):
|
||||
cat_backup_id = 980
|
||||
|
||||
def buildUrl(self, media, quality):
|
||||
query = (tryUrlencode('%s' % fireEvent('searcher.get_search_title',
|
||||
media['library'], include_identifier = True, single = True)),
|
||||
query = (tryUrlencode(fireEvent('library.query', media['library'], single = True)),
|
||||
self.getCatId(quality['identifier'])[0],
|
||||
self.getSceneOnly())
|
||||
return query
|
||||
@@ -134,8 +132,7 @@ class Episode(EpisodeProvider, Base):
|
||||
cat_backup_id = 620
|
||||
|
||||
def buildUrl(self, media, quality):
|
||||
query = (tryUrlencode('%s' % fireEvent('searcher.get_search_title',
|
||||
media['library'], include_identifier = True, single = True)),
|
||||
query = (tryUrlencode(fireEvent('library.query', media['library'], single = True)),
|
||||
self.getCatId(quality['identifier'])[0],
|
||||
self.getSceneOnly())
|
||||
return query
|
||||
|
||||
@@ -184,6 +184,15 @@ class Library(Entity):
|
||||
root_library = related_libraries.get(root_key)
|
||||
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
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user