def play_movie(tmdb_id, usedefault): from resources.lib.TheMovieDB import Movies play_plugin = meta_players.ADDON_SELECTOR.id players = meta_players.get_players('movies') players = [p for p in players if p.id == play_plugin] or players if not players or len(players) == 0: xbmc.executebuiltin('Action(Info)') play_base.action_cancel() return if usedefault == 'True': default = plugin.get_setting('moviesdefault', unicode) for player in players: if player.title == default: players = [player] movie = Movies(tmdb_id).info( language='en', append_to_response= 'external_ids,alternative_titles,credits,images,keywords,releases,translations,rating' ) movie_info = meta_info.get_movie_metadata(movie) imdb_id = movie['imdb_id'] if 'imdb_id' in movie else None id_type = 'imdb' if imdb_id and imdb_id.startswith('tt') else 'tmdb' id = imdb_id if imdb_id and imdb_id.startswith('tt') else tmdb_id trakt_ids = play_base.get_trakt_ids(id_type=id_type, id=id, type='movie') params = {} for lang in meta_players.get_needed_langs(players): if lang == 'en': tmdb_data = movie else: tmdb_data = Movies(tmdb_id).info( language=lang, append_to_response= 'external_ids,alternative_titles,credits,images,keywords,releases,translations,rating' ) params[lang] = get_movie_parameters(tmdb_data) if trakt_ids != None: params[lang].update(trakt_ids) params[lang]['info'] = movie_info params[lang] = text.to_unicode(params[lang]) link = play_base.on_play_video(players, params, trakt_ids) if link: movie = Movies(tmdb_id).info(language='en') play_base.action_play({ 'label': movie_info['title'], 'path': link, 'info': movie_info, 'is_playable': True, 'info_type': 'video', 'thumbnail': movie_info['poster'], 'poster': movie_info['poster'], 'fanart': movie_info['fanart'] })
def play_movie(tmdb_id): from resources.lib.TheMovieDB import Movies play_plugin = meta_players.ADDON_SELECTOR.id players = meta_players.get_players('movies') players = [p for p in players if p.id == play_plugin] or players if not players or len(players) == 0: xbmc.executebuiltin('Action(Info)') play_base.action_cancel() return movie = Movies(tmdb_id).info( language='en', append_to_response= 'external_ids,alternative_titles,credits,images,keywords,releases,translations,rating' ) movie_info = meta_info.get_movie_metadata(movie) trakt_ids = play_base.get_trakt_ids('tmdb', tmdb_id, movie['original_title'], 'movie', text.parse_year(movie['release_date'])) params = {} for lang in meta_players.get_needed_langs(players): if lang == 'en': tmdb_data = movie else: tmdb_data = Movies(tmdb_id).info( language=lang, append_to_response= 'external_ids,alternative_titles,credits,images,keywords,releases,translations,rating' ) params[lang] = get_movie_parameters(tmdb_data) if trakt_ids != None: params[lang].update(trakt_ids) params[lang]['info'] = movie_info params[lang] = text.to_unicode(params[lang]) link = play_base.on_play_video(players, params, trakt_ids) if link: movie = Movies(tmdb_id).info(language='en') play_base.action_play({ 'label': movie_info['title'], 'path': link, 'info': movie_info, 'is_playable': True, 'info_type': 'video', 'thumbnail': movie_info['poster'], 'poster': movie_info['poster'], 'fanart': movie_info['fanart'] })
def tmdb_play_episode(id, season, episode): from resources.lib.TheMovieDB import TV, TV_Seasons, TV_Episodes tried = 'tvdb' id = int(id) season = int(season) episode = int(episode) dbid = xbmc.getInfoLabel('ListItem.DBID') try: dbid = int(dbid) except: dbid = None show = TV(id).info(language='en', append_to_response='external_ids,images') if 'first_air_date' in show and show['first_air_date'] != None: year = show['first_air_date'][:4] else: year = None trakt_ids = play_base.get_trakt_ids('tmdb', id) if 'status_code' in show: return trakt_play_episode(trakt_ids['trakt'], season, episode) if 'name' in show: title = show['name'] else: title = None show_info = meta_info.get_tvshow_metadata_tmdb(show) title = show_info['name'] preason = TV_Seasons(id, season).info(language='en', append_to_response='external_ids,images') if 'The resource you requested could not be found' in str(preason): return trakt_play_episode(trakt_ids['trakt'], season, episode) season_info = meta_info.get_season_metadata_tmdb(show_info, preason) prepisode = TV_Episodes(id, season, episode).info(language='en', append_to_response='external_ids,images') if prepisode == '{u"status_code": 34, u"status_message": u"The resource you requested could not be found."}': return trakt_play_episode(trakt_ids['tmdb'], season, episode) episode_info = meta_info.get_episode_metadata_tmdb(season_info, prepisode) if show_info['poster'] != None and show_info['poster'] != '': show_poster = show_info['poster'] else: show_poster = '' if show_info['fanart'] != None and show_info['fanart'] != '': show_fanart = show_info['fanart'] else: show_fanart = '' episodes = preason['episodes'] items = [] play_plugin = meta_players.ADDON_SELECTOR.id players = meta_players.get_players('tvshows') players = [p for p in players if p.id == play_plugin] or players if not players: return xbmc.executebuiltin('Action(Info)') trakt_ids = play_base.get_trakt_ids('tmdb', id, show_info['name'], 'show', show['first_air_date'][:4]) params = {} for lang in meta_players.get_needed_langs(players): if show['name'] is None: continue episode_parameters = get_tmdb_episode_parameters(show, preason, prepisode) if episode_parameters is not None: params[lang] = episode_parameters else: if trakt_ids['trakt'] != None and trakt_ids['trakt'] != '': return trakt_play_episode(trakt_ids['trakt'], season, episode) else: msg = 'No TMDb information found for %s - S%sE%s' % (show_info['name'], season, episode) plugin.ok('Episode information not found', msg) if trakt_ids != None: params[lang].update(trakt_ids) params[lang]['info'] = show_info params[lang] = text.to_unicode(params[lang]) link = play_base.on_play_video(players, params, trakt_ids) if link: plugin.setProperty('plugin.video.openmeta.data', json.dumps( { 'dbid': dbid, 'tmdb': id, 'season': season, 'episode': episode })) episode_metadata = meta_info.get_episode_metadata_tmdb(season_info, prepisode) play_base.action_play( { 'label': episode_info['title'], 'path': link, 'info': [], 'is_playable': True, 'info_type': 'video', 'thumbnail': episode_info['poster'], 'poster': episode_info['poster'], 'fanart': str(show_info['fanart']) })
def get_episode_parameters(show, season, episode): from resources.lib.TheMovieDB import Find if season in show and episode in show[season]: season_obj = show[season] episode_obj = show[season][episode] else: return episodes = 0 count = 0 for i in show.items(): episodes += len(i[1].items()) if i[0] != 0 and i[0] < (season -1): count += len(i[1].items()) parameters = {'id': show['id'], 'season': season, 'episode': episode} if season in NTH: parameters['season_ordinal'] = NTH[season] else: try: if text.number_to_text(season) in (season, ''): if int(str(season)[-1]) in NTH: parameters['season_ordinal'] = '%s%s' % (DCS[int(str(season)[-2])], NTH[int(str(season)[-1])]) else: parameters['season_ordinal'] = '%s%sth' % (DCS[int(str(season)[-2])], text.number_to_text(int(str(season)[-1]))) else: parameters['season_ordinal'] = '%sth' % text.number_to_text(season) except: pass parameters['episodes'] = episodes parameters['seasons'] = len(show.items()) parameters['seasons_no_specials'] = len([season_num for (season_num, season) in show.items() if season_num != 0]) show_info = meta_info.get_tvshow_metadata_tvdb(show, banners=True) network = show.get('network', '') parameters['network'] = network if network: parameters['network_clean'] = re.sub('(\(.*?\))', '', network).strip() else: parameters['network_clean'] = network try: parameters['absolute_number'] = int(episode_obj.get('absolute_number')) except: parameters['absolute_number'] = count + episode parameters['showname'] = show['seriesname'].replace('&', '%26') parameters['clearname'] = re.sub('(\(.*?\))', '', show['seriesname']).strip() parameters['stripname'] = ' '.join(re.compile('[\W_]+').sub(' ', show['seriesname']).split()) parameters['sortname'] = text.to_utf8(parameters['clearname']) parameters['urlname'] = urllib.quote(text.to_utf8(parameters['clearname'])) parameters['shortname'] = text.to_utf8(parameters['clearname'][1:-1]) parameters['title'] = text.escape(episode_obj.get('episodename', str(episode))) parameters['urltitle'] = urllib.quote(text.to_utf8(parameters['title'])) parameters['sorttitle'] = text.to_utf8(parameters['title']) parameters['shorttitle'] = text.to_utf8(parameters['title'][1:-1]) articles = ['a ', 'A ', 'An ', 'an ', 'The ', 'the '] for article in articles: if text.to_utf8(parameters['clearname']).startswith(article): parameters['sortname'] = text.to_utf8(parameters['clearname']).replace(article,'') if text.to_utf8(parameters['title']).startswith(article): parameters['sorttitle'] = text.to_utf8(parameters['title']).replace(article,'') parameters['firstaired'] = episode_obj.get('firstaired') parameters['series_firstaired'] = show.get('firstaired') parameters['year'] = show.get('year', 0) if parameters['firstaired']: parameters['epyear'] = int(parameters['firstaired'].split('-')[0].strip()) parameters['epmonth'] = int(parameters['firstaired'].split('-')[1].strip()) parameters['epday'] = int(parameters['firstaired'].split('-')[2].strip()) else: parameters['epyear'] = 1980 parameters['epmonth'] = 0 parameters['epday'] = 0 parameters['imdb'] = show.get('imdb_id', '') parameters['tvrage'] = 0 parameters['epimdb'] = episode_obj.get('imdb_id', '') parameters['eptmdb'] = 0 parameters['eptrakt'] = 0 parameters['eptvrage'] = 0 parameters['epid'] = episode_obj.get('id') if episode_obj.get('id') != '': parameters['plot'] = text.escape(episode_obj.get('overview')) else: parameters['plot'] = text.escape(show['overview']) parameters['series_plot'] = text.escape(show['overview']) if episode_obj.get('rating') not in (None, ''): parameters['rating'] = episode_obj.get('rating') elif show.get('rating') not in (None, ''): parameters['rating'] = show.get('rating') else: parameters['rating'] = 0.0 if show.get('rating') not in (None, ''): parameters['series_rating'] = show.get('rating') else: parameters['series_rating'] = 0 if episode_obj.get('ratingcount') != '': parameters['votes'] = episode_obj.get('ratingcount') else: parameters['votes'] = show['ratingcount'] parameters['mpaa'] = show.get('contentrating') parameters['writers'] = episode_obj.get('writer') parameters['directors'] = episode_obj.get('director') parameters['status'] = show.get('status') if show.get('actors') != None and show.get('actors') != '': parameters['actors'] = re.sub(r'\<[^)].*?\>', '', show.get('actors')) if show.get('genre') != None and '|' in show.get('genre'): parameters['genres'] = show.get('genre').replace('|',' / ')[3:-3] else: parameters['genres'] = show.get('genre') parameters['runtime'] = show['runtime'] parameters['duration'] = int(show['runtime']) * 60 tvdb_base = 'https://thetvdb.com/banners/' if episode_obj.get('filename') != '': parameters['thumbnail'] = tvdb_base + str(episode_obj.get('filename')) elif show.get('poster') != '': parameters['thumbnail'] = show.get('poster') if show.get('poster') != '' and show.get('poster') is not None: parameters['poster'] = show.get('poster') parameters['thumbnail'] = '%sepisodes/%s/%s.jpg' % (tvdb_base, str(show['id']), str(parameters['epid'])) parameters['banner'] = show.get('banner') if show.get('fanart') != None and show.get('fanart') != '': parameters['fanart'] = show.get('fanart') else: parameters['fanart'] = get_background_path() is_anime = False if parameters['genres'] != None and parameters['absolute_number'] and parameters['absolute_number'] != '0' and 'animation' in parameters['genres'].lower(): tmdb_results = Find(show['id']).info(external_source='tvdb_id') for tmdb_show in tmdb_results.get('tv_results', []): if 'JP' in tmdb_show['origin_country']: is_anime = True if is_anime: parameters['name'] = u'%s %s' % (parameters['showname'], parameters['absolute_number']) else: parameters['name'] = u'%s S%02dE%02d' % (parameters['showname'], parameters['season'], parameters['episode']) parameters['now'] = datetime.datetime.now().strftime('%Y%m%d%H%M%S%f') trakt_ids = play_base.get_trakt_ids('tvdb', show['id'], parameters['clearname'], 'show', parameters['year']) if 'slug' in trakt_ids: if trakt_ids['slug'] != '' and trakt_ids['slug'] != None: parameters['slug'] = trakt_ids['slug'] else: parameters['slug'] = text.clean_title(parameters['clearname'].lower()) return parameters
def tvmaze_play_episode(id, season, episode, title=None): title = '' try: id = int(id) except: title = id if title and title != '': url = 'https://api.tvmaze.com/search/shows?q=%s' % id response = urllib.urlopen(url) shows = json.loads(response.read()) if len(shows) > 0: show = shows[0] id = show['show']['id'] url = 'https://api.tvmaze.com/shows/%d?embed[]=seasons&embed[]=episodes' % int(id) response = urllib.urlopen(url) show = json.loads(response.read()) season = int(season) episode = int(episode) dbid = xbmc.getInfoLabel('ListItem.DBID') try: dbid = int(dbid) except: dbid = None if show['externals']: if show['externals']['thetvdb']: trakt_ids = play_base.get_trakt_ids('tvdb', show['externals']['thetvdb'], show['name'], 'show', show['premiered'][:4]) elif show['externals']['imdb']: trakt_ids = play_base.get_trakt_ids('imdb', show['externals']['imdb'], show['name'], 'show', show['premiered'][:4]) else: trakt_ids = play_base.get_trakt_ids(query=show['name'], type='show', year=show['premiered'][:4]) else: trakt_ids = play_base.get_trakt_ids(query=show['name'], type='show', year=show['premiered'][:4]) show_info = meta_info.get_tvshow_metadata_tvmaze(show) preasons = show['_embedded']['seasons'] for item in preasons: if item['number'] == season: preason = item season = preasons.index(item) + 1 elif item['premiereDate'] and item['endDate']: if int(item['premiereDate'][:4]) <= season and int(item['endDate'][:4]) >= season: preason = item season = preasons.index(item) + 1 prepisodes = show['_embedded']['episodes'] for item in prepisodes: if item['number'] == episode: prepisode = item season_info = meta_info.get_season_metadata_tvmaze(show_info, preason) episode_info = meta_info.get_episode_metadata_tvmaze(season_info, prepisode) if show_info['poster'] != None and show_info['poster'] != '': show_poster = show_info['poster'] else: show_poster = '' if show_info['fanart'] != None and show_info['fanart'] != '': show_fanart = show_info['fanart'] else: show_fanart = '' items = [] play_plugin = meta_players.ADDON_SELECTOR.id players = meta_players.get_players('tvshows') players = [p for p in players if p.id == play_plugin] or players if not players: return xbmc.executebuiltin('Action(Info)') params = {} for lang in meta_players.get_needed_langs(players): if show['name'] is None: continue episode_parameters = get_tvmaze_episode_parameters(show, preason, prepisode) if episode_parameters is not None: params[lang] = episode_parameters else: if trakt_ids['tmdb'] != None and trakt_ids['tmdb'] != '' and tried != 'tmdb': tried = 'tmdb' return tvdb_play_episode(trakt_ids['tvdb'], season, episode) elif tried == 'tmdb': msg = 'No TVDb or TMDb information found for %s - S%sE%s' % (show_info['name'], season, episode) plugin.ok('Episode information not found', msg) else: msg = 'No TMDb information found for %s - S%sE%s' % (show_info['name'], season, episode) plugin.ok('Episode information not found', msg) if trakt_ids != None: params[lang].update(trakt_ids) params[lang]['info'] = show_info params[lang] = text.to_unicode(params[lang]) link = play_base.on_play_video(players, params, trakt_ids) if link: plugin.setProperty('plugin.video.openmeta.data', json.dumps( { 'dbid': dbid, 'tvdb': trakt_ids['tvdb'], 'season': season, 'episode': episode })) episode_metadata = meta_info.get_episode_metadata_tvmaze(season_info, prepisode) play_base.action_play( { 'label': episode_info['title'], 'path': link, 'info': [], 'is_playable': True, 'info_type': 'video', 'thumbnail': episode_info['poster'], 'poster': episode_info['poster'], 'fanart': str(show_info['fanart']) })
def trakt_play_episode(id, season, episode): from resources.lib.Trakt import get_show, get_season, get_seasons, get_episode id = int(id) season = int(season) episode = int(episode) show = None preason = None prepisode = None dbid = xbmc.getInfoLabel('ListItem.DBID') try: dbid = int(dbid) except: dbid = None show = get_show(id) if 'name' in show: show_title = show['name'] elif 'title' in show: show_title = show['title'] if show: if show['first_aired']: year = show['first_aired'][:4] else: year = None trakt_ids = play_base.get_trakt_ids('trakt', id, show_title, 'show', year) preason = get_season(id, season) if preason: prepisode = get_episode(id, season, episode) elif not preason and season > 1900: seasons = get_seasons(id) for item in seasons: if item['first_aired'] != None: if int(item['first_aired'][:4]) == season: season_number = item['number'] preason = get_season(id, season_number) if not prepisode or not preason or not show: return tvmaze_play_episode(show_title, season, episode) show_info = meta_info.get_tvshow_metadata_trakt(show) season_info = meta_info.get_season_metadata_trakt(show_info, preason) episode_info = meta_info.get_episode_metadata_trakt(season_info, prepisode) title = show_info['name'] if show_info['poster'] != None and show_info['poster'] != '': show_poster = show_info['poster'] else: show_poster = '' if show_info['fanart'] != None and show_info['fanart'] != '': show_fanart = show_info['fanart'] else: show_fanart = '' items = [] play_plugin = meta_players.ADDON_SELECTOR.id players = meta_players.get_players('tvshows') players = [p for p in players if p.id == play_plugin] or players if not players: return xbmc.executebuiltin('Action(Info)') params = {} for lang in meta_players.get_needed_langs(players): if show['name'] is None: continue episode_parameters = get_trakt_episode_parameters(show, preason, prepisode) if episode_parameters is not None: params[lang] = episode_parameters else: if trakt_ids['tmdb'] != None and trakt_ids['tmdb'] != '' and tried != 'tmdb': tried = 'tmdb' return tvdb_play_episode(trakt_ids['tvdb'], season, episode) elif tried == 'tmdb': msg = 'No TVDb or TMDb information found for %s - S%sE%s' % (show_info['name'], season, episode) plugin.ok('Episode information not found', msg) else: msg = 'No TMDb information found for %s - S%sE%s' % (show_info['name'], season, episode) plugin.ok('Episode information not found', msg) if trakt_ids != None: params[lang].update(trakt_ids) params[lang]['info'] = show_info params[lang] = text.to_unicode(params[lang]) link = play_base.on_play_video(players, params, trakt_ids) if link: plugin.setProperty('plugin.video.openmeta.data', json.dumps( { 'dbid': dbid, 'trakt': id, 'season': season, 'episode': episode })) episode_metadata = meta_info.get_episode_metadata_trakt(season_info, prepisode) play_base.action_play( { 'label': episode_info['title'], 'path': link, 'info': episode_info, 'is_playable': True, 'info_type': 'video', 'thumbnail': episode_info['poster'], 'poster': episode_info['poster'], 'fanart': str(show_info['fanart']) })
def play_episode(id, season, episode): from resources.lib.TheTVDB import TVDB id = int(id) season = int(season) episode = int(episode) dbid = xbmc.getInfoLabel('ListItem.DBID') try: dbid = int(dbid) except: dbid = None show = TVDB[id] show_info = meta_info.get_tvshow_metadata_tvdb(show, banners=False) play_plugin = meta_players.ADDON_SELECTOR.id PLAYERS = meta_players.get_players('tvshows') players = [p for p in PLAYERS if p.id == play_plugin] or PLAYERS if not players or len(players) == 0: xbmc.executebuiltin('Action(Info)') play_base.action_cancel() return trakt_ids = play_base.get_trakt_ids('tvdb', id, show['seriesname'], 'show', show.get('year', 0)) params = {} for lang in meta_players.get_needed_langs(players): tvdb_data = show if tvdb_data['seriesname'] is None: continue episode_parameters = get_episode_parameters(tvdb_data, season, episode) if episode_parameters is not None: params[lang] = episode_parameters else: if trakt_ids['tmdb'] != None and trakt_ids['tmdb'] != '': return tmdb_play_episode(trakt_ids['tmdb'], season, episode) elif trakt_ids['tvdb'] == None or trakt_ids['tvdb'] == '': plugin.ok('Information not found for:', '%s - S%sE%s' % (show_info['name'], season, episode)) else: plugin.ok('Information not found for:', '%s - S%sE%s' % (show_info['name'], season, episode)) if trakt_ids != None: params[lang].update(trakt_ids) params[lang]['info'] = show_info params[lang] = text.to_unicode(params[lang]) link = play_base.on_play_video(players, params, trakt_ids) if link: plugin.setProperty('plugin.video.openmeta.data', json.dumps( { 'dbid': dbid, 'tvdb': id, 'season': season, 'episode': episode })) season_info = meta_info.get_season_metadata_tvdb(show_info, show[season], banners=False) episode_info = meta_info.get_episode_metadata_tvdb(season_info, show[season][episode]) play_base.action_play( { 'label': episode_info['name'], 'path': link, 'info': episode_info, 'is_playable': True, 'info_type': 'video', 'thumbnail': episode_info['poster'], 'poster': episode_info['poster'], 'fanart': episode_info['fanart'] })
def get_movie_parameters(movie): parameters = {} parameters['date'] = movie['release_date'] parameters['premiered'] = movie['release_date'] parameters['year'] = text.parse_year(movie['release_date']) parameters['released'] = movie['release_date'] parameters['id'] = movie['id'] parameters['imdb'] = movie['imdb_id'] parameters['realtitle'] = re.sub('\(\d{4}\)', '', movie['title']).strip() parameters['title'] = text.escape(movie['title']) parameters['striptitle'] = ' '.join(re.compile('[\W_]+').sub(' ', movie['title']).split()) parameters['urltitle'] = urllib.quote(text.to_utf8(parameters['title'])) parameters['sorttitle'] = text.to_utf8(parameters['title']) articles = ['a ', 'A ', 'An ', 'an ', 'The ', 'the '] for article in articles: if text.to_utf8(parameters['title']).startswith(article): parameters['sorttitle'] = text.to_utf8(parameters['title']).replace(article,'') parameters['shorttitle'] = text.to_utf8(parameters['title'][1:-1]) if 'movie' in str(parameters['sorttitle']).lower(): parameters['sortesttitle'] = str(parameters['sorttitle']).lower().replace(' movie', '') elif 'movi' in str(parameters['sorttitle']).lower(): parameters['sortesttitle'] = str(parameters['sorttitle']).lower().replace(' movi', '') else: parameters['sortesttitle'] = parameters['sorttitle'] parameters['original_title'] = text.escape(movie['original_title']) parameters['name'] = u'%s (%s)' % (parameters['title'], parameters['year']) parameters['urlname'] = urllib.quote(text.to_utf8(parameters['name'])) parameters['released'] = movie['release_date'] parameters['rating'] = movie['vote_average'] studios = [x['name'] for x in movie['production_companies'] if not x == ''] parameters['studios'] = ' / '.join(studios) genre = [x['name'] for x in movie['genres'] if not x == ''] parameters['genres'] = ' / '.join(genre) if movie['runtime'] and movie['runtime'] != '' and movie['runtime'] != None: parameters['runtime'] = movie['runtime'] else: parameters['runtime'] = '0' if movie['vote_count'] and movie['vote_count'] != '' and movie['vote_count'] != None and movie['vote_count'] != 0: parameters['votes'] = movie['vote_count'] else: parameters['votes'] = '0' if movie['vote_average'] and movie['vote_average'] != '' and movie['vote_average'] != None and movie['vote_average'] != 0: parameters['rating'] = movie['vote_average'] else: parameters['rating'] = '0' if movie['credits']['crew']: prewriters = [i['name'] for i in movie['credits']['crew'] if i['department'] == 'Writing'] writers = [] for item in prewriters: if item not in writers: writers.append(item) parameters['writers'] = ', '.join(writers) else: parameters['writers'] = '' if movie['credits']['crew']: predirectors = [i['name'] for i in movie['credits']['crew'] if i['department'] == 'Directing'] directors = [] for item in predirectors: if item not in directors: directors.append(item) parameters['directors'] = ', '.join(directors) else: parameters['directors'] = '' if movie['credits']['cast']: preactors = [i['name'] for i in movie['credits']['cast']] actors = [] for item in preactors: if item not in actors: actors.append(item) parameters['actors'] = actors else: parameters['actors'] = '' if movie['releases']['countries'][0]['certification']: parameters['mpaa'] = movie['releases']['countries'][0]['certification'] else: parameters['mpaa'] = '' parameters['duration'] = int(parameters['runtime']) * 60 parameters['plot'] = text.escape(movie['overview']) parameters['tagline'] = text.escape(movie['tagline']) if 'https://image.tmdb.org/t/p/w300%s' % str(movie['poster_path']): parameters['poster'] = 'https://image.tmdb.org/t/p/w300%s' % str(movie['poster_path']) else: parameters['poster'] = 'https://image.tmdb.org/t/p/original%s' % str(movie['poster_path']) if 'https://image.tmdb.org/t/p/w1280%s' % str(movie['backdrop_path']): parameters['fanart'] = 'https://image.tmdb.org/t/p/w1280%s' % str(movie['backdrop_path']) else: parameters['fanart'] = 'https://image.tmdb.org/t/p/original%s' % str(movie['backdrop_path']) parameters['now'] = datetime.datetime.now().strftime('%Y%m%d%H%M%S%f') trakt_ids = play_base.get_trakt_ids(id_type='tmdb', id=movie['id'], type='movie') if 'slug' in trakt_ids and trakt_ids['slug'] != '' and trakt_ids['slug'] != None: try: parameters['slug'] = trakt_ids['slug'] except: pass else: parameters['slug'] = text.clean_title(parameters['title'].lower()) return parameters