Attach shows to searcher
This commit is contained in:
1 parent
fa78d18890
commit
6070209d33
3 files changed
+20
-22
No files matched your search
@@ -27,7 +27,7 @@ Block.Search.MovieItem = new Class({
|
|||||||
self.options_el = new Element('div.options.inlay'),
|
self.options_el = new Element('div.options.inlay'),
|
||||||
self.data_container = new Element('div.data', {
|
self.data_container = new Element('div.data', {
|
||||||
'events': {
|
'events': {
|
||||||
'click': self.movieOptions.bind(self)
|
'click': self.showOptions.bind(self)
|
||||||
}
|
}
|
||||||
}).adopt(
|
}).adopt(
|
||||||
self.info_container = new Element('div.info').adopt(
|
self.info_container = new Element('div.info').adopt(
|
||||||
@@ -71,7 +71,7 @@ Block.Search.MovieItem = new Class({
|
|||||||
return this.info[key]
|
return this.info[key]
|
||||||
},
|
},
|
||||||
|
|
||||||
movieOptions: function(){
|
showOptions: function(){
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
self.createOptions();
|
self.createOptions();
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ Block.Search.ShowItem = new Class({
|
|||||||
var self = this,
|
var self = this,
|
||||||
info = self.info;
|
info = self.info;
|
||||||
|
|
||||||
self.el = new Element('div.show_result', {
|
self.el = new Element('div.media_result', {
|
||||||
'id': info.id
|
'id': info.id
|
||||||
}).adopt(
|
}).adopt(
|
||||||
self.thumbnail = info.images && info.images.poster.length > 0 ? new Element('img.thumbnail', {
|
self.thumbnail = info.images && info.images.poster.length > 0 ? new Element('img.thumbnail', {
|
||||||
@@ -98,10 +98,7 @@ Block.Search.ShowItem = new Class({
|
|||||||
|
|
||||||
Api.request('show.add', {
|
Api.request('show.add', {
|
||||||
'data': {
|
'data': {
|
||||||
'identifier': self.info.id,
|
'identifier': self.info.imdb,
|
||||||
'id': self.info.id,
|
|
||||||
'type': self.info.type,
|
|
||||||
'primary_provider': self.info.primary_provider,
|
|
||||||
'title': self.title_select.get('value'),
|
'title': self.title_select.get('value'),
|
||||||
'profile_id': self.profile_select.get('value'),
|
'profile_id': self.profile_select.get('value'),
|
||||||
'category_id': self.category_select.get('value')
|
'category_id': self.category_select.get('value')
|
||||||
@@ -110,7 +107,7 @@ Block.Search.ShowItem = new Class({
|
|||||||
self.options_el.empty();
|
self.options_el.empty();
|
||||||
self.options_el.adopt(
|
self.options_el.adopt(
|
||||||
new Element('div.message', {
|
new Element('div.message', {
|
||||||
'text': json.added ? 'Show successfully added.' : 'Show didn\'t add properly. Check logs'
|
'text': json.added ? 'Movie successfully added.' : 'Movie didn\'t add properly. Check logs'
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
self.mask.fade('out');
|
self.mask.fade('out');
|
||||||
@@ -144,10 +141,10 @@ Block.Search.ShowItem = new Class({
|
|||||||
|
|
||||||
self.options_el.grab(
|
self.options_el.grab(
|
||||||
new Element('div', {
|
new Element('div', {
|
||||||
'class': self.info.in_wanted && self.info.in_wanted.profile || in_library ? 'in_library_wanted' : ''
|
'class': self.info.in_wanted && self.info.in_wanted.profile_id || in_library ? 'in_library_wanted' : ''
|
||||||
}).adopt(
|
}).adopt(
|
||||||
self.info.in_wanted && self.info.in_wanted.profile ? new Element('span.in_wanted', {
|
self.info.in_wanted && self.info.in_wanted.profile_id ? new Element('span.in_wanted', {
|
||||||
'text': 'Already in wanted list: ' + self.info.in_wanted.profile.label
|
'text': 'Already in wanted list: ' + Quality.getProfile(self.info.in_wanted.profile_id).get('label')
|
||||||
}) : (in_library ? new Element('span.in_library', {
|
}) : (in_library ? new Element('span.in_library', {
|
||||||
'text': 'Already in library: ' + in_library.join(', ')
|
'text': 'Already in library: ' + in_library.join(', ')
|
||||||
}) : null),
|
}) : null),
|
||||||
@@ -208,7 +205,7 @@ Block.Search.ShowItem = new Class({
|
|||||||
self.options_el.addClass('set');
|
self.options_el.addClass('set');
|
||||||
|
|
||||||
if(categories.length == 0 && self.title_select.getElements('option').length == 1 && profiles.length == 1 &&
|
if(categories.length == 0 && self.title_select.getElements('option').length == 1 && profiles.length == 1 &&
|
||||||
!(self.info.in_wanted && self.info.in_wanted.profile || in_library))
|
!(self.info.in_wanted && self.info.in_wanted.profile_id || in_library))
|
||||||
self.add();
|
self.add();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ log = CPLog(__name__)
|
|||||||
class TheTVDb(ShowProvider):
|
class TheTVDb(ShowProvider):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
addEvent('info.search', self.search, priority = 1)
|
||||||
addEvent('show.search', self.search, priority = 1)
|
addEvent('show.search', self.search, priority = 1)
|
||||||
addEvent('show.info', self.getShowInfo, priority = 1)
|
addEvent('show.info', self.getShowInfo, priority = 1)
|
||||||
addEvent('season.info', self.getSeasonInfo, priority = 1)
|
addEvent('season.info', self.getSeasonInfo, priority = 1)
|
||||||
@@ -35,7 +36,7 @@ class TheTVDb(ShowProvider):
|
|||||||
self.tvdb = tvdb_api.Tvdb(**self.tvdb_api_parms)
|
self.tvdb = tvdb_api.Tvdb(**self.tvdb_api_parms)
|
||||||
self.valid_languages = self.tvdb.config['valid_languages']
|
self.valid_languages = self.tvdb.config['valid_languages']
|
||||||
|
|
||||||
def search(self, q, limit = 12, language='en'):
|
def search(self, q, limit = 12, language = 'en'):
|
||||||
''' Find show by name
|
''' Find show by name
|
||||||
show = { 'id': 74713,
|
show = { 'id': 74713,
|
||||||
'language': 'en',
|
'language': 'en',
|
||||||
@@ -48,7 +49,7 @@ class TheTVDb(ShowProvider):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
if language != self.tvdb_api_parms['language'] and language in self.valid_languages:
|
if language != self.tvdb_api_parms['language'] and language in self.valid_languages:
|
||||||
self.tvdb_api_parms['language'] = language
|
self.tvdb_api_parms['language'] = language
|
||||||
self._setup()
|
self._setup()
|
||||||
|
|
||||||
search_string = simplifyString(q)
|
search_string = simplifyString(q)
|
||||||
@@ -103,7 +104,7 @@ class TheTVDb(ShowProvider):
|
|||||||
if result:
|
if result:
|
||||||
return result
|
return result
|
||||||
|
|
||||||
show = self.getShow(identifier=identifier)
|
show = self.getShow(identifier = identifier)
|
||||||
if show:
|
if show:
|
||||||
result = self._parseShow(show)
|
result = self._parseShow(show)
|
||||||
self.setCache(cache_key, result)
|
self.setCache(cache_key, result)
|
||||||
@@ -164,7 +165,7 @@ class TheTVDb(ShowProvider):
|
|||||||
if season_identifier:
|
if season_identifier:
|
||||||
try:
|
try:
|
||||||
identifier, season_identifier = season_identifier.split(':')
|
identifier, season_identifier = season_identifier.split(':')
|
||||||
season_identifier = int(season_identifier)
|
season_identifier = int(season_identifier)
|
||||||
except: return None
|
except: return None
|
||||||
|
|
||||||
cache_key = 'thetvdb.cache.%s.%s.%s' % (identifier, episode_identifier, season_identifier)
|
cache_key = 'thetvdb.cache.%s.%s.%s' % (identifier, episode_identifier, season_identifier)
|
||||||
@@ -236,8 +237,8 @@ class TheTVDb(ShowProvider):
|
|||||||
|
|
||||||
genres = [] if show['genre'] is None else show['genre'].strip('|').split('|')
|
genres = [] if show['genre'] is None else show['genre'].strip('|').split('|')
|
||||||
if show['firstaired'] is not None:
|
if show['firstaired'] is not None:
|
||||||
try: year = datetime.strptime(show['firstaired'], '%Y-%m-%d').year
|
try: year = datetime.strptime(show['firstaired'], '%Y-%m-%d').year
|
||||||
except: year = None
|
except: year = None
|
||||||
else:
|
else:
|
||||||
year = None
|
year = None
|
||||||
|
|
||||||
@@ -299,7 +300,7 @@ class TheTVDb(ShowProvider):
|
|||||||
poster = []
|
poster = []
|
||||||
try:
|
try:
|
||||||
for id, data in show.data['_banners']['season']['season'].items():
|
for id, data in show.data['_banners']['season']['season'].items():
|
||||||
if data.get('season', None) == str(number) and data['bannertype'] == 'season' and data['bannertype2'] == 'season':
|
if data.get('season', None) == str(number) and data['bannertype'] == 'season' and data['bannertype2'] == 'season':
|
||||||
poster.append(data.get('_bannerpath'))
|
poster.append(data.get('_bannerpath'))
|
||||||
break # Only really need one
|
break # Only really need one
|
||||||
except:
|
except:
|
||||||
@@ -374,13 +375,13 @@ class TheTVDb(ShowProvider):
|
|||||||
poster = episode['filename'] or []
|
poster = episode['filename'] or []
|
||||||
backdrop = []
|
backdrop = []
|
||||||
genres = []
|
genres = []
|
||||||
plot = "%s - %sx%s - %s" % (show['seriesname'],
|
plot = "%s - %sx%s - %s" % (show['seriesname'],
|
||||||
episode['seasonnumber'],
|
episode['seasonnumber'],
|
||||||
episode['episodenumber'],
|
episode['episodenumber'],
|
||||||
episode['overview'])
|
episode['overview'])
|
||||||
if episode['firstaired'] is not None:
|
if episode['firstaired'] is not None:
|
||||||
try: year = datetime.strptime(episode['firstaired'], '%Y-%m-%d').year
|
try: year = datetime.strptime(episode['firstaired'], '%Y-%m-%d').year
|
||||||
except: year = None
|
except: year = None
|
||||||
else:
|
else:
|
||||||
year = None
|
year = None
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user