def get_tmdb_details(self, tmdb=None): if not tmdb: return details = None if self.infolabels.get('mediatype') in ['movie', 'tvshow']: tmdbtype = 'tv' if self.infolabels.get( 'mediatype') == 'tvshow' else 'movie' details = tmdb.get_detailed_item(tmdbtype, self.tmdb_id, cache_only=True) if self.infolabels.get('mediatype') in ['season', 'episode']: episode = self.infolabels.get('episode') if self.infolabels.get( 'mediatype') == 'episode' else None details = tmdb.get_detailed_item( 'tv', self.tmdb_id, season=self.infolabels.get('season'), episode=episode, cache_only=True) # # TODO: Add details for actors if not details: return self.cast = details.get('cast', []) self.imdb_id = self.imdb_id or details.get('infolabels', {}).get('imdbnumber') self.infolabels = utils.merge_two_dicts(details.get('infolabels', {}), self.infolabels) self.infoproperties = utils.merge_two_dicts( details.get('infoproperties', {}), self.infoproperties)
def get_kodi_details(self): if not self.dbid: return details = {} if self.infolabels.get('mediatype') == 'movie': details = KodiLibrary().get_movie_details(self.dbid) if self.infolabels.get('mediatype') == 'tvshow': details = KodiLibrary().get_tvshow_details(self.dbid) if self.infolabels.get('mediatype') == 'episode': details = KodiLibrary().get_episode_details(self.dbid) if not details: return self.icon = self.icon or details.get('icon', '') self.thumb = self.thumb or details.get('thumb', '') self.poster = self.poster or details.get('poster', '') self.fanart = self.fanart or details.get('fanart', '') self.landscape = self.landscape or details.get('landscape', '') self.clearart = self.clearart or details.get('clearart', '') self.clearlogo = self.clearlogo or details.get('clearlogo', '') self.discart = self.discart or details.get('discart', '') self.cast = self.cast or details.get('cast', []) self.infolabels = utils.merge_two_dicts(details.get('infolabels', {}), self.infolabels) self.infoproperties = utils.merge_two_dicts( details.get('infoproperties', {}), self.infoproperties) self.streamdetails = details.get('streamdetails', {})
def get_niceitem(self, item): label = self.get_title(item) icon = self.get_icon(item) poster = self.get_season_poster(item) or icon thumb = self.get_season_thumb(item) or '' fanart = self.get_fanart(item) cast = self.get_cast(item) infolabels = self.get_infolabels(item) infolabels = utils.merge_two_dicts(infolabels, self.get_trailer(item)) infolabels = utils.merge_two_dicts(infolabels, self.get_director_writer(item)) infolabels = utils.del_empty_keys(infolabels, ['N/A', '0.0', '0']) infoproperties = self.get_infoproperties(item) infoproperties = utils.merge_two_dicts(infoproperties, self.get_cast_properties(cast)) infoproperties = utils.merge_two_dicts(infoproperties, self.get_crew_properties(item)) infoproperties = utils.del_empty_keys(infoproperties, ['N/A', '0.0', '0']) return { 'label': label, 'icon': icon, 'poster': poster, 'thumb': thumb, 'fanart': fanart, 'cast': cast, 'infolabels': infolabels, 'infoproperties': infoproperties, 'tmdb_id': infoproperties.get('tmdb_id'), 'imdb_id': infoproperties.get('imdb_id'), 'tvdb_id': infoproperties.get('tvdb_id') }
def get_trakt_ratings(self, item, tmdbtype=None, tmdb_id=None, season=None, episode=None): imdb_id = self.tmdb.get_item_externalid(itemtype=tmdbtype, tmdb_id=tmdb_id, external_id='imdb_id') if tmdbtype and imdb_id: ratings = TraktAPI().get_ratings(tmdbtype=tmdbtype, imdb_id=imdb_id, season=season, episode=episode) if ratings: item['infoproperties'] = utils.merge_two_dicts(item.get('infoproperties', {}), ratings) return item
def get_kodi_person_stats(self, item): if item.get('infolabels', {}).get('title'): statistics = KodiLibrary().get_person_stats( item.get('infolabels', {}).get('title')) if statistics: item['infoproperties'] = utils.merge_two_dicts( item.get('infoproperties', {}), statistics) return item
def get_kodi_details(self): if not self.dbid and not self.tvshow_dbid: return details = {} tvshow_details = {} if self.infolabels.get('mediatype') == 'movie' and self.dbid: details = KodiLibrary().get_movie_details(self.dbid) elif self.infolabels.get('mediatype') == 'tvshow' and self.dbid: details = KodiLibrary().get_tvshow_details(self.dbid) elif self.infolabels.get('mediatype') == 'episode': details = KodiLibrary().get_episode_details( self.dbid) if self.dbid else {} tvshow_details = KodiLibrary().get_tvshow_details( self.tvshow_dbid) if self.tvshow_dbid else {} if tvshow_details: self.tvshow_poster = tvshow_details.get( 'poster') or self.tvshow_poster self.tvshow_fanart = tvshow_details.get( 'fanart') or self.tvshow_fanart self.tvshow_landscape = tvshow_details.get( 'landscape') or self.tvshow_landscape self.tvshow_clearart = tvshow_details.get( 'clearart') or self.tvshow_clearart self.tvshow_clearlogo = tvshow_details.get( 'clearlogo') or self.tvshow_clearlogo if not details: return self.local_path = details.get('path') self.icon = details.get('icon') or self.icon self.poster = details.get('poster') or self.poster self.fanart = details.get('fanart') or self.fanart self.landscape = details.get('landscape') or self.landscape self.clearart = details.get('clearart') or self.clearart self.clearlogo = details.get('clearlogo') or self.clearlogo self.discart = details.get('discart') or self.discart self.cast = self.cast or details.get('cast', []) self.infolabels = utils.merge_two_dicts(details.get('infolabels', {}), self.infolabels) self.infoproperties = utils.merge_two_dicts( details.get('infoproperties', {}), self.infoproperties) self.streamdetails = details.get('streamdetails', {})
def get_omdb_ratings(self, item, cache_only=False): if self.omdb and item.get('infolabels', {}).get('imdbnumber'): ratings_awards = self.omdb.get_ratings_awards( imdb_id=item.get('infolabels', {}).get('imdbnumber'), cache_only=cache_only) if ratings_awards: item['infoproperties'] = utils.merge_two_dicts( item.get('infoproperties', {}), ratings_awards) return item
def get_detailed_item(self, itemtype, tmdb_id, season=None, episode=None, cache_only=False, cache_refresh=False): if not itemtype or not tmdb_id: return {} extra_request = None cache_name = '{0}.TMDb.v2_2_18.{1}.{2}'.format(self.cache_name, itemtype, tmdb_id) cache_name = '{0}.Season{1}'.format(cache_name, season) if season else cache_name cache_name = '{0}.Episode{1}'.format( cache_name, episode) if season and episode else cache_name itemdict = self.get_cache(cache_name) if not cache_refresh else None if not itemdict and not cache_only: request = self.get_request_lc(itemtype, tmdb_id, language=self.req_language, append_to_response=self.req_append, cache_refresh=cache_refresh) if itemtype == 'tv': request['tvshowtitle'] = self.get_title(request) if season and episode: extra_request = self.get_request_lc( 'tv', tmdb_id, 'season', season, 'episode', episode, language=self.req_language, append_to_response=self.req_append, cache_refresh=cache_refresh) elif season: extra_request = self.get_request_lc( 'tv', tmdb_id, 'season', season, language=self.req_language, append_to_response=self.req_append, cache_refresh=cache_refresh) if season and episode and not extra_request: extra_request = { 'episode_number': episode, 'season_number': season } if extra_request: request = utils.merge_two_dicts(request, extra_request) itemdict = self.set_cache(self.get_niceitem(request), cache_name, self.cache_long) if request else {} return itemdict
def get_omdb_ratings(self, item, cache_only=False): imdb_id = item.get('infolabels', {}).get('imdbnumber') if not imdb_id or not imdb_id.startswith('tt'): imdb_id = item.get('infoproperties', {}).get('imdb_id') if not imdb_id or not imdb_id.startswith('tt'): imdb_id = item.get('infoproperties', {}).get('tvshow.imdb_id') if self.omdb and imdb_id: ratings_awards = self.omdb.get_ratings_awards( imdb_id=imdb_id, cache_only=cache_only) if ratings_awards: item['infoproperties'] = utils.merge_two_dicts( item.get('infoproperties', {}), ratings_awards) return item
def set_listitem(self, path=None): listitem = xbmcgui.ListItem(label=self.label, label2=self.label2, path=path) listitem.setLabel2(self.label2) listitem.setUniqueIDs({'imdb': self.imdb_id, 'tmdb': self.tmdb_id}) listitem.setInfo(self.library, self.infolabels) listitem.setProperties(self.infoproperties) listitem.setArt( utils.merge_two_dicts( { 'thumb': self.thumb or self.icon or self.fanart or self.fallback_icon, 'icon': self.icon or self.fallback_icon, 'fanart': self.fanart or self.tvshow_fanart or self.fallback_fanart, 'tvshow.fanart': self.tvshow_fanart, 'poster': self.poster or self.tvshow_poster, 'tvshow.poster': self.tvshow_poster, 'landscape': self.landscape or self.tvshow_landscape, 'tvshow.landscape': self.tvshow_landscape, 'banner': self.banner or self.tvshow_banner, 'tvshow.banner': self.tvshow_banner, 'clearlogo': self.clearlogo or self.tvshow_clearlogo, 'tvshow.clearlogo': self.tvshow_clearlogo, 'clearart': self.clearart or self.tvshow_clearart, 'tvshow.clearart': self.tvshow_clearart, 'discart': self.discart }, self.extrafanart)) listitem.setCast(self.cast) listitem.addContextMenuItems(self.contextmenu) if self.streamdetails: for k, v in self.streamdetails.items(): if not k or not v: continue for i in v: if not i: continue listitem.addStreamInfo(k, i) return listitem
def get_detailed_item(self, itemtype, tmdb_id, season=None, episode=None, cache_only=False, cache_refresh=False): if not itemtype or not tmdb_id: utils.kodi_log(u'TMDb Get Details: No Item Type or TMDb ID!\n{} {} {} {}'.format(itemtype, tmdb_id, season, episode), 2) return {} extra_request = None cache_name = '{0}.TMDb.v3_2_3.{1}.{2}'.format(self.cache_name, itemtype, tmdb_id) cache_name = '{0}.Season{1}'.format(cache_name, season) if season else cache_name cache_name = '{0}.Episode{1}'.format(cache_name, episode) if season and episode else cache_name itemdict = self.get_cache(cache_name) if not cache_refresh else None if not itemdict and not cache_only: request = self.get_request_lc(itemtype, tmdb_id, language=self.req_language, append_to_response=self.req_append, cache_refresh=cache_refresh) if itemtype == 'tv': request['tvshowtitle'] = self.get_title(request) if season and episode: extra_request = self.get_request_lc( 'tv', tmdb_id, 'season', season, 'episode', episode, language=self.req_language, append_to_response=self.req_append, cache_refresh=cache_refresh) elif season: extra_request = self.get_request_lc( 'tv', tmdb_id, 'season', season, language=self.req_language, append_to_response=self.req_append, cache_refresh=cache_refresh) if season and episode and not extra_request: extra_request = {'episode_number': episode, 'season_number': season} if extra_request: extra_request['tvshow.tmdb_id'] = request.get('id') extra_request['tvshow.imdb_id'] = request.get('imdb_id') or request.get('external_ids', {}).get('imdb_id') extra_request['tvshow.tvdb_id'] = request.get('external_ids', {}).get('tvdb_id') request = utils.merge_two_dicts(request, extra_request) itemdict = self.set_cache(self.get_niceitem(request), cache_name, self.cache_long) if request else {} utils.kodi_log(u'TMDb Get Details: No Item Found!\n{} {} {} {}'.format(itemtype, tmdb_id, season, episode), 2) if not request else None return itemdict
def get_omdb_details(self, omdb=None): if omdb and self.imdb_id and self.infolabels.get( 'mediatype') == 'movie': self.infoproperties = utils.merge_two_dicts( self.infoproperties, omdb.get_ratings_awards(imdb_id=self.imdb_id, cache_only=True))