commit
21030e7cb4
6 files changed
+232
-100
No files matched your search
@@ -83,7 +83,7 @@ class ShowBase(MediaBase):
|
|||||||
'movie': movie_dict,
|
'movie': movie_dict,
|
||||||
}
|
}
|
||||||
|
|
||||||
def debug(self):
|
def debug(self, identifier):
|
||||||
"""
|
"""
|
||||||
XXX: This is only a hook for a breakpoint so we can test database stuff easily
|
XXX: This is only a hook for a breakpoint so we can test database stuff easily
|
||||||
REMOVE when finished
|
REMOVE when finished
|
||||||
@@ -99,7 +99,7 @@ class ShowBase(MediaBase):
|
|||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
db = get_session()
|
db = get_session()
|
||||||
#parent = db.query(Library).filter_by(identifier = attrs.get('')).first()
|
parent = db.query(Library).filter_by(identifier = identifier).first()
|
||||||
return
|
return
|
||||||
|
|
||||||
def add(self, params = {}, force_readd = True, search_after = True, update_library = False, status_id = None):
|
def add(self, params = {}, force_readd = True, search_after = True, update_library = False, status_id = None):
|
||||||
@@ -126,18 +126,36 @@ class ShowBase(MediaBase):
|
|||||||
# Add show parent to db first
|
# Add show parent to db first
|
||||||
parent = self.addToDatabase(params = params, type = 'show')
|
parent = self.addToDatabase(params = params, type = 'show')
|
||||||
|
|
||||||
skip = False # XXX: For debugging
|
|
||||||
identifier = params.get('id')
|
identifier = params.get('id')
|
||||||
episodes = fireEvent('show.episodes', identifier = identifier)
|
|
||||||
|
|
||||||
# XXX: Fix so we dont have a nested list
|
# XXX: add seasons
|
||||||
if episodes is not None and skip is False:
|
# XXX: Fix so we dont have a nested list [0] (fireEvent)
|
||||||
for episode in episodes[0]:
|
try:
|
||||||
episode['title'] = episode.get('titles', None)[0]
|
seasons = fireEvent('season.info', identifier = identifier)[0]
|
||||||
episode['identifier'] = episode.get('id', None)
|
except: return None
|
||||||
episode['parent_identifier'] = identifier
|
if seasons is not None:
|
||||||
self.addToDatabase(params=episode, type = "episode")
|
for season in seasons:
|
||||||
|
season['title'] = season.get('title', None)
|
||||||
|
season_id = season.get('id', None)
|
||||||
|
if season_id is None: continue
|
||||||
|
season['identifier'] = season_id
|
||||||
|
season['parent_identifier'] = identifier
|
||||||
|
self.addToDatabase(params=season, type = "season")
|
||||||
|
|
||||||
|
# XXX: Fix so we dont have a nested list [0] (fireEvent)
|
||||||
|
try:
|
||||||
|
episodes = fireEvent('episode.info', identifier = identifier, season_identifier = season_id)[0]
|
||||||
|
except: continue
|
||||||
|
if episodes is not None:
|
||||||
|
for episode in episodes:
|
||||||
|
episode['title'] = episode.get('titles', None)[0] # XXX. [0] will create exception. FIX!
|
||||||
|
episode_id = episode.get('id', None)
|
||||||
|
if episode_id is None: continue
|
||||||
|
episode['identifier'] = episode_id
|
||||||
|
episode['parent_identifier'] = season['identifier']
|
||||||
|
self.addToDatabase(params=episode, type = "episode")
|
||||||
|
|
||||||
|
self.debug(str(identifier)) # XXX: Remove TODO: Add Show(extend Library) convience options for db seasching
|
||||||
return parent
|
return parent
|
||||||
|
|
||||||
def addToDatabase(self, params = {}, type="show", force_readd = True, search_after = True, update_library = False, status_id = None):
|
def addToDatabase(self, params = {}, type="show", force_readd = True, search_after = True, update_library = False, status_id = None):
|
||||||
|
|||||||
@@ -88,8 +88,12 @@ class EpisodeLibraryPlugin(LibraryBase):
|
|||||||
if library.status_id == done_status.get('id') and not force:
|
if library.status_id == done_status.get('id') and not force:
|
||||||
do_update = False
|
do_update = False
|
||||||
|
|
||||||
info = fireEvent('episode.info', merge = True, identifier = identifier, \
|
#info = fireEvent('episode.info', merge = True, identifier = identifier, \
|
||||||
parent_identifier = parent_identifier)
|
# parent_identifier = parent_identifier)
|
||||||
|
#info = fireEvent('episode.info', merge = True, identifier = parent_identifier, \
|
||||||
|
# episode_identifier = identifier)
|
||||||
|
info = fireEvent('episode.info', merge = True, season_identifier = parent_identifier, \
|
||||||
|
episode_identifier = identifier)
|
||||||
|
|
||||||
# Don't need those here
|
# Don't need those here
|
||||||
try: del info['in_wanted']
|
try: del info['in_wanted']
|
||||||
|
|||||||
@@ -88,8 +88,8 @@ class SeasonLibraryPlugin(LibraryBase):
|
|||||||
if library.status_id == done_status.get('id') and not force:
|
if library.status_id == done_status.get('id') and not force:
|
||||||
do_update = False
|
do_update = False
|
||||||
|
|
||||||
info = fireEvent('season.info', merge = True, identifier = identifier, \
|
info = fireEvent('season.info', merge = True, identifier = parent_identifier, \
|
||||||
parent_identifier = parent_identifier)
|
season_identifier = identifier)
|
||||||
|
|
||||||
# Don't need those here
|
# Don't need those here
|
||||||
try: del info['in_wanted']
|
try: del info['in_wanted']
|
||||||
@@ -124,7 +124,9 @@ class SeasonLibraryPlugin(LibraryBase):
|
|||||||
t = LibraryTitle(
|
t = LibraryTitle(
|
||||||
title = title,
|
title = title,
|
||||||
simple_title = self.simplifyTitle(title),
|
simple_title = self.simplifyTitle(title),
|
||||||
default = (len(default_title) == 0 and counter == 0) or len(titles) == 1 or title.lower() == toUnicode(default_title.lower()) or (toUnicode(default_title) == u'' and toUnicode(titles[0]) == title)
|
# XXX: default was None; so added a quick hack since we don't really need titiles for seasons anyway
|
||||||
|
#default = (len(default_title) == 0 and counter == 0) or len(titles) == 1 or title.lower() == toUnicode(default_title.lower()) or (toUnicode(default_title) == u'' and toUnicode(titles[0]) == title)
|
||||||
|
default = True,
|
||||||
)
|
)
|
||||||
library.titles.append(t)
|
library.titles.append(t)
|
||||||
counter += 1
|
counter += 1
|
||||||
@@ -132,23 +134,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)
|
||||||
|
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ class ShowLibraryPlugin(LibraryBase):
|
|||||||
|
|
||||||
do_update = True
|
do_update = True
|
||||||
|
|
||||||
info = fireEvent('show.info' % library.type, merge = True, identifier = identifier)
|
info = fireEvent('show.info', merge = True, identifier = identifier)
|
||||||
|
|
||||||
# Don't need those here
|
# Don't need those here
|
||||||
try: del info['in_wanted']
|
try: del info['in_wanted']
|
||||||
|
|||||||
@@ -9,16 +9,20 @@ import traceback
|
|||||||
log = CPLog(__name__)
|
log = CPLog(__name__)
|
||||||
|
|
||||||
# XXX: I return None in alot of functions when there is error or no value; check if I
|
# XXX: I return None in alot of functions when there is error or no value; check if I
|
||||||
# should be returning an empty list or dictionary
|
# should be returning an empty list or dictionary
|
||||||
# XXX: Consider grabbing zips to put less strain on tvdb
|
# XXX: Consider grabbing zips to put less strain on tvdb
|
||||||
# XXX: Consider a cache; not implenented everywhere yet or at all
|
# XXX: Consider a cache; not implenented everywhere yet or at all
|
||||||
|
# XXX: Search by language; now ists defualt of "en"
|
||||||
|
# XXX: alternate titles do exist for show and episodes; add them
|
||||||
|
# XXX: Unicode stuff
|
||||||
|
# XXX: we have a getShow function but it it being used?
|
||||||
class TheTVDb(ShowProvider):
|
class TheTVDb(ShowProvider):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
#addEvent('show.by_hash', self.byHash)
|
#addEvent('show.by_hash', self.byHash)
|
||||||
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('show.episodes', self.getEpisodes, priority = 1)
|
addEvent('season.info', self.getSeasonInfo, priority = 1)
|
||||||
addEvent('episode.info', self.getEpisodeInfo, priority = 1)
|
addEvent('episode.info', self.getEpisodeInfo, priority = 1)
|
||||||
#addEvent('show.info_by_thetvdb', self.getInfoByTheTVDBId)
|
#addEvent('show.info_by_thetvdb', self.getInfoByTheTVDBId)
|
||||||
|
|
||||||
@@ -76,6 +80,7 @@ class TheTVDb(ShowProvider):
|
|||||||
search_string = simplifyString(q)
|
search_string = simplifyString(q)
|
||||||
cache_key = 'thetvdb.cache.%s.%s' % (search_string, limit)
|
cache_key = 'thetvdb.cache.%s.%s' % (search_string, limit)
|
||||||
results = self.getCache(cache_key)
|
results = self.getCache(cache_key)
|
||||||
|
# TODO: cache is not returned
|
||||||
|
|
||||||
if not results:
|
if not results:
|
||||||
log.debug('Searching for show: %s', q)
|
log.debug('Searching for show: %s', q)
|
||||||
@@ -83,7 +88,6 @@ class TheTVDb(ShowProvider):
|
|||||||
raw = None
|
raw = None
|
||||||
try:
|
try:
|
||||||
raw = self.tvdb.search(search_string)
|
raw = self.tvdb.search(search_string)
|
||||||
|
|
||||||
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', (search_string, traceback.format_exc()))
|
||||||
return None
|
return None
|
||||||
@@ -114,30 +118,6 @@ class TheTVDb(ShowProvider):
|
|||||||
|
|
||||||
return results
|
return results
|
||||||
|
|
||||||
def getEpisodes(self, identifier=None, episode_identifier=None):
|
|
||||||
"""Either return a list of all episodes or a single episode.
|
|
||||||
If episode_identifer contains an episode to search for it will be returned if found
|
|
||||||
"""
|
|
||||||
if not identifier:
|
|
||||||
return None
|
|
||||||
|
|
||||||
try:
|
|
||||||
show = self.tvdb[int(identifier)]
|
|
||||||
except (tvdb_exceptions.tvdb_error, IOError), e:
|
|
||||||
log.error('Failed parsing TheTVDB for "%s" id "%s": %s', (show, identifier, traceback.format_exc()))
|
|
||||||
return None
|
|
||||||
|
|
||||||
result = []
|
|
||||||
for season in show.values():
|
|
||||||
for episode in season.values():
|
|
||||||
if episode_identifier:
|
|
||||||
if episode['id'] == toUnicode(episode_identifier):
|
|
||||||
return episode
|
|
||||||
else:
|
|
||||||
result.append(self.parseEpisode(show, episode))
|
|
||||||
|
|
||||||
return result
|
|
||||||
|
|
||||||
def getShow(self, identifier = None):
|
def getShow(self, identifier = None):
|
||||||
show = None
|
show = None
|
||||||
try:
|
try:
|
||||||
@@ -149,6 +129,86 @@ class TheTVDb(ShowProvider):
|
|||||||
|
|
||||||
return show
|
return show
|
||||||
|
|
||||||
|
def getSeasonInfo(self, identifier=None, season_identifier=None):
|
||||||
|
"""Either return a list of all seasons or a single season by number.
|
||||||
|
identifier is the show 'id'
|
||||||
|
"""
|
||||||
|
if not identifier:
|
||||||
|
return None
|
||||||
|
|
||||||
|
# season_identifier must contain the 'show id : season number' since there is no tvdb id
|
||||||
|
# for season and we need a reference to both the show id and season number
|
||||||
|
if season_identifier:
|
||||||
|
try: season_identifier = int(season_identifier.split(':')[1])
|
||||||
|
except: return None
|
||||||
|
|
||||||
|
cache_key = 'thetvdb.cache.%s.%s' % (identifier, season_identifier)
|
||||||
|
log.debug('Getting SeasonInfo: %s', cache_key)
|
||||||
|
result = self.getCache(cache_key) or {}
|
||||||
|
if result:
|
||||||
|
return result
|
||||||
|
|
||||||
|
try:
|
||||||
|
show = self.tvdb[int(identifier)]
|
||||||
|
except (tvdb_exceptions.tvdb_error, IOError), e:
|
||||||
|
log.error('Failed parsing TheTVDB SeasonInfo for "%s" id "%s": %s', (show, identifier, traceback.format_exc()))
|
||||||
|
return None
|
||||||
|
|
||||||
|
result = []
|
||||||
|
for number, season in show.items():
|
||||||
|
if season_identifier is not None and number == season_identifier:
|
||||||
|
result = self.parseSeason(show, (number, season))
|
||||||
|
self.setCache(cache_key, result)
|
||||||
|
return result
|
||||||
|
else:
|
||||||
|
result.append(self.parseSeason(show, (number, season)))
|
||||||
|
|
||||||
|
self.setCache(cache_key, result)
|
||||||
|
return result
|
||||||
|
|
||||||
|
def getEpisodeInfo(self, identifier=None, season_identifier=None, episode_identifier=None):
|
||||||
|
"""Either return a list of all episodes or a single episode.
|
||||||
|
If episode_identifer contains an episode number to search for
|
||||||
|
"""
|
||||||
|
if not identifier and season_identifier is None:
|
||||||
|
return None
|
||||||
|
|
||||||
|
# season_identifier must contain the 'show id : season number' since there is no tvdb id
|
||||||
|
# for season and we need a reference to both the show id and season number
|
||||||
|
if season_identifier:
|
||||||
|
try:
|
||||||
|
identifier, season_identifier = season_identifier.split(':')
|
||||||
|
season_identifier = int(season_identifier)
|
||||||
|
except: return None
|
||||||
|
|
||||||
|
cache_key = 'thetvdb.cache.%s.%s.%s' % (identifier, episode_identifier, season_identifier)
|
||||||
|
log.debug('Getting EpisodeInfo: %s', cache_key)
|
||||||
|
result = self.getCache(cache_key) or {}
|
||||||
|
if result:
|
||||||
|
return result
|
||||||
|
|
||||||
|
try:
|
||||||
|
show = self.tvdb[int(identifier)]
|
||||||
|
except (tvdb_exceptions.tvdb_error, IOError), e:
|
||||||
|
log.error('Failed parsing TheTVDB EpisodeInfo for "%s" id "%s": %s', (show, identifier, traceback.format_exc()))
|
||||||
|
return None
|
||||||
|
|
||||||
|
result = []
|
||||||
|
for number, season in show.items():
|
||||||
|
if season_identifier is not None and number != season_identifier:
|
||||||
|
continue
|
||||||
|
|
||||||
|
for episode in season.values():
|
||||||
|
if episode_identifier is not None and episode['id'] == toUnicode(episode_identifier):
|
||||||
|
result = self.parseEpisode(show, episode)
|
||||||
|
self.setCache(cache_key, result)
|
||||||
|
return result
|
||||||
|
else:
|
||||||
|
result.append(self.parseEpisode(show, episode))
|
||||||
|
|
||||||
|
self.setCache(cache_key, result)
|
||||||
|
return result
|
||||||
|
|
||||||
def getShowInfo(self, identifier = None):
|
def getShowInfo(self, identifier = None):
|
||||||
if not identifier:
|
if not identifier:
|
||||||
return None
|
return None
|
||||||
@@ -166,26 +226,6 @@ class TheTVDb(ShowProvider):
|
|||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def getEpisodeInfo(self, identifier = None, parent_identifier = None):
|
|
||||||
if not identifier or not parent_identifier:
|
|
||||||
return None
|
|
||||||
|
|
||||||
cache_key = 'thetvdb.cache.%s.%s' % (parent_identifier, identifier)
|
|
||||||
log.debug('Getting EpisodeInfo: %s', cache_key)
|
|
||||||
result = self.getCache(cache_key) or {}
|
|
||||||
if result:
|
|
||||||
return result
|
|
||||||
|
|
||||||
show = self.getShow(identifier = parent_identifier)
|
|
||||||
if show:
|
|
||||||
episode = self.getEpisodes(identifier=parent_identifier, episode_identifier=identifier)
|
|
||||||
|
|
||||||
if episode:
|
|
||||||
result = self.parseEpisode(show, episode)
|
|
||||||
self.setCache(cache_key, result)
|
|
||||||
|
|
||||||
return result
|
|
||||||
|
|
||||||
#def getInfoByTheTVDBId(self, id = None):
|
#def getInfoByTheTVDBId(self, id = None):
|
||||||
|
|
||||||
#cache_key = 'thetvdb.cache.%s' % id
|
#cache_key = 'thetvdb.cache.%s' % id
|
||||||
@@ -247,12 +287,10 @@ class TheTVDb(ShowProvider):
|
|||||||
#poster_original = self.getImage(show, type = 'poster', size = 'original')
|
#poster_original = self.getImage(show, type = 'poster', size = 'original')
|
||||||
#backdrop_original = self.getImage(show, type = 'backdrop', size = 'original')
|
#backdrop_original = self.getImage(show, type = 'backdrop', size = 'original')
|
||||||
|
|
||||||
## Genres
|
|
||||||
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:
|
||||||
## Year
|
try: year = datetime.strptime(show['firstaired'], '%Y-%m-%d').year
|
||||||
if show['firstaired']:
|
except: year = None
|
||||||
year = datetime.strptime(show['firstaired'], '%Y-%m-%d').year
|
|
||||||
else:
|
else:
|
||||||
year = None
|
year = None
|
||||||
|
|
||||||
@@ -268,24 +306,69 @@ class TheTVDb(ShowProvider):
|
|||||||
'poster_original': [],
|
'poster_original': [],
|
||||||
'backdrop_original': [],
|
'backdrop_original': [],
|
||||||
},
|
},
|
||||||
'imdb': show['imdb_id'],
|
|
||||||
'runtime': show['runtime'],
|
|
||||||
'released': show['firstaired'],
|
|
||||||
'year': year,
|
'year': year,
|
||||||
'plot': show['overview'],
|
|
||||||
'genres': genres,
|
'genres': genres,
|
||||||
|
'imdb': show['imdb_id'],
|
||||||
|
'zap2it_id': show['zap2it_id'],
|
||||||
|
'seriesid': show['seriesid'],
|
||||||
|
'network': show['network'],
|
||||||
|
'networkid': show['networkid'],
|
||||||
|
'airs_dayofweek': show['airs_dayofweek'],
|
||||||
|
'airs_time': show['airs_time'],
|
||||||
|
'firstaired': show['firstaired'],
|
||||||
|
'released': show['firstaired'],
|
||||||
|
'runtime': show['runtime'],
|
||||||
|
'contentrating': show['contentrating'],
|
||||||
|
'rating': show['rating'],
|
||||||
|
'ratingcount': show['ratingcount'],
|
||||||
|
'actors': show['actors'],
|
||||||
|
'lastupdated': show['lastupdated'],
|
||||||
|
'status': show['status'],
|
||||||
|
'language': show['language'],
|
||||||
}
|
}
|
||||||
|
|
||||||
show_data = dict((k, v) for k, v in show_data.iteritems() if v)
|
show_data = dict((k, v) for k, v in show_data.iteritems() if v)
|
||||||
|
|
||||||
## Add alternative names
|
## Add alternative names
|
||||||
#for alt in ['original_name', 'alternative_name']:
|
#for alt in ['original_name', 'alternative_name']:
|
||||||
#alt_name = toUnicode(show.get(alt))
|
#alt_name = toUnicode(show['alt))
|
||||||
#if alt_name and not alt_name in show_data['titles'] and alt_name.lower() != 'none' and alt_name != None:
|
#if alt_name and not alt_name in show_data['titles'] and alt_name.lower() != 'none' and alt_name != None:
|
||||||
#show_data['titles'].append(alt_name)
|
#show_data['titles'].append(alt_name)
|
||||||
|
|
||||||
return show_data
|
return show_data
|
||||||
|
|
||||||
|
def parseSeason(self, show, season_tuple):
|
||||||
|
"""
|
||||||
|
contains no data
|
||||||
|
"""
|
||||||
|
|
||||||
|
number, season = season_tuple
|
||||||
|
title = toUnicode('%s - Season %s' % (show['seriesname'], str(number)))
|
||||||
|
|
||||||
|
# XXX: work on title; added defualt_title to fix an error
|
||||||
|
season_data = {
|
||||||
|
'id': (show['id'] + ':' + str(number)),
|
||||||
|
'type': 'season',
|
||||||
|
'primary_provider': 'thetvdb',
|
||||||
|
'titles': [title, ],
|
||||||
|
'original_title': title,
|
||||||
|
'via_thetvdb': True,
|
||||||
|
'parent_identifier': show['id'],
|
||||||
|
'seasonnumber': str(number),
|
||||||
|
'images': {
|
||||||
|
'poster': [],
|
||||||
|
'backdrop': [],
|
||||||
|
'poster_original': [],
|
||||||
|
'backdrop_original': [],
|
||||||
|
},
|
||||||
|
'year': None,
|
||||||
|
'genres': None,
|
||||||
|
'imdb': None,
|
||||||
|
}
|
||||||
|
|
||||||
|
season_data = dict((k, v) for k, v in season_data.iteritems() if v)
|
||||||
|
return season_data
|
||||||
|
|
||||||
def parseEpisode(self, show, episode):
|
def parseEpisode(self, show, episode):
|
||||||
"""
|
"""
|
||||||
('episodenumber', u'1'),
|
('episodenumber', u'1'),
|
||||||
@@ -327,17 +410,17 @@ class TheTVDb(ShowProvider):
|
|||||||
#backdrop = self.getImage(episode, type = 'fanart', size = 'w1280')
|
#backdrop = self.getImage(episode, type = 'fanart', size = 'w1280')
|
||||||
##poster_original = self.getImage(episode, type = 'poster', size = 'original')
|
##poster_original = self.getImage(episode, type = 'poster', size = 'original')
|
||||||
##backdrop_original = self.getImage(episode, type = 'backdrop', size = 'original')
|
##backdrop_original = self.getImage(episode, type = 'backdrop', size = 'original')
|
||||||
|
|
||||||
poster = episode['filename'] or []
|
poster = episode['filename'] or []
|
||||||
backdrop = []
|
backdrop = []
|
||||||
|
|
||||||
## Genres
|
|
||||||
genres = []
|
genres = []
|
||||||
|
plot = "%s - %sx%s - %s" % (show['seriesname'],
|
||||||
plot = "%s - %sx%s - %s" % (show['seriesname'], episode['seasonnumber'], episode['episodenumber'], episode['overview'])
|
episode['seasonnumber'],
|
||||||
|
episode['episodenumber'],
|
||||||
## Year
|
episode['overview'])
|
||||||
if episode['firstaired']:
|
if episode['firstaired'] is not None:
|
||||||
year = datetime.strptime(episode['firstaired'], '%Y-%m-%d').year
|
try: year = datetime.strptime(episode['firstaired'], '%Y-%m-%d').year
|
||||||
|
except: year = None
|
||||||
else:
|
else:
|
||||||
year = None
|
year = None
|
||||||
|
|
||||||
@@ -348,7 +431,7 @@ class TheTVDb(ShowProvider):
|
|||||||
'via_thetvdb': True,
|
'via_thetvdb': True,
|
||||||
'thetvdb_id': int(episode['id']),
|
'thetvdb_id': int(episode['id']),
|
||||||
'titles': [episode['episodename'], ],
|
'titles': [episode['episodename'], ],
|
||||||
'original_title': episode['episodename'],
|
'original_title': episode['episodename'] ,
|
||||||
'images': {
|
'images': {
|
||||||
'poster': [poster] if poster else [],
|
'poster': [poster] if poster else [],
|
||||||
'backdrop': [backdrop] if backdrop else [],
|
'backdrop': [backdrop] if backdrop else [],
|
||||||
@@ -362,13 +445,38 @@ class TheTVDb(ShowProvider):
|
|||||||
'plot': plot,
|
'plot': plot,
|
||||||
'genres': genres,
|
'genres': genres,
|
||||||
'parent_identifier': show['id'],
|
'parent_identifier': show['id'],
|
||||||
|
'seasonnumber': episode['seasonnumber'],
|
||||||
|
'episodenumber': episode['episodenumber'],
|
||||||
|
'combined_episodenumber': episode['combined_episodenumber'],
|
||||||
|
'absolute_number': episode['absolute_number'],
|
||||||
|
'combined_season': episode['combined_season'],
|
||||||
|
'productioncode': episode['productioncode'],
|
||||||
|
'seriesid': episode['seriesid'],
|
||||||
|
'seasonid': episode['seasonid'],
|
||||||
|
'firstaired': episode['firstaired'],
|
||||||
|
'thumb_added': episode['thumb_added'],
|
||||||
|
'thumb_height': episode['thumb_height'],
|
||||||
|
'thumb_width': episode['thumb_width'],
|
||||||
|
'rating': episode['rating'],
|
||||||
|
'ratingcount': episode['ratingcount'],
|
||||||
|
'epimgflag': episode['epimgflag'],
|
||||||
|
'dvd_episodenumber': episode['dvd_episodenumber'],
|
||||||
|
'dvd_discid': episode['dvd_discid'],
|
||||||
|
'dvd_chapter': episode['dvd_chapter'],
|
||||||
|
'dvd_season': episode['dvd_season'],
|
||||||
|
'tms_export': episode['tms_export'],
|
||||||
|
'writer': episode['writer'],
|
||||||
|
'director': episode['director'],
|
||||||
|
'gueststars': episode['gueststars'],
|
||||||
|
'lastupdated': episode['lastupdated'],
|
||||||
|
'language': episode['language'],
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
## Add alternative names
|
||||||
#for alt in ['original_name', 'alternative_name']:
|
#for alt in ['original_name', 'alternative_name']:
|
||||||
#alt_name = toUnicode(episode.get(alt))
|
#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:
|
#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)
|
#episode_data['titles'].append(alt_name)
|
||||||
|
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ class Library(Entity):
|
|||||||
type = Field(String(10), default="movie", index=True)
|
type = Field(String(10), default="movie", index=True)
|
||||||
primary_provider = Field(String(10), default="imdb", index=True)
|
primary_provider = Field(String(10), default="imdb", index=True)
|
||||||
year = Field(Integer)
|
year = Field(Integer)
|
||||||
identifier = Field(String(20), index = True)
|
identifier = Field(String(40), index = True)
|
||||||
|
|
||||||
plot = Field(UnicodeText)
|
plot = Field(UnicodeText)
|
||||||
tagline = Field(UnicodeText(255))
|
tagline = Field(UnicodeText(255))
|
||||||
|
|||||||
Reference in new issue
Block a user