added posters for seasons

This commit is contained in:
Jason Mehring committed 2013-09-11 00:36:12 -04:00
1 parent a37a4a8cd4
commit e180addc3c
2 files changed
+70 -74

No files matched your search

@@ -135,23 +135,23 @@ class SeasonLibraryPlugin(LibraryBase):
db.commit() db.commit()
# Files # Files
#images = info.get('images', []) images = info.get('images', [])
#for image_type in ['poster']: for image_type in ['poster']:
#for image in images.get(image_type, []): for image in images.get(image_type, []):
#if not isinstance(image, (str, unicode)): if not isinstance(image, (str, unicode)):
#continue continue
#file_path = fireEvent('file.download', url = image, single = True) file_path = fireEvent('file.download', url = image, single = True)
#if file_path: if file_path:
#file_obj = fireEvent('file.add', path = file_path, type_tuple = ('image', image_type), single = True) file_obj = fireEvent('file.add', path = file_path, type_tuple = ('image', image_type), single = True)
#try: try:
#file_obj = db.query(File).filter_by(id = file_obj.get('id')).one() file_obj = db.query(File).filter_by(id = file_obj.get('id')).one()
#library.files.append(file_obj) library.files.append(file_obj)
#db.commit() db.commit()
#break break
#except: except:
#log.debug('Failed to attach to library: %s', traceback.format_exc()) log.debug('Failed to attach to library: %s', traceback.format_exc())
library_dict = library.to_dict(self.default_dict) library_dict = library.to_dict(self.default_dict)
+55 -59
View File
@@ -11,12 +11,8 @@ import os
log = CPLog(__name__) log = CPLog(__name__)
# TODO: Consider grabbing zips to put less strain on tvdb # TODO: Consider grabbing zips to put less strain on tvdb
# TODO: Unicode stuff (check)
# TODO: alternate titles do exist for show and episodes; add them # TODO: Notigy frontend on error (tvdb down at monent)
# TODO: Unicode stuff
# TODO: cwNotifyNotigy frontend on error (tvdb down at monent)
# TODO: Expose apikey in setting so it can be changed by user # TODO: Expose apikey in setting so it can be changed by user
class TheTVDb(ShowProvider): class TheTVDb(ShowProvider):
@@ -74,7 +70,7 @@ class TheTVDb(ShowProvider):
nr = 0 nr = 0
for show_info in raw: for show_info in raw:
show = self.tvdb[int(show_info['id'])] show = self.tvdb[int(show_info['id'])]
results.append(self.parseShow(show)) results.append(self._parseShow(show))
nr += 1 nr += 1
if nr == limit: if nr == limit:
break break
@@ -109,7 +105,7 @@ class TheTVDb(ShowProvider):
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)
return result return result
@@ -142,11 +138,11 @@ class TheTVDb(ShowProvider):
result = [] result = []
for number, season in show.items(): for number, season in show.items():
if season_identifier is not None and number == season_identifier: if season_identifier is not None and number == season_identifier:
result = self.parseSeason(show, (number, season)) result = self._parseSeason(show, (number, season))
self.setCache(cache_key, result) self.setCache(cache_key, result)
return result return result
else: else:
result.append(self.parseSeason(show, (number, season))) result.append(self._parseSeason(show, (number, season)))
self.setCache(cache_key, result) self.setCache(cache_key, result)
return result return result
@@ -185,43 +181,42 @@ class TheTVDb(ShowProvider):
for episode in season.values(): for episode in season.values():
if episode_identifier is not None and episode['id'] == toUnicode(episode_identifier): if episode_identifier is not None and episode['id'] == toUnicode(episode_identifier):
result = self.parseEpisode(show, episode) result = self._parseEpisode(show, episode)
self.setCache(cache_key, result) self.setCache(cache_key, result)
return result return result
else: else:
result.append(self.parseEpisode(show, episode)) result.append(self._parseEpisode(show, episode))
self.setCache(cache_key, result) self.setCache(cache_key, result)
return result return result
def parseShow(self, show): def _parseShow(self, show):
""" """
show[74713] = { 'actors': u'|Bryan Cranston|Aaron Paul|Dean Norris|RJ Mitte|Betsy Brandt|Anna Gunn|Laura Fraser|Jesse Plemons|Christopher Cousins|Steven Michael Quezada|Jonathan Banks|Giancarlo Esposito|Bob Odenkirk|',
'actors': u'|Bryan Cranston|Aaron Paul|Dean Norris|RJ Mitte|Betsy Brandt|Anna Gunn|Laura Fraser|Jesse Plemons|Christopher Cousins|Steven Michael Quezada|Jonathan Banks|Giancarlo Esposito|Bob Odenkirk|', 'added': None,
'added': None, 'addedby': None,
'addedby': None, 'airs_dayofweek': u'Sunday',
'airs_dayofweek': u'Sunday', 'airs_time': u'9:00 PM',
'airs_time': u'9:00 PM', 'banner': u'http://thetvdb.com/banners/graphical/81189-g13.jpg',
'banner': u'http://thetvdb.com/banners/graphical/81189-g13.jpg', 'contentrating': u'TV-MA',
'contentrating': u'TV-MA', 'fanart': u'http://thetvdb.com/banners/fanart/original/81189-28.jpg',
'fanart': u'http://thetvdb.com/banners/fanart/original/81189-28.jpg', 'firstaired': u'2008-01-20',
'firstaired': u'2008-01-20', 'genre': u'|Crime|Drama|Suspense|',
'genre': u'|Crime|Drama|Suspense|', 'id': u'81189',
'id': u'81189', 'imdb_id': u'tt0903747',
'imdb_id': u'tt0903747', 'language': u'en',
'language': u'en', 'lastupdated': u'1376620212',
'lastupdated': u'1376620212', 'network': u'AMC',
'network': u'AMC', 'networkid': None,
'networkid': None, 'overview': u"Walter White, a struggling high school chemistry teacher is diagnosed with advanced lung cancer. He turns to a life of crime, producing and selling methamphetamine accompanied by a former student, Jesse Pinkman with the aim of securing his family's financial future before he dies.",
'overview': u"Walter White, a struggling high school chemistry teacher is diagnosed with advanced lung cancer. He turns to a life of crime, producing and selling methamphetamine accompanied by a former student, Jesse Pinkman with the aim of securing his family's financial future before he dies.", 'poster': u'http://thetvdb.com/banners/posters/81189-22.jpg',
'poster': u'http://thetvdb.com/banners/posters/81189-22.jpg', 'rating': u'9.3',
'rating': u'9.3', 'ratingcount': u'473',
'ratingcount': u'473', 'runtime': u'60',
'runtime': u'60', 'seriesid': u'74713',
'seriesid': u'74713', 'seriesname': u'Breaking Bad',
'seriesname': u'Breaking Bad', 'status': u'Continuing',
'status': u'Continuing', 'zap2it_id': u'SH01009396'
'zap2it_id': u'SH01009396'}
""" """
# Make sure we have a valid show id, not '' or None # Make sure we have a valid show id, not '' or None
@@ -285,17 +280,25 @@ class TheTVDb(ShowProvider):
for alt_name in show_info['aliasnames'].split('|'): for alt_name in show_info['aliasnames'].split('|'):
show_data['titles'].append(toUnicode(alt_name)) show_data['titles'].append(toUnicode(alt_name))
except (tvdb_exceptions.tvdb_error, IOError), e: except (tvdb_exceptions.tvdb_error, IOError), e:
log.error('Failed searching TheTVDB for "%s": %s', (search_string, traceback.format_exc())) log.error('Failed searching TheTVDB for "%s": %s', (show['seriesname'], traceback.format_exc()))
return show_data return show_data
def parseSeason(self, show, season_tuple): def _parseSeason(self, show, season_tuple):
""" """
contains no data contains no data
""" """
number, season = season_tuple number, season = season_tuple
title = toUnicode('%s - Season %s' % (show['seriesname'], str(number))) title = toUnicode('%s - Season %s' % (show['seriesname'], str(number)))
poster = []
try:
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':
poster.append(data.get('_bannerpath'))
break # Only really need one
except:
pass
# XXX: work on title; added defualt_title to fix an error # XXX: work on title; added defualt_title to fix an error
season_data = { season_data = {
@@ -308,7 +311,7 @@ class TheTVDb(ShowProvider):
'parent_identifier': show['id'], 'parent_identifier': show['id'],
'seasonnumber': str(number), 'seasonnumber': str(number),
'images': { 'images': {
'poster': [], 'poster': poster,
'backdrop': [], 'backdrop': [],
'poster_original': [], 'poster_original': [],
'backdrop_original': [], 'backdrop_original': [],
@@ -321,7 +324,7 @@ class TheTVDb(ShowProvider):
season_data = dict((k, v) for k, v in season_data.iteritems() if v) season_data = dict((k, v) for k, v in season_data.iteritems() if v)
return season_data return season_data
def parseEpisode(self, show, episode): def _parseEpisode(self, show, episode):
""" """
('episodenumber', u'1'), ('episodenumber', u'1'),
('thumb_added', None), ('thumb_added', None),
@@ -425,26 +428,19 @@ class TheTVDb(ShowProvider):
} }
episode_data = dict((k, v) for k, v in episode_data.iteritems() if v) episode_data = dict((k, v) for k, v in episode_data.iteritems() if v)
## Add alternative names
#for alt in ['original_name', 'alternative_name']:
#alt_name = toUnicode(episode['alt))
#if alt_name and not alt_name in episode_data['titles'] and alt_name.lower() != 'none' and alt_name != None:
#episode_data['titles'].append(alt_name)
return episode_data return episode_data
def getImage(self, show, type = 'poster', size = 'cover'): #def getImage(self, show, type = 'poster', size = 'cover'):
"""""" #""""""
# XXX: Need to implement size ## XXX: Need to implement size
image_url = '' #image_url = ''
for res, res_data in show['_banners'].get(type, {}).items(): #for res, res_data in show['_banners'].get(type, {}).items():
for bid, banner_info in res_data.items(): #for bid, banner_info in res_data.items():
image_url = banner_info.get('_bannerpath', '') #image_url = banner_info.get('_bannerpath', '')
break #break
return image_url #return image_url
def isDisabled(self): def isDisabled(self):
if self.conf('api_key') == '': if self.conf('api_key') == '':