def get_userlist(user_slug=None, list_slug=None, confirm=True, busy_spinner=True): with busy_dialog(is_enabled=busy_spinner): if list_slug.startswith('watchlist'): path = ['users', user_slug, list_slug] else: path = ['users', user_slug, 'lists', list_slug, 'items'] request = TraktAPI().get_response_json(*path) if not request: return if confirm: d_head = ADDON.getLocalizedString(32125) i_check_limits = check_overlimit(request) if i_check_limits: # List over limit so inform user that it is too large to add d_body = [ ADDON.getLocalizedString(32168).format(list_slug, user_slug), ADDON.getLocalizedString(32170).format( i_check_limits.get('show'), i_check_limits.get('movie')), '', ADDON.getLocalizedString(32164).format( LIBRARY_ADD_LIMIT_TVSHOWS, LIBRARY_ADD_LIMIT_MOVIES) ] xbmcgui.Dialog().ok(d_head, '\n'.join(d_body)) return elif isinstance(confirm, bool) or len(request) > confirm: # List is within limits so ask for confirmation before adding it d_body = [ ADDON.getLocalizedString(32168).format(list_slug, user_slug), ADDON.getLocalizedString(32171).format(len(request)) if len(request) > 20 else '', '', ADDON.getLocalizedString(32126) ] if not xbmcgui.Dialog().yesno(d_head, '\n'.join(d_body)): return return request
def _get_basedir_rules_tv(): return [{ 'label': ADDON.getLocalizedString(32257), 'method': 'with_networks' }, { 'label': ADDON.getLocalizedString(32258), 'method': 'air_date.gte' }, { 'label': ADDON.getLocalizedString(32259), 'method': 'air_date.lte' }, { 'label': ADDON.getLocalizedString(32260), 'method': 'first_air_date.gte' }, { 'label': ADDON.getLocalizedString(32261), 'method': 'first_air_date.lte' }, { 'label': ADDON.getLocalizedString(32262), 'method': 'first_air_date_year' }]
def logout(self): token = self.get_stored_token() if not xbmcgui.Dialog().yesno(ADDON.getLocalizedString(32212), ADDON.getLocalizedString(32213)): return if token: response = self.get_api_request('https://api.trakt.tv/oauth/revoke', postdata={ 'token': token.get('access_token', ''), 'client_id': self.client_id, 'client_secret': self.client_secret}) if response and response.status_code == 200: msg = ADDON.getLocalizedString(32216) ADDON.setSettingString('trakt_token', '') else: msg = ADDON.getLocalizedString(32215) else: msg = ADDON.getLocalizedString(32214) xbmcgui.Dialog().ok(ADDON.getLocalizedString(32212), msg)
def _sync_item_methods(): return [{ 'method': 'history', 'sync_type': 'watched', 'allow_episodes': True, 'name_add': xbmc.getLocalizedString(16103), 'name_remove': xbmc.getLocalizedString(16104) }, { 'method': 'collection', 'sync_type': 'collection', 'allow_episodes': True, 'name_add': ADDON.getLocalizedString(32289), 'name_remove': ADDON.getLocalizedString(32290) }, { 'method': 'watchlist', 'sync_type': 'watchlist', 'name_add': ADDON.getLocalizedString(32291), 'name_remove': ADDON.getLocalizedString(32292) }, { 'method': 'recommendations', 'sync_type': 'recommendations', 'name_add': ADDON.getLocalizedString(32293), 'name_remove': ADDON.getLocalizedString(32294) }]
def _get_basedir_tmdb(): return [{ 'label': u'{}{{space}}{{item_type}}'.format(xbmc.getLocalizedString(137)), 'types': ['movie', 'tv', 'person'], 'params': { 'info': 'dir_search' }, 'path': PLUGINPATH, 'art': { 'thumb': u'{}/resources/icons/tmdb/search.png'.format(ADDONPATH) } }, { 'label': u'{}{{space}}{{item_type}}'.format(ADDON.getLocalizedString(32175)), 'types': ['movie', 'tv', 'person'], 'params': { 'info': 'popular' }, 'path': PLUGINPATH, 'art': { 'thumb': u'{}/resources/icons/tmdb/popular.png'.format(ADDONPATH) } }, { 'label': u'{}{{space}}{{item_type}}'.format(ADDON.getLocalizedString(32176)), 'types': ['movie', 'tv'], 'params': { 'info': 'top_rated' }, 'path': PLUGINPATH, 'art': { 'thumb': u'{}/resources/icons/tmdb/toprated.png'.format(ADDONPATH) } }, { 'label': u'{}{{space}}{{item_type}}'.format(ADDON.getLocalizedString(32177)), 'types': ['movie'], 'params': { 'info': 'upcoming' }, 'path': PLUGINPATH, 'art': { 'thumb': u'{}/resources/icons/tmdb/upcoming.png'.format(ADDONPATH) } }, { 'label': u'{{item_type}}{{space}}{}'.format(ADDON.getLocalizedString(32178)), 'types': ['movie', 'tv', 'person'], 'params': { 'info': 'trending_day' }, 'path': PLUGINPATH, 'art': { 'thumb': u'{}/resources/icons/tmdb/upcoming.png'.format(ADDONPATH) } }, { 'label': u'{{item_type}}{{space}}{}'.format(ADDON.getLocalizedString(32179)), 'types': ['movie', 'tv', 'person'], 'params': { 'info': 'trending_week' }, 'path': PLUGINPATH, 'art': { 'thumb': u'{}/resources/icons/tmdb/upcoming.png'.format(ADDONPATH) } }, { 'label': ADDON.getLocalizedString(32180), 'types': ['movie'], 'params': { 'info': 'now_playing' }, 'path': PLUGINPATH, 'art': { 'thumb': u'{}/resources/icons/tmdb/intheatres.png'.format(ADDONPATH) } }, { 'label': ADDON.getLocalizedString(32181), 'types': ['tv'], 'params': { 'info': 'airing_today' }, 'path': PLUGINPATH, 'art': { 'thumb': u'{}/resources/icons/tmdb/airing.png'.format(ADDONPATH) } }, { 'label': ADDON.getLocalizedString(32182), 'types': ['tv'], 'params': { 'info': 'on_the_air' }, 'path': PLUGINPATH, 'art': { 'thumb': u'{}/resources/icons/tmdb/airing.png'.format(ADDONPATH) } }, { 'label': ADDON.getLocalizedString(32183), 'types': ['tv'], 'params': { 'info': 'dir_calendar_library' }, 'path': PLUGINPATH, 'art': { 'thumb': u'{}/resources/icons/tmdb/airing.png'.format(ADDONPATH) } }, { 'label': u'{{item_type}}{{space}}{}'.format(xbmc.getLocalizedString(135)), 'types': ['movie', 'tv'], 'params': { 'info': 'genres' }, 'path': PLUGINPATH, 'art': { 'thumb': u'{}/resources/icons/tmdb/genre.png'.format(ADDONPATH) } }, { 'label': u'{}{{space}}{{item_type}}'.format(ADDON.getLocalizedString(32184)), 'types': ['movie'], 'params': { 'info': 'revenue_movies' }, 'path': PLUGINPATH, 'art': { 'thumb': u'{}/resources/poster.png'.format(ADDONPATH) } }, { 'label': u'{}{{space}}{{item_type}}'.format(ADDON.getLocalizedString(32185)), 'types': ['movie', 'tv'], 'params': { 'info': 'most_voted' }, 'path': PLUGINPATH, 'art': { 'thumb': u'{}/resources/poster.png'.format(ADDONPATH) } }, { 'label': u'{}{{space}}{{item_type}}'.format(ADDON.getLocalizedString(32186)), 'types': ['collection', 'keyword', 'network', 'studio'], 'params': { 'info': 'all_items' }, 'path': PLUGINPATH, 'art': { 'thumb': u'{}/resources/poster.png'.format(ADDONPATH) } }]
def _get_basedir_main(): return [{ 'label': xbmc.getLocalizedString(342), 'types': [None], 'params': { 'info': 'dir_movie' }, 'path': PLUGINPATH, 'art': { 'thumb': u'{}/resources/icons/tmdb/movies.png'.format(ADDONPATH) } }, { 'label': xbmc.getLocalizedString(20343), 'types': [None], 'params': { 'info': 'dir_tv' }, 'path': PLUGINPATH, 'art': { 'thumb': u'{}/resources/icons/tmdb/tv.png'.format(ADDONPATH) } }, { 'label': ADDON.getLocalizedString(32172), 'types': [None], 'params': { 'info': 'dir_person' }, 'path': PLUGINPATH, 'art': { 'thumb': u'{}/resources/icons/tmdb/cast.png'.format(ADDONPATH) } }, { 'label': xbmc.getLocalizedString(137), 'types': [None], 'params': { 'info': 'dir_multisearch' }, 'path': PLUGINPATH, 'art': { 'thumb': u'{}/resources/icons/tmdb/search.png'.format(ADDONPATH) } }, { 'label': ADDON.getLocalizedString(32174), 'types': [None], 'params': { 'info': 'dir_discover' }, 'path': PLUGINPATH, 'art': { 'thumb': u'{}/resources/poster.png'.format(ADDONPATH) } }, { 'label': ADDON.getLocalizedString(32173), 'types': [None], 'params': { 'info': 'dir_random' }, 'path': PLUGINPATH, 'art': { 'thumb': u'{}/resources/poster.png'.format(ADDONPATH) } }, { 'label': u'TheMovieDb', 'types': [None], 'params': { 'info': 'dir_tmdb' }, 'path': PLUGINPATH, 'art': { 'thumb': u'{}/resources/poster.png'.format(ADDONPATH) } }, { 'label': u'Trakt', 'types': [None], 'params': { 'info': 'dir_trakt' }, 'path': PLUGINPATH, 'art': { 'thumb': u'{}/resources/trakt.png'.format(ADDONPATH) } }]
def _get_basedir_trakt(): return [ { 'label': u'{{item_type}}{{space}}{}'.format( ADDON.getLocalizedString(32192)), 'types': ['movie', 'tv'], 'params': { 'info': 'trakt_collection' }, 'path': PLUGINPATH, 'sorting': True, 'art': { 'thumb': u'{}/resources/icons/trakt/watchlist.png'.format(ADDONPATH) } }, { 'label': u'{{item_type}}{{space}}{}'.format( ADDON.getLocalizedString(32193)), 'types': ['movie'], 'params': { 'info': 'trakt_watchlist' }, 'context_menu': [(xbmc.getLocalizedString(20444), u'Runscript(plugin.video.themoviedb.helper,user_list=watchlist/movies)' )], 'path': PLUGINPATH, 'sorting': True, 'art': { 'thumb': u'{}/resources/icons/trakt/watchlist.png'.format(ADDONPATH) } }, { # Separate TV Watchlist entry for context menu purposes 'label': u'{{item_type}}{{space}}{}'.format( ADDON.getLocalizedString(32193)), 'types': ['tv'], 'params': { 'info': 'trakt_watchlist' }, 'context_menu': [(xbmc.getLocalizedString(20444), u'Runscript(plugin.video.themoviedb.helper,user_list=watchlist/shows)' )], 'path': PLUGINPATH, 'sorting': True, 'art': { 'thumb': u'{}/resources/icons/trakt/watchlist.png'.format(ADDONPATH) } }, { 'label': u'{}{{space}}{{item_type}}'.format( ADDON.getLocalizedString(32194)), 'types': ['movie', 'tv'], 'params': { 'info': 'trakt_history' }, 'path': PLUGINPATH, 'art': { 'thumb': u'{}/resources/icons/trakt/recentlywatched.png'.format( ADDONPATH) } }, { 'label': u'{}{{space}}{{item_type}}'.format( ADDON.getLocalizedString(32195)), 'types': ['movie', 'tv'], 'params': { 'info': 'trakt_mostwatched' }, 'path': PLUGINPATH, 'art': { 'thumb': u'{}/resources/icons/trakt/mostwatched.png'.format(ADDONPATH) } }, { 'label': u'{}{{space}}{{item_type}}'.format( ADDON.getLocalizedString(32196)), 'types': ['movie', 'tv'], 'params': { 'info': 'trakt_inprogress' }, 'path': PLUGINPATH, 'sorting': True, 'art': { 'thumb': u'{}/resources/icons/trakt/inprogress.png'.format(ADDONPATH) } }, { 'label': ADDON.getLocalizedString(32197), 'types': ['tv'], 'params': { 'info': 'trakt_nextepisodes' }, 'path': PLUGINPATH, 'art': { 'thumb': u'{}/resources/icons/trakt/inprogress.png'.format(ADDONPATH) } }, { 'label': u'{{item_type}}{{space}}{}'.format( ADDON.getLocalizedString(32198)), 'types': ['movie', 'tv'], 'params': { 'info': 'trakt_recommendations' }, 'path': PLUGINPATH, 'art': { 'thumb': u'{}/resources/icons/trakt/recommended.png'.format(ADDONPATH) } }, { 'label': u'{}{{space}}{{item_type}}'.format( ADDON.getLocalizedString(32199)), 'types': ['movie', 'tv'], 'params': { 'info': 'trakt_becauseyouwatched' }, 'path': PLUGINPATH, 'art': { 'thumb': u'{}/resources/icons/trakt/recommended.png'.format(ADDONPATH) } }, { 'label': u'{}{{space}}{{item_type}}'.format( ADDON.getLocalizedString(32200)), 'types': ['movie', 'tv'], 'params': { 'info': 'trakt_becausemostwatched' }, 'path': PLUGINPATH, 'art': { 'thumb': u'{}/resources/icons/trakt/recommended.png'.format(ADDONPATH) } }, { 'label': u'{} {{item_type}}{{space}}{}'.format( ADDON.getLocalizedString(32201), ADDON.getLocalizedString(32202)), 'types': ['tv'], 'params': { 'info': 'trakt_myairing' }, 'path': PLUGINPATH, 'art': { 'thumb': u'{}/resources/icons/trakt/airing.png'.format(ADDONPATH) } }, { 'label': u'{} {{item_type}}{{space}}{}'.format( ADDON.getLocalizedString(32201), ADDON.getLocalizedString(32203)), 'types': ['tv'], 'params': { 'info': 'dir_calendar_trakt' }, 'path': PLUGINPATH, 'art': { 'thumb': u'{}/resources/icons/trakt/calendar.png'.format(ADDONPATH) } }, { 'label': u'{}{{space}}{{item_type}}'.format( ADDON.getLocalizedString(32204)), 'types': ['movie', 'tv'], 'params': { 'info': 'trakt_trending' }, 'path': PLUGINPATH, 'art': { 'thumb': u'{}/resources/icons/trakt/trend.png'.format(ADDONPATH) } }, { 'label': u'{}{{space}}{{item_type}}'.format( ADDON.getLocalizedString(32175)), 'types': ['movie', 'tv'], 'params': { 'info': 'trakt_popular' }, 'path': PLUGINPATH, 'art': { 'thumb': u'{}/resources/icons/trakt/popular.png'.format(ADDONPATH) } }, { 'label': u'{}{{space}}{{item_type}}'.format( ADDON.getLocalizedString(32205)), 'types': ['movie', 'tv'], 'params': { 'info': 'trakt_mostplayed' }, 'path': PLUGINPATH, 'art': { 'thumb': u'{}/resources/icons/trakt/mostplayed.png'.format(ADDONPATH) } }, { 'label': u'{}{{space}}{{item_type}}'.format( ADDON.getLocalizedString(32206)), 'types': ['movie', 'tv'], 'params': { 'info': 'trakt_anticipated' }, 'path': PLUGINPATH, 'art': { 'thumb': u'{}/resources/icons/trakt/anticipated.png'.format(ADDONPATH) } }, { 'label': u'{}{{space}}{{item_type}}'.format( ADDON.getLocalizedString(32207)), 'types': ['movie'], 'params': { 'info': 'trakt_boxoffice' }, 'path': PLUGINPATH, 'art': { 'thumb': u'{}/resources/icons/trakt/boxoffice.png'.format(ADDONPATH) } }, { 'label': ADDON.getLocalizedString(32208), 'types': ['both'], 'params': { 'info': 'trakt_trendinglists' }, 'path': PLUGINPATH, 'art': { 'thumb': u'{}/resources/icons/trakt/trendinglist.png'.format(ADDONPATH) } }, { 'label': ADDON.getLocalizedString(32209), 'types': ['both'], 'params': { 'info': 'trakt_popularlists' }, 'path': PLUGINPATH, 'art': { 'thumb': u'{}/resources/icons/trakt/popularlist.png'.format(ADDONPATH) } }, { 'label': ADDON.getLocalizedString(32210), 'types': ['both'], 'params': { 'info': 'trakt_likedlists' }, 'path': PLUGINPATH, 'art': { 'thumb': u'{}/resources/icons/trakt/likedlist.png'.format(ADDONPATH) } }, { 'label': ADDON.getLocalizedString(32211), 'types': ['both'], 'params': { 'info': 'trakt_mylists' }, 'path': PLUGINPATH, 'art': { 'thumb': u'{}/resources/icons/trakt/mylists.png'.format(ADDONPATH) } }, { 'label': ADDON.getLocalizedString(32361), 'types': ['both'], 'params': { 'info': 'trakt_searchlists' }, 'path': PLUGINPATH, 'art': { 'thumb': u'{}/resources/icons/trakt/mylist.png'.format(ADDONPATH) } } ]
def _get_basedir_details(): return [{ 'label': xbmc.getLocalizedString(33054), 'params': { 'info': 'seasons' }, 'path': PLUGINPATH, 'art': { 'thumb': u'{}/resources/icons/tmdb/episodes.png'.format(ADDONPATH) }, 'types': ['tv'] }, { 'label': xbmc.getLocalizedString(206), 'params': { 'info': 'cast' }, 'path': PLUGINPATH, 'art': { 'thumb': u'{}/resources/icons/tmdb/cast.png'.format(ADDONPATH) }, 'types': ['movie', 'tv'] }, { 'label': xbmc.getLocalizedString(206), 'params': { 'info': 'episode_cast' }, 'path': PLUGINPATH, 'art': { 'thumb': u'{}/resources/icons/tmdb/cast.png'.format(ADDONPATH) }, 'types': ['episode'] }, { 'label': ADDON.getLocalizedString(32223), 'params': { 'info': 'recommendations' }, 'path': PLUGINPATH, 'art': { 'thumb': u'{}/resources/icons/tmdb/recommended.png'.format(ADDONPATH) }, 'types': ['movie', 'tv', 'episode'] }, { 'label': ADDON.getLocalizedString(32224), 'params': { 'info': 'similar' }, 'path': PLUGINPATH, 'art': { 'thumb': u'{}/resources/icons/tmdb/similar.png'.format(ADDONPATH) }, 'types': ['movie', 'tv', 'episode'] }, { 'label': ADDON.getLocalizedString(32225), 'params': { 'info': 'crew' }, 'path': PLUGINPATH, 'art': { 'thumb': u'{}/resources/icons/tmdb/cast.png'.format(ADDONPATH) }, 'types': ['movie', 'tv', 'episode'] }, { 'label': ADDON.getLocalizedString(32226), 'params': { 'info': 'posters' }, 'path': PLUGINPATH, 'art': { 'thumb': u'{}/resources/icons/tmdb/images.png'.format(ADDONPATH) }, 'types': ['movie', 'tv', 'episode'] }, { 'label': xbmc.getLocalizedString(20445), 'params': { 'info': 'fanart' }, 'path': PLUGINPATH, 'art': { 'thumb': u'{}/resources/icons/tmdb/images.png'.format(ADDONPATH) }, 'types': ['movie', 'tv', 'episode'] }, { 'label': xbmc.getLocalizedString(21861), 'params': { 'info': 'movie_keywords' }, 'path': PLUGINPATH, 'art': { 'thumb': u'{}/resources/icons/tmdb/tags.png'.format(ADDONPATH) }, 'types': ['movie'] }, { 'label': ADDON.getLocalizedString(32188), 'params': { 'info': 'reviews' }, 'path': PLUGINPATH, 'art': { 'thumb': u'{}/resources/icons/tmdb/reviews.png'.format(ADDONPATH) }, 'types': ['movie', 'tv', 'episode'] }, { 'label': ADDON.getLocalizedString(32227), 'params': { 'info': 'stars_in_movies' }, 'path': PLUGINPATH, 'art': { 'thumb': u'{}/resources/icons/tmdb/movies.png'.format(ADDONPATH) }, 'types': ['person'] }, { 'label': ADDON.getLocalizedString(32228), 'params': { 'info': 'stars_in_tvshows' }, 'path': PLUGINPATH, 'art': { 'thumb': u'{}/resources/icons/tmdb/tv.png'.format(ADDONPATH) }, 'types': ['person'] }, { 'label': ADDON.getLocalizedString(32229), 'params': { 'info': 'crew_in_movies' }, 'path': PLUGINPATH, 'art': { 'thumb': u'{}/resources/icons/tmdb/movies.png'.format(ADDONPATH) }, 'types': ['person'] }, { 'label': ADDON.getLocalizedString(32230), 'params': { 'info': 'crew_in_tvshows' }, 'path': PLUGINPATH, 'art': { 'thumb': u'{}/resources/icons/tmdb/tv.png'.format(ADDONPATH) }, 'types': ['person'] }, { 'label': ADDON.getLocalizedString(32191), 'params': { 'info': 'images' }, 'path': PLUGINPATH, 'art': { 'thumb': u'{}/resources/icons/tmdb/images.png'.format(ADDONPATH) }, 'types': ['person'] }, { 'label': ADDON.getLocalizedString(32231), 'params': { 'info': 'episode_thumbs' }, 'path': PLUGINPATH, 'art': { 'thumb': u'{}/resources/icons/tmdb/images.png'.format(ADDONPATH) }, 'types': ['episode'] }, { 'label': xbmc.getLocalizedString(10025), 'params': { 'info': 'videos' }, 'path': PLUGINPATH, 'art': { 'thumb': u'{}/resources/icons/tmdb/movies.png'.format(ADDONPATH) }, 'types': ['movie', 'tv', 'episode'] }, { 'label': ADDON.getLocalizedString(32345), 'params': { 'info': 'episode_groups' }, 'path': PLUGINPATH, 'art': { 'thumb': u'{}/resources/icons/tmdb/episodes.png'.format(ADDONPATH) }, 'types': ['tv'] }, { 'label': ADDON.getLocalizedString(32232), 'params': { 'info': 'trakt_inlists' }, 'path': PLUGINPATH, 'art': { 'thumb': u'{}/resources/icons/tmdb/trakt.png'.format(ADDONPATH) }, 'types': ['null'] }]
def _getself(self): self.remove = xbmc.getInfoLabel( "ListItem.Property(param.owner)") == 'true' self.name = ADDON.getLocalizedString( 32355) if self.remove else ADDON.getLocalizedString(32298) return self
def _get_basedir_trakt(): return [{ 'label': u'{{item_type}}{{space}}{}'.format(ADDON.getLocalizedString(32192)), 'types': ['movie', 'tv'], 'params': { 'info': 'trakt_collection' }, 'path': PLUGINPATH, 'sorting': True, 'art': { 'thumb': '{}/resources/icons/trakt/watchlist.png'.format(ADDONPATH) } }, { 'label': u'{{item_type}}{{space}}{}'.format(ADDON.getLocalizedString(32193)), 'types': ['movie', 'tv'], 'params': { 'info': 'trakt_watchlist' }, 'path': PLUGINPATH, 'sorting': True, 'art': { 'thumb': '{}/resources/icons/trakt/watchlist.png'.format(ADDONPATH) } }, { 'label': u'{}{{space}}{{item_type}}'.format(ADDON.getLocalizedString(32194)), 'types': ['movie', 'tv'], 'params': { 'info': 'trakt_history' }, 'path': PLUGINPATH, 'art': { 'thumb': '{}/resources/icons/trakt/recentlywatched.png'.format(ADDONPATH) } }, { 'label': u'{}{{space}}{{item_type}}'.format(ADDON.getLocalizedString(32195)), 'types': ['movie', 'tv'], 'params': { 'info': 'trakt_mostwatched' }, 'path': PLUGINPATH, 'art': { 'thumb': '{}/resources/icons/trakt/mostwatched.png'.format(ADDONPATH) } }, { 'label': u'{}{{space}}{{item_type}}'.format(ADDON.getLocalizedString(32196)), 'types': ['movie', 'tv'], 'params': { 'info': 'trakt_inprogress' }, 'path': PLUGINPATH, 'sorting': True, 'art': { 'thumb': '{}/resources/icons/trakt/inprogress.png'.format(ADDONPATH) } }, { 'label': ADDON.getLocalizedString(32197), 'types': ['tv'], 'params': { 'info': 'trakt_nextepisodes' }, 'path': PLUGINPATH, 'art': { 'thumb': '{}/resources/icons/trakt/inprogress.png'.format(ADDONPATH) } }, { 'label': u'{{item_type}}{{space}}{}'.format(ADDON.getLocalizedString(32198)), 'types': ['movie', 'tv'], 'params': { 'info': 'trakt_recommendations' }, 'path': PLUGINPATH, 'art': { 'thumb': '{}/resources/icons/trakt/recommended.png'.format(ADDONPATH) } }, { 'label': u'{}{{space}}{{item_type}}'.format(ADDON.getLocalizedString(32199)), 'types': ['movie', 'tv'], 'params': { 'info': 'trakt_becauseyouwatched' }, 'path': PLUGINPATH, 'art': { 'thumb': '{}/resources/icons/trakt/recommended.png'.format(ADDONPATH) } }, { 'label': u'{}{{space}}{{item_type}}'.format(ADDON.getLocalizedString(32200)), 'types': ['movie', 'tv'], 'params': { 'info': 'trakt_becausemostwatched' }, 'path': PLUGINPATH, 'art': { 'thumb': '{}/resources/icons/trakt/recommended.png'.format(ADDONPATH) } }, { 'label': u'{} {{item_type}}{{space}}{}'.format(ADDON.getLocalizedString(32201), ADDON.getLocalizedString(32202)), 'types': ['tv'], 'params': { 'info': 'trakt_myairing' }, 'path': PLUGINPATH, 'art': { 'thumb': '{}/resources/icons/trakt/airing.png'.format(ADDONPATH) } }, { 'label': u'{} {{item_type}}{{space}}{}'.format(ADDON.getLocalizedString(32201), ADDON.getLocalizedString(32203)), 'types': ['tv'], 'params': { 'info': 'dir_calendar_trakt' }, 'path': PLUGINPATH, 'art': { 'thumb': '{}/resources/icons/trakt/calendar.png'.format(ADDONPATH) } }, { 'label': u'{}{{space}}{{item_type}}'.format(ADDON.getLocalizedString(32204)), 'types': ['movie', 'tv'], 'params': { 'info': 'trakt_trending' }, 'path': PLUGINPATH, 'art': { 'thumb': '{}/resources/icons/trakt/trend.png'.format(ADDONPATH) } }, { 'label': u'{}{{space}}{{item_type}}'.format(ADDON.getLocalizedString(32175)), 'types': ['movie', 'tv'], 'params': { 'info': 'trakt_popular' }, 'path': PLUGINPATH, 'art': { 'thumb': '{}/resources/icons/trakt/popular.png'.format(ADDONPATH) } }, { 'label': u'{}{{space}}{{item_type}}'.format(ADDON.getLocalizedString(32205)), 'types': ['movie', 'tv'], 'params': { 'info': 'trakt_mostplayed' }, 'path': PLUGINPATH, 'art': { 'thumb': '{}/resources/icons/trakt/mostplayed.png'.format(ADDONPATH) } }, { 'label': u'{}{{space}}{{item_type}}'.format(ADDON.getLocalizedString(32206)), 'types': ['movie', 'tv'], 'params': { 'info': 'trakt_anticipated' }, 'path': PLUGINPATH, 'art': { 'thumb': '{}/resources/icons/trakt/anticipated.png'.format(ADDONPATH) } }, { 'label': u'{}{{space}}{{item_type}}'.format(ADDON.getLocalizedString(32207)), 'types': ['movie'], 'params': { 'info': 'trakt_boxoffice' }, 'path': PLUGINPATH, 'art': { 'thumb': '{}/resources/icons/trakt/boxoffice.png'.format(ADDONPATH) } }, { 'label': ADDON.getLocalizedString(32208), 'types': ['both'], 'params': { 'info': 'trakt_trendinglists' }, 'path': PLUGINPATH, 'art': { 'thumb': '{}/resources/icons/trakt/trendinglist.png'.format(ADDONPATH) } }, { 'label': ADDON.getLocalizedString(32209), 'types': ['both'], 'params': { 'info': 'trakt_popularlists' }, 'path': PLUGINPATH, 'art': { 'thumb': '{}/resources/icons/trakt/popularlist.png'.format(ADDONPATH) } }, { 'label': ADDON.getLocalizedString(32210), 'types': ['both'], 'params': { 'info': 'trakt_likedlists' }, 'path': PLUGINPATH, 'art': { 'thumb': '{}/resources/icons/trakt/likedlist.png'.format(ADDONPATH) } }, { 'label': ADDON.getLocalizedString(32211), 'types': ['both'], 'params': { 'info': 'trakt_mylists' }, 'path': PLUGINPATH, 'art': { 'thumb': '{}/resources/icons/trakt/mylists.png'.format(ADDONPATH) } }]
def _get_genre(tmdb_type, method): data_list = TMDb().get_request_lc('genre', tmdb_type, 'list') if data_list and data_list.get('genres'): return _select_properties(data_list['genres'], method, header=ADDON.getLocalizedString(32112))
def monitor_userlist(): # Build list choices with busy_dialog(): user_lists = [{ 'label': '{} {}'.format(ADDON.getLocalizedString(32193), xbmc.getLocalizedString(20342)), 'params': { 'user_slug': 'me', 'list_slug': 'watchlist/movies' } }, { 'label': '{} {}'.format(ADDON.getLocalizedString(32193), xbmc.getLocalizedString(20343)), 'params': { 'user_slug': 'me', 'list_slug': 'watchlist/shows' } }] user_lists += TraktAPI().get_list_of_lists( 'users/me/lists', authorize=True, next_page=False) or [] user_lists += TraktAPI().get_list_of_lists( 'users/likes/lists', authorize=True, next_page=False) or [] saved_lists = get_monitor_userlists() dialog_list = [i['label'] for i in user_lists] preselected = [ x for x, i in enumerate(user_lists) if (i.get('params', {}).get('list_slug'), i.get('params', {}).get('user_slug')) in saved_lists ] # Ask user to choose lists indices = xbmcgui.Dialog().multiselect(ADDON.getLocalizedString(32312), dialog_list, preselect=preselected) if indices is None: return # Build the new settings and check that lists aren't over limit added_lists, added_users = [], [] for x in indices: list_slug = user_lists[x].get('params', {}).get('list_slug') user_slug = user_lists[x].get('params', {}).get('user_slug') if get_userlist(user_slug, list_slug, confirm=50): added_lists.append(list_slug) added_users.append(user_slug) # Set the added lists to our settings if not added_lists or not added_users: return added_lists = ' | '.join(added_lists) added_users = ' | '.join(added_users) ADDON.setSettingString('monitor_userlist', added_lists) ADDON.setSettingString('monitor_userslug', added_users) # Update library? if xbmcgui.Dialog().yesno(xbmc.getLocalizedString(653), ADDON.getLocalizedString(32132)): library_autoupdate(list_slugs=added_lists, user_slugs=added_users, busy_spinner=True)
def _start(self): if self.p_dialog: self.p_dialog.create('TMDbHelper', ADDON.getLocalizedString(32166)) if not ADDON.getSettingBool('legacy_conversion'): self.legacy_conversion()
def get_season_list(self, tmdb_id, special_folders=0): """ special_folders: int binary to hide: 001 (1) = Hide Specials, 010 (2) = Hide Up Next, 100 (4) = Hide Groups """ request = self.get_request_sc(u'tv/{}'.format(tmdb_id)) if not request: return [] base_item = self.mapper.get_info(request, 'tv') items, items_end = [], [] for i in request.get('seasons', []): item = self.mapper.get_info(i, 'season', base_item, definition=TMDB_PARAMS_SEASONS, tmdb_id=tmdb_id) # TODO: Fix play all # Might be issue with resolving to dummy file that resets playlist to 1 # item['context_menu'] += [( # xbmc.getLocalizedString(22083), # 'RunScript(plugin.video.themoviedb.helper,play_season={},tmdb_id={})'.format( # item['infolabels']['season'], tmdb_id))] if i.get('season_number') != 0: items.append(item) elif ((special_folders >> 0) & 1) == 0: # on bit in 0 pos hides specials items_end.append(item) # Episode Groups if ((special_folders >> 2) & 1) == 0: # on bit in 2 pos hides episode groups egroups = self.get_request_sc( u'tv/{}/episode_groups'.format(tmdb_id)) if egroups and egroups.get('results'): egroup_item = self.mapper.get_info( {'title': ADDON.getLocalizedString(32345)}, 'season', base_item, tmdb_id=tmdb_id, definition={ 'info': 'episode_groups', 'tmdb_type': 'tv', 'tmdb_id': tmdb_id }) egroup_item['art']['thumb'] = egroup_item['art'][ 'poster'] = u'{}/resources/icons/trakt/groupings.png'.format( ADDONPATH) items_end.append(egroup_item) # Up Next if ((special_folders >> 1) & 1) == 0: # on bit in 1 pos hides up next if get_property('TraktIsAuth') == 'True': upnext_item = self.mapper.get_info( {'title': ADDON.getLocalizedString(32043)}, 'season', base_item, tmdb_id=tmdb_id, definition={ 'info': 'trakt_upnext', 'tmdb_type': 'tv', 'tmdb_id': tmdb_id }) upnext_item['art']['thumb'] = upnext_item['art'][ 'poster'] = u'{}/resources/icons/trakt/up-next.png'.format( ADDONPATH) items_end.append(upnext_item) return items + items_end
def __init__(self, download_url=None, extract_to=None): self.download_url = download_url self.extract_to = xbmc.translatePath(extract_to) self.msg_cleardir = ADDON.getLocalizedString(32054)
def get_sort_methods(default_only=False): items = [{ 'name': u'{}: {}'.format(ADDON.getLocalizedString(32287), ADDON.getLocalizedString(32286)), 'params': { 'sort_by': 'rank', 'sort_how': 'asc' } }, { 'name': u'{}: {}'.format(ADDON.getLocalizedString(32287), ADDON.getLocalizedString(32106)), 'params': { 'sort_by': 'added', 'sort_how': 'desc' } }, { 'name': u'{}: {}'.format(ADDON.getLocalizedString(32287), xbmc.getLocalizedString(369)), 'params': { 'sort_by': 'title', 'sort_how': 'asc' } }, { 'name': u'{}: {}'.format(ADDON.getLocalizedString(32287), xbmc.getLocalizedString(16102)), 'params': { 'sort_by': 'watched', 'sort_how': 'desc', 'extended': 'sync' } }, { 'name': u'{}: {}'.format(ADDON.getLocalizedString(32287), xbmc.getLocalizedString(563)), 'params': { 'sort_by': 'percentage', 'sort_how': 'desc', 'extended': 'full' } }, { 'name': u'{}: {}'.format(ADDON.getLocalizedString(32287), xbmc.getLocalizedString(345)), 'params': { 'sort_by': 'year', 'sort_how': 'desc' } }, { 'name': u'{}: {}'.format(ADDON.getLocalizedString(32287), ADDON.getLocalizedString(32377)), 'params': { 'sort_by': 'plays', 'sort_how': 'desc', 'extended': 'sync' } }, { 'name': u'{}: {}'.format(ADDON.getLocalizedString(32287), ADDON.getLocalizedString(32242)), 'params': { 'sort_by': 'released', 'sort_how': 'desc', 'extended': 'full' } }, { 'name': u'{}: {}'.format(ADDON.getLocalizedString(32287), xbmc.getLocalizedString(2050)), 'params': { 'sort_by': 'runtime', 'sort_how': 'desc', 'extended': 'full' } }, { 'name': u'{}: {}'.format(ADDON.getLocalizedString(32287), xbmc.getLocalizedString(205)), 'params': { 'sort_by': 'votes', 'sort_how': 'desc', 'extended': 'full' } }, { 'name': u'{}: {}'.format(ADDON.getLocalizedString(32287), ADDON.getLocalizedString(32175)), 'params': { 'sort_by': 'popularity', 'sort_how': 'desc', 'extended': 'full' } }, { 'name': u'{}: {}'.format(ADDON.getLocalizedString(32287), xbmc.getLocalizedString(590)), 'params': { 'sort_by': 'random' } }] if default_only: return [ i for i in items if i['params']['sort_by'] in ['rank', 'added', 'title', 'year', 'random'] ] return items
def _getself(self): self.name = ADDON.getLocalizedString(32304) return self
def _player_dialog_select(self, folder, auto=False): d_items = [] for f in folder: # Skip items without labels as probably not worth playing if not f.get('label') or f.get('label') == 'None': continue # Get the label of the item label_a = f.get('label') label_b_list = [] # Add year to our label if exists and not special value of 1601 if f.get('year') and f.get('year') != 1601: label_a = u'{} ({})'.format(label_a, f.get('year')) # Add season and episode numbers to label if try_int(f.get('season', 0)) > 0 and try_int(f.get('episode', 0)) > 0: if f.get( 'filetype' ) == 'file': # If file assume is an episode so add to main label label_a = u'{}x{}. {}'.format(f['season'], f['episode'], label_a) else: # If folder assume is tvshow or season so add episode count to label2 label_b_list.append(u'{} {}'.format( f['episode'], xbmc.getLocalizedString(20360))) # Add various stream details to ListItem.Label2 (aka label_b) if f.get('streamdetails'): sdv_list = f.get('streamdetails', {}).get('video', [{}]) or [{}] sda_list = f.get('streamdetails', {}).get('audio', [{}]) or [{}] sdv, sda = sdv_list[0], sda_list[0] if sdv.get('width') or sdv.get('height'): label_b_list.append(u'{}x{}'.format( sdv.get('width'), sdv.get('height'))) if sdv.get('codec'): label_b_list.append(u'{}'.format( sdv.get('codec', '').upper())) if sda.get('codec'): label_b_list.append(u'{}'.format( sda.get('codec', '').upper())) if sda.get('channels'): label_b_list.append(u'{} CH'.format(sda.get( 'channels', ''))) for i in sda_list: if i.get('language'): label_b_list.append(u'{}'.format( i.get('language', '').upper())) if sdv.get('duration'): label_b_list.append(u'{} mins'.format( try_int(sdv.get('duration', 0)) // 60)) if f.get('size'): label_b_list.append(u'{}'.format( normalise_filesize(f.get('size', 0)))) label_b = ' | '.join(label_b_list) if label_b_list else '' # Add item to select dialog list d_items.append( ListItem(label=label_a, label2=label_b, art={ 'thumb': f.get('thumbnail') }).get_listitem()) if not d_items: return -1 # No items so ask user to select new player # If autoselect enabled and only 1 item choose that otherwise ask user to choose idx = 0 if auto and len(d_items) == 1 else xbmcgui.Dialog().select( ADDON.getLocalizedString(32236), d_items, useDetails=True) if idx == -1: return # User exited the dialog so return nothing is_folder = False if folder[idx].get('filetype') == 'file' else True return (folder[idx].get('file'), is_folder) # Return the player
def get_list_of_lists(self, path, page=1, limit=250, authorize=False, next_page=True): response = self.get_response(path, page=page, limit=limit) like_list = True if path.startswith('lists/') else False delete_like = True if path.startswith('users/likes') else False if not response: return items = [] for i in response.json(): if i.get('list', {}).get('name'): i = i.get('list', {}) elif not i.get('name'): continue item = {} item['label'] = i.get('name') item['infolabels'] = {'plot': i.get('description')} item['infoproperties'] = { k: v for k, v in viewitems(i) if v and type(v) not in [list, dict] } item['art'] = {} item['params'] = { 'info': 'trakt_userlist', 'list_slug': i.get('ids', {}).get('slug'), 'user_slug': i.get('user', {}).get('ids', {}).get('slug') } item['unique_ids'] = { 'trakt': i.get('ids', {}).get('trakt'), 'slug': i.get('ids', {}).get('slug'), 'user': i.get('user', {}).get('ids', {}).get('slug') } item['infoproperties']['tmdbhelper.context.sorting'] = dumps( item['params']) # Add library context menu item['context_menu'] = [ (xbmc.getLocalizedString(20444), 'Runscript(plugin.video.themoviedb.helper,{})'.format( 'user_list={list_slug},user_slug={user_slug}'.format( **item['params']))) ] # Unlike list context menu if path.startswith('users/likes'): item['context_menu'] += [ (ADDON.getLocalizedString(32319), 'Runscript(plugin.video.themoviedb.helper,{},delete)'. format( 'like_list={list_slug},user_slug={user_slug}'.format( **item['params']))) ] # Like list context menu elif path.startswith('lists/'): item['context_menu'] += [ (ADDON.getLocalizedString(32315), 'Runscript(plugin.video.themoviedb.helper,{})'.format( 'like_list={list_slug},user_slug={user_slug}'.format( **item['params']))) ] # Owner of list so set param to allow deleting later else: item['params']['owner'] = 'true' item['context_menu'] += [ (xbmc.getLocalizedString(118), 'Runscript(plugin.video.themoviedb.helper,{})'.format( 'rename_list={list_slug}'.format(**item['params']))) ] item['context_menu'] += [ (xbmc.getLocalizedString(117), 'Runscript(plugin.video.themoviedb.helper,{})'.format( 'delete_list={list_slug}'.format(**item['params']))) ] items.append(item) if not next_page: return items return items + pages.get_next_page(response.headers)
def _get_upnext_season_item(self, base_item): base_item['params']['info'] = 'trakt_upnext' base_item['infolabels']['mediatype'] = 'season' base_item['label'] = base_item['infolabels'][ 'title'] = ADDON.getLocalizedString(32043) return [base_item]
def select_artwork(self, ftv_id, ftv_type, container_refresh=True, blacklist=[]): if ftv_type not in ['movies', 'tv']: return with busy_dialog(): artwork = self.get_artwork_request(ftv_id, ftv_type) if not artwork: return xbmcgui.Dialog().notification( 'FanartTV', ADDON.getLocalizedString(32217).format(ftv_type, ftv_id)) # Choose Type _artwork_types = [ 'poster', 'fanart', 'clearart', 'clearlogo', 'landscape', 'banner' ] _artwork_types.append('discart' if ftv_type == 'movies' else 'characterart') artwork_types = [i for i in _artwork_types if i not in blacklist ] # Remove types that we previously looked for choice = xbmcgui.Dialog().select(xbmc.getLocalizedString(13511), artwork_types) if choice == -1: return # Get artwork of user's choosing artwork_type = artwork_types[choice] artwork_items = self.get_artwork(ftv_id, ftv_type, artwork_type, get_list=True) # If there was not artwork of that type found then blacklist it before re-prompting if not artwork_items: xbmcgui.Dialog().notification( 'FanartTV', ADDON.getLocalizedString(32217).format(ftv_type, ftv_id)) blacklist.append(artwork_types[choice]) return self.select_artwork(ftv_id, ftv_type, container_refresh, blacklist) # Choose artwork from options items = [ ListItem(label=i.get('url'), label2=ADDON.getLocalizedString(32219).format( i.get('lang', ''), i.get('likes', 0), i.get('id', '')), art={ 'thumb': i.get('url') }).get_listitem() for i in artwork_items if i.get('url') ] choice = xbmcgui.Dialog().select(xbmc.getLocalizedString(13511), items, useDetails=True) if choice == -1: # If user hits back go back to main menu rather than exit completely return self.select_artwork(ftv_id, ftv_type, container_refresh, blacklist) # Cache our choice as the best artwork forever since it was selected manually # Some types have have HD and SD variants so set cache for both for i in ARTWORK_TYPES.get(ftv_type, {}).get(artwork_type, []): success = cache.set_cache( artwork_items[choice].get('url'), cache_name='fanart_tv.best.{}.{}.{}.{}'.format( self.language, ftv_id, ftv_type, i), cache_days=10000) if success and container_refresh: xbmc.executebuiltin('Container.Refresh') xbmc.executebuiltin( 'UpdateLibrary(video,/fake/path/to/force/refresh/on/home)')
def _get_basedir_rules(tmdb_type): items = [{ 'label': ADDON.getLocalizedString(32263), 'method': 'with_genres' }, { 'label': ADDON.getLocalizedString(32264), 'method': 'without_genres' }, { 'label': ADDON.getLocalizedString(32265), 'method': 'with_companies' }, { 'label': ADDON.getLocalizedString(32268), 'method': 'with_keywords' }, { 'label': ADDON.getLocalizedString(32267), 'method': 'without_keywords' }] items += _get_basedir_rules_movies( ) if tmdb_type == 'movie' else _get_basedir_rules_tv() items += [{ 'label': ADDON.getLocalizedString(32269), 'method': 'with_original_language' }, { 'label': ADDON.getLocalizedString(32270), 'method': 'vote_count.gte' }, { 'label': ADDON.getLocalizedString(32271), 'method': 'vote_count.lte' }, { 'label': ADDON.getLocalizedString(32272), 'method': 'vote_average.gte' }, { 'label': ADDON.getLocalizedString(32273), 'method': 'vote_average.lte' }, { 'label': ADDON.getLocalizedString(32274), 'method': 'with_runtime.gte' }, { 'label': ADDON.getLocalizedString(32275), 'method': 'with_runtime.lte' }] return items
def _get_separator(): if xbmcgui.Dialog().yesno( ADDON.getLocalizedString(32107), ADDON.getLocalizedString(32108), yeslabel=ADDON.getLocalizedString(32109), nolabel=ADDON.getLocalizedString(32110)): return {'value': 'OR', 'label': 'ANY', 'method': 'with_separator'} return {'value': 'AND', 'label': 'ALL', 'method': 'with_separator'}
def list_discoverdir(self, **kwargs): items = [] params = merge_two_dicts(kwargs, {'info': 'user_discover'}) artwork = {'thumb': '{}/resources/poster.png'.format(ADDONPATH)} for i in ['movie', 'tv']: item = { 'label': u'{} {}'.format(ADDON.getLocalizedString(32174), convert_type(i, 'plural')), 'params': merge_two_dicts(params, {'tmdb_type': i}), 'infoproperties': { 'specialsort': 'top' }, 'art': artwork } items.append(item) history = get_search_history('discover') history.reverse() for x, i in enumerate(history): item_params = merge_two_dicts(kwargs, i.get('params', {})) edit_params = { 'info': 'user_discover', 'tmdb_type': item_params.get('tmdb_type'), 'method': 'edit', 'idx': x } name_params = { 'info': 'dir_discover', 'tmdb_type': item_params.get('tmdb_type'), 'method': 'rename', 'idx': x } dele_params = { 'info': 'dir_discover', 'tmdb_type': item_params.get('tmdb_type'), 'method': 'delete', 'idx': x } item = { 'label': i.get('label'), 'params': item_params, 'art': artwork, 'context_menu': [(xbmc.getLocalizedString(21435), 'Container.Update({})'.format( encode_url(PLUGINPATH, **edit_params))), (xbmc.getLocalizedString(118), 'Container.Update({})'.format( encode_url(PLUGINPATH, **name_params))), (xbmc.getLocalizedString(117), 'Container.Update({})'.format( encode_url(PLUGINPATH, **dele_params)))] } items.append(item) if history: item = { 'label': ADDON.getLocalizedString(32237), 'art': artwork, 'params': merge_two_dicts(params, { 'info': 'dir_discover', 'clear_cache': 'True' }) } items.append(item) return items
def _get_basedir_calendar_items(): return [{ 'label': ADDON.getLocalizedString(32280), 'params': { 'startdate': -14, 'days': 14 }, 'path': PLUGINPATH, 'info_types': ['trakt_calendar', 'library_nextaired'], 'art': { 'thumb': u'{}/resources/poster.png'.format(ADDONPATH) } }, { 'label': ADDON.getLocalizedString(32281), 'params': { 'startdate': -7, 'days': 7 }, 'path': PLUGINPATH, 'info_types': ['trakt_calendar', 'library_nextaired'], 'art': { 'thumb': u'{}/resources/poster.png'.format(ADDONPATH) } }, { 'label': ADDON.getLocalizedString(32282), 'params': { 'startdate': -1, 'days': 1 }, 'path': PLUGINPATH, 'info_types': ['trakt_calendar', 'library_nextaired'], 'art': { 'thumb': u'{}/resources/poster.png'.format(ADDONPATH) } }, { 'label': xbmc.getLocalizedString(33006), 'params': { 'startdate': 0, 'days': 1 }, 'path': PLUGINPATH, 'info_types': ['trakt_calendar', 'library_nextaired'], 'art': { 'thumb': u'{}/resources/poster.png'.format(ADDONPATH) } }, { 'label': xbmc.getLocalizedString(33007), 'params': { 'startdate': 1, 'days': 1 }, 'path': PLUGINPATH, 'info_types': ['trakt_calendar', 'library_nextaired'], 'art': { 'thumb': u'{}/resources/poster.png'.format(ADDONPATH) } }, { 'label': u'{weekday}', 'params': { 'startdate': 2, 'days': 1 }, 'path': PLUGINPATH, 'info_types': ['trakt_calendar', 'library_nextaired'], 'art': { 'thumb': u'{}/resources/poster.png'.format(ADDONPATH) } }, { 'label': u'{weekday}', 'params': { 'startdate': 3, 'days': 1 }, 'path': PLUGINPATH, 'info_types': ['trakt_calendar', 'library_nextaired'], 'art': { 'thumb': u'{}/resources/poster.png'.format(ADDONPATH) } }, { 'label': u'{weekday}', 'params': { 'startdate': 4, 'days': 1 }, 'path': PLUGINPATH, 'info_types': ['trakt_calendar', 'library_nextaired'], 'art': { 'thumb': u'{}/resources/poster.png'.format(ADDONPATH) } }, { 'label': u'{weekday}', 'params': { 'startdate': 5, 'days': 1 }, 'path': PLUGINPATH, 'info_types': ['trakt_calendar', 'library_nextaired'], 'art': { 'thumb': u'{}/resources/poster.png'.format(ADDONPATH) } }, { 'label': u'{weekday}', 'params': { 'startdate': 6, 'days': 1 }, 'path': PLUGINPATH, 'info_types': ['trakt_calendar', 'library_nextaired'], 'art': { 'thumb': u'{}/resources/poster.png'.format(ADDONPATH) } }, { 'label': ADDON.getLocalizedString(32284), 'params': { 'startdate': 0, 'days': 7 }, 'path': PLUGINPATH, 'info_types': ['trakt_calendar', 'library_nextaired'], 'art': { 'thumb': u'{}/resources/poster.png'.format(ADDONPATH) } }, { 'label': ADDON.getLocalizedString(32285), 'params': { 'startdate': 0, 'days': 14 }, 'path': PLUGINPATH, 'info_types': ['trakt_calendar', 'library_nextaired'], 'art': { 'thumb': u'{}/resources/poster.png'.format(ADDONPATH) } }]
def __init__(self, language=None, mpaa_prefix=None): self.language = language or get_language() self.mpaa_prefix = mpaa_prefix or get_mpaa_prefix() self.iso_language = language[:2] self.iso_country = language[-2:] self.blacklist = [] """ Mapping dictionary keys: list of tuples containing parent and child key to add value. [('parent', 'child')] parent keys: art, unique_ids, infolabels, infoproperties, params use UPDATE_BASEKEY for child key to update parent with a dict func: function to call to manipulate values (omit to skip and pass value directly) (kw)args: list/dict of args/kwargs to pass to func. func is also always passed v as first argument type: int, float, str - convert v to type using try_type(v, type) extend: set True to add to existing list - leave blank to overwrite exiting list subkeys: list of sub keys to get for v - i.e. v.get(subkeys[0], {}).get(subkeys[1]) etc. note that getting subkeys sticks for entire loop so do other ops on base first if needed use standard_map for direct one-to-one mapping of v onto single property tuple """ self.advanced_map = { 'poster_path': [{ 'keys': [('art', 'poster')], 'func': get_imagepath_poster }], 'profile_path': [{ 'keys': [('art', 'poster')], 'func': get_imagepath_poster }], 'file_path': [{ 'keys': [('art', 'poster')], 'func': get_imagepath_fanart }], 'still_path': [{ 'keys': [('art', 'thumb')], 'func': get_imagepath_fanart }], 'backdrop_path': [{ 'keys': [('art', 'fanart')], 'func': get_imagepath_fanart }], 'content_ratings': [{ 'keys': [('infolabels', 'mpaa')], 'subkeys': ['results'], 'func': get_mpaa_rating, 'args': [self.mpaa_prefix, self.iso_country, False] }], 'release_dates': [{ 'keys': [('infolabels', 'mpaa')], 'subkeys': ['results'], 'func': get_mpaa_rating, 'args': [self.mpaa_prefix, self.iso_country, True] }], 'release_date': [{ 'keys': [('infolabels', 'premiered')] }, { 'keys': [('infolabels', 'year')], 'func': lambda v: v[0:4] }], 'first_air_date': [{ 'keys': [('infolabels', 'premiered')] }, { 'keys': [('infolabels', 'year')], 'func': lambda v: v[0:4] }], 'air_date': [{ 'keys': [('infolabels', 'premiered')] }, { 'keys': [('infolabels', 'year')], 'func': lambda v: v[0:4] }], 'genre_ids': [{ 'keys': [('infolabels', 'genre')], 'func': get_genres_by_id }], 'videos': [{ 'keys': [('infolabels', 'trailer')], 'func': get_trailer }], 'popularity': [{ 'keys': [('infoproperties', 'popularity')], 'type': str }], 'vote_count': [{ 'keys': [('infolabels', 'votes'), ('infoproperties', 'tmdb_votes')], 'type': float, 'func': lambda v: u'{:0,.0f}'.format(v) }], 'vote_average': [{ 'keys': [('infolabels', 'rating'), ('infoproperties', 'tmdb_rating')], 'type': float, 'func': lambda v: u'{:.1f}'.format(v) }], 'budget': [{ 'keys': [('infoproperties', 'budget')], 'type': float, 'func': lambda v: u'${:0,.0f}'.format(v) }], 'revenue': [{ 'keys': [('infoproperties', 'revenue')], 'type': float, 'func': lambda v: u'${:0,.0f}'.format(v) }], 'spoken_languages': [{ 'keys': [('infoproperties', UPDATE_BASEKEY)], 'func': iter_props, 'args': ['language'], 'kwargs': { 'name': 'name', 'iso': 'iso_639_1' } }], 'keywords': [{ 'keys': [('infoproperties', UPDATE_BASEKEY)], 'subkeys': ['keywords'], 'func': iter_props, 'args': ['keyword'], 'kwargs': { 'name': 'name', 'tmdb_id': 'id' } }], 'reviews': [{ 'keys': [('infoproperties', UPDATE_BASEKEY)], 'subkeys': ['results'], 'func': iter_props, 'args': ['review'], 'kwargs': { 'content': 'content', 'author': 'author', 'tmdb_id': 'id' } }], 'created_by': [ { 'keys': [('infoproperties', UPDATE_BASEKEY)], 'func': get_iter_props, 'args': ['creator'], 'kwargs': { 'basic_keys': { 'name': 'name', 'tmdb_id': 'id' }, 'image_keys': { 'thumb': 'profile_path' } } }, { # --- 'keys': [('infoproperties', 'creator')], 'func': lambda v: ' / '.join( [x['name'] for x in v or [] if x.get('name')]) } ], 'also_known_as': [{ 'keys': [('infoproperties', 'aliases')], 'func': lambda v: ' / '.join([x for x in v or [] if x]) }], 'known_for': [ { 'keys': [('infoproperties', UPDATE_BASEKEY)], 'func': iter_props, 'args': ['known_for'], 'kwargs': { 'title': 'title', 'tmdb_id': 'id', 'rating': 'vote_average', 'tmdb_type': 'media_type' } }, { # --- 'keys': [('infoproperties', 'known_for')], 'func': lambda v: ' / '.join( [x['title'] for x in v or [] if x.get('title')]) } ], 'external_ids': [{ 'keys': [('unique_ids', UPDATE_BASEKEY)], 'func': get_external_ids }], 'credits': [ { 'keys': [('infolabels', UPDATE_BASEKEY)], 'func': get_credits }, { # --- 'keys': [('infoproperties', UPDATE_BASEKEY)], 'subkeys': ['crew'], 'func': get_crew_properties } ], 'parts': [{ 'keys': [('infoproperties', UPDATE_BASEKEY)], 'func': get_collection_properties }], 'movie_credits': [ { 'keys': [('infoproperties', 'numitems.tmdb.movies.cast')], 'func': lambda v: len(v.get('cast') or []) }, { # --- 'keys': [('infoproperties', 'numitems.tmdb.movies.crew')], 'func': lambda v: len(v.get('crew') or []) }, { # --- 'keys': [('infoproperties', 'numitems.tmdb.movies.total')], 'func': lambda v: len(v.get('cast') or []) + len( v.get('crew') or []) } ], 'tv_credits': [ { 'keys': [('infoproperties', 'numitems.tmdb.tvshows.cast')], 'func': lambda v: len(v.get('cast') or []) }, { # --- 'keys': [('infoproperties', 'numitems.tmdb.tvshows.crew')], 'func': lambda v: len(v.get('crew') or []) }, { # --- 'keys': [('infoproperties', 'numitems.tmdb.tvshows.total')], 'func': lambda v: len(v.get('cast') or []) + len( v.get('crew') or []) } ], 'belongs_to_collection': [ { 'keys': [('infoproperties', UPDATE_BASEKEY)], 'func': get_collection }, { # --- 'keys': [('infolabels', 'set')], 'subkeys': ['name'] } ], 'episode_run_time': [{ 'keys': [('infolabels', 'duration')], 'func': get_runtime }], 'runtime': [{ 'keys': [('infolabels', 'duration')], 'func': get_runtime }], 'genres': [ { 'keys': [('infolabels', 'genre')], 'func': dict_to_list, 'args': ['name'] }, { # --- 'keys': [('infoproperties', UPDATE_BASEKEY)], 'func': iter_props, 'args': ['genre'], 'kwargs': { 'name': 'name', 'tmdb_id': 'id' } } ], 'production_countries': [ { 'keys': [('infolabels', 'country')], 'extend': True, 'func': dict_to_list, 'args': ['name'] }, { # --- 'keys': [('infoproperties', UPDATE_BASEKEY)], 'func': iter_props, 'args': ['country'], 'kwargs': { 'name': 'name', 'tmdb_id': 'id' } } ], 'networks': [ { 'keys': [('infolabels', 'studio')], 'extend': True, 'func': dict_to_list, 'args': ['name'] }, { # --- 'keys': [('infoproperties', UPDATE_BASEKEY)], 'func': get_iter_props, 'args': ['studio'], 'kwargs': { 'basic_keys': { 'name': 'name', 'tmdb_id': 'id' }, 'image_keys': { 'icon': 'logo_path' } } } ], 'production_companies': [ { 'keys': [('infolabels', 'studio')], 'extend': True, 'func': dict_to_list, 'args': ['name'] }, { # --- 'keys': [('infoproperties', UPDATE_BASEKEY)], 'func': get_iter_props, 'args': ['studio'], 'kwargs': { 'basic_keys': { 'name': 'name', 'tmdb_id': 'id' }, 'image_keys': { 'icon': 'logo_path' } } } ], 'watch/providers': [{ 'keys': [('infoproperties', UPDATE_BASEKEY)], 'subkeys': ['results', self.iso_country], 'func': get_providers }], 'last_episode_to_air': [{ 'keys': [('infoproperties', UPDATE_BASEKEY)], 'func': get_episode_to_air, 'args': ['last_aired'] }], 'next_episode_to_air': [{ 'keys': [('infoproperties', UPDATE_BASEKEY)], 'func': get_episode_to_air, 'args': ['next_aired'] }], 'imdb_id': [{ 'keys': [('infolabels', 'imdbnumber'), ('unique_ids', 'imdb')] }], 'character': [{ 'keys': [('infoproperties', 'role'), ('infoproperties', 'character'), ('label2', None)] }], 'job': [{ 'keys': [('infoproperties', 'role'), ('infoproperties', 'job'), ('label2', None)] }], 'biography': [{ 'keys': [('infoproperties', 'biography'), ('infolabels', 'plot')] }], 'gender': [{ 'keys': [('infoproperties', 'gender')], 'func': lambda v, d: d.get(v), 'args': [{ 1: ADDON.getLocalizedString(32071), 2: ADDON.getLocalizedString(32070) }] }] } self.standard_map = { 'overview': ('infolabels', 'plot'), 'content': ('infolabels', 'plot'), 'tagline': ('infolabels', 'tagline'), 'id': ('unique_ids', 'tmdb'), 'original_title': ('infolabels', 'originaltitle'), 'original_name': ('infolabels', 'originaltitle'), 'title': ('infolabels', 'title'), 'name': ('infolabels', 'title'), 'author': ('infolabels', 'title'), 'origin_country': ('infolabels', 'country'), 'status': ('infolabels', 'status'), 'season_number': ('infolabels', 'season'), 'episode_number': ('infolabels', 'episode'), 'season_count': ('infolabels', 'season'), 'episode_count': ('infolabels', 'episode'), 'department': ('infoproperties', 'department'), 'place_of_birth': ('infoproperties', 'born'), 'birthday': ('infoproperties', 'birthday'), 'deathday': ('infoproperties', 'deathday'), 'width': ('infoproperties', 'width'), 'height': ('infoproperties', 'height'), 'aspect_ratio': ('infoproperties', 'aspect_ratio') }
def _get_basedir_random(): return [{ 'label': u'{} {{item_type}}{{space}}{}'.format(xbmc.getLocalizedString(590), xbmc.getLocalizedString(515)), 'types': ['movie', 'tv'], 'params': { 'info': 'random_genres' }, 'path': PLUGINPATH, 'art': { 'thumb': u'{}/resources/icons/tmdb/genre.png'.format(ADDONPATH) } }, { 'label': u'{} {{item_type}}{{space}}{}'.format(xbmc.getLocalizedString(590), ADDON.getLocalizedString(32117)), 'types': ['movie'], 'params': { 'info': 'random_keyword' }, 'path': PLUGINPATH, 'art': { 'thumb': u'{}/resources/poster.png'.format(ADDONPATH) } }, { 'label': u'{}{{space}}{{item_type}}'.format(ADDON.getLocalizedString(32199)), 'types': ['movie', 'tv'], 'params': { 'info': 'trakt_becauseyouwatched' }, 'path': PLUGINPATH, 'art': { 'thumb': u'{}/resources/icons/trakt/recommended.png'.format(ADDONPATH) } }, { 'label': u'{}{{space}}{{item_type}}'.format(ADDON.getLocalizedString(32200)), 'types': ['movie', 'tv'], 'params': { 'info': 'trakt_becausemostwatched' }, 'path': PLUGINPATH, 'art': { 'thumb': u'{}/resources/icons/trakt/recommended.png'.format(ADDONPATH) } }, { 'label': u'{} {}{{space}}{{item_type}}'.format(xbmc.getLocalizedString(590), ADDON.getLocalizedString(32204)), 'types': ['movie', 'tv', 'both'], 'params': { 'info': 'random_trending' }, 'path': PLUGINPATH, 'art': { 'thumb': u'{}/resources/icons/trakt/trend.png'.format(ADDONPATH) } }, { 'label': u'{} {}{{space}}{{item_type}}'.format(xbmc.getLocalizedString(590), ADDON.getLocalizedString(32175)), 'types': ['movie', 'tv', 'both'], 'params': { 'info': 'random_popular' }, 'path': PLUGINPATH, 'art': { 'thumb': u'{}/resources/icons/trakt/popular.png'.format(ADDONPATH) } }, { 'label': u'{} {}{{space}}{{item_type}}'.format(xbmc.getLocalizedString(590), ADDON.getLocalizedString(32205)), 'types': ['movie', 'tv', 'both'], 'params': { 'info': 'random_mostplayed' }, 'path': PLUGINPATH, 'art': { 'thumb': u'{}/resources/icons/trakt/mostplayed.png'.format(ADDONPATH) } }, { 'label': u'{} {}{{space}}{{item_type}}'.format(xbmc.getLocalizedString(590), ADDON.getLocalizedString(32206)), 'types': ['movie', 'tv', 'both'], 'params': { 'info': 'random_anticipated' }, 'path': PLUGINPATH, 'art': { 'thumb': u'{}/resources/icons/trakt/anticipated.png'.format(ADDONPATH) } }, { 'label': u'{} {}{{space}}{{item_type}}'.format(xbmc.getLocalizedString(590), ADDON.getLocalizedString(32300)), 'types': ['list'], 'params': { 'info': 'random_trendinglists' }, 'path': PLUGINPATH, 'art': { 'thumb': u'{}/resources/icons/trakt/trendinglist.png'.format(ADDONPATH) } }, { 'label': u'{} {}{{space}}{{item_type}}'.format(xbmc.getLocalizedString(590), ADDON.getLocalizedString(32301)), 'types': ['list'], 'params': { 'info': 'random_popularlists' }, 'path': PLUGINPATH, 'art': { 'thumb': u'{}/resources/icons/trakt/popularlist.png'.format(ADDONPATH) } }, { 'label': u'{} {}{{space}}{{item_type}}'.format(xbmc.getLocalizedString(590), ADDON.getLocalizedString(32302)), 'types': ['list'], 'params': { 'info': 'random_likedlists' }, 'path': PLUGINPATH, 'art': { 'thumb': u'{}/resources/icons/trakt/likedlist.png'.format(ADDONPATH) } }, { 'label': u'{} {}{{space}}{{item_type}}'.format(xbmc.getLocalizedString(590), ADDON.getLocalizedString(32303)), 'types': ['list'], 'params': { 'info': 'random_mylists' }, 'path': PLUGINPATH, 'art': { 'thumb': u'{}/resources/icons/trakt/mylists.png'.format(ADDONPATH) } }]
def _start(self): if self.p_dialog: self.p_dialog.create('TMDbHelper', ADDON.getLocalizedString(32166))
def _build_choices(self): choices = [{'name': ADDON.getLocalizedString(32298), 'method': 'userlist'}] choices += [j for j in (self._sync_item_check(**i) for i in _sync_item_methods()) if j] choices += [{'name': ADDON.getLocalizedString(32304), 'method': 'comments'}] return choices