def extras_menu(params): function = metadata.movie_meta if params[ 'db_type'] == 'movie' else metadata.tvshow_meta meta_user_info = metadata.retrieve_user_info() meta = function('tmdb_id', params['tmdb_id'], meta_user_info) open_window(['windows.extras', 'Extras'], 'extras.xml', meta=meta, is_widget=params.get('is_widget', 'false'), is_home=params.get('is_home', 'false'))
def imdb_keywords_choice(db_type, imdb_id, poster): from apis.imdb_api import imdb_keywords def _builder(): for item in keywords_info: obj = { 'line': item, 'function': json.dumps({ 'mode': mode, 'action': 'imdb_keywords_list_contents', 'list_id': item, 'iconImage': 'imdb.png' }) } yield obj kodi_utils.show_busy_dialog() keywords_info = imdb_keywords(imdb_id) if len(keywords_info) == 0: kodi_utils.hide_busy_dialog() kodi_utils.notification(32760, 2500) return None meta_type = 'movie' if db_type == 'movies' else 'tvshow' mode = 'build_%s_list' % meta_type items = list(_builder()) kodi_utils.hide_busy_dialog() return open_window(['windows.extras', 'ShowSelectMedia'], 'select_media.xml', items=items, poster=poster, context_active_action='keywords')
def genres_choice(db_type, genres, poster, return_genres=False): from modules.meta_lists import movie_genres, tvshow_genres def _process_dicts(genre_str, _dict): final_genres_list = [] append = final_genres_list.append for key, value in _dict.items(): if key in genre_str: append({'genre': key, 'value': value}) return final_genres_list if db_type in ('movie', 'movies'): genre_action, meta_type, action = movie_genres, 'movie', 'tmdb_movies_genres' else: genre_action, meta_type, action = tvshow_genres, 'tvshow', 'tmdb_tv_genres' genre_list = _process_dicts(genres, genre_action) if return_genres: return genre_list if len(genre_list) == 0: kodi_utils.notification(32760, 2500) return None mode = 'build_%s_list' % meta_type items = [{ 'line': item['genre'], 'function': json.dumps({ 'mode': mode, 'action': action, 'genre_id': item['value'][0] }) } for item in genre_list] return open_window(['windows.extras', 'ShowSelectMedia'], 'select_media.xml', items=items, poster=poster)
def imdb_videos_choice(videos, poster, media=True): try: videos = json.loads(videos) except: pass videos.sort(key=lambda x: x['quality_rank']) if media: items = [{'line': i['quality'], 'function': i['url']} for i in videos] choice = open_window(['windows.extras', 'ShowSelectMedia'], 'select_media.xml', items=items, poster=poster) else: dl = [i['quality'] for i in videos] fl = [i['url'] for i in videos] list_items = [{'line1': item, 'icon': poster} for item in dl] kwargs = { 'items': json.dumps(list_items), 'heading': 'Fen', 'enumerate': 'false', 'multi_choice': 'false', 'multi_line': 'false' } choice = kodi_utils.select_dialog(fl, **kwargs) return choice
def select_dialog(function_list, **kwargs): from windows import open_window selection = open_window(('windows.select_ok', 'Select'), 'select.xml', **kwargs) if selection in ([], None): return None if kwargs.get('multi_choice', 'false') == 'true': return [function_list[i] for i in selection] return function_list[selection]
def _continue_action(): if run_popup: action = open_window(('windows.next_episode', 'NextEpisode'), 'next_episode.xml', meta=nextep_meta, function='next_ep') else: action = 'close' return action
def show_text(heading, text=None, file=None, font_size='small'): from windows import open_window if isinstance(heading, int): heading = local_string(heading) if file: with open(file, encoding='utf-8') as r: text = r.read() return open_window(['windows.textviewer', 'TextViewer'], 'textviewer.xml', heading=heading, text=text, font_size=font_size)
def ok_dialog(heading='Fen', text='', highlight='royalblue', ok_label=local_string(32839), top_space=False): from windows import open_window if isinstance(heading, int): heading = local_string(heading) if isinstance(text, int): text = local_string(text) if not text: text = '[CR][CR]%s' % local_string(32760) elif top_space: text = '[CR][CR]%s' % text kwargs = { 'heading': heading, 'text': text, 'highlight': highlight, 'ok_label': ok_label } return open_window(('windows.select_ok', 'OK'), 'ok.xml', **kwargs)
def display_results(self, results): window_style = settings.results_xml_style() action, chosen_item = open_window( ('windows.sources', 'SourceResults'), 'sources_results.xml', window_style=window_style, window_id=settings.results_xml_window_number(window_style), results=results, meta=self.meta, scraper_settings=self.scraper_settings, prescrape=self.prescrape, filters_ignored=self.filters_ignored) if not action and self.prescrape: self._kill_progress_dialog() if action == 'play': if self.prescrape: self._kill_progress_dialog() return self.play_file(results, chosen_item) elif self.prescrape and action == 'perform_full_search': self.prescrape = False return self.playback_prep()
def scrape_with_custom_values(db_type, meta, season=None, episode=None): from windows import open_window from modules.sources import Sources ls = kodi_utils.local_string if db_type == 'movie': play_params = { 'mode': 'play_media', 'vid_type': 'movie', 'tmdb_id': meta['tmdb_id'], 'prescrape': 'false' } else: play_params = { 'mode': 'play_media', 'vid_type': 'episode', 'tmdb_id': meta['tmdb_id'], 'tvshowtitle': meta['rootname'], 'season': season, 'episode': episode, 'prescrape': 'false' } custom_title = kodi_utils.dialog.input(ls(32228), defaultt=meta['title']) if not custom_title: return play_params['custom_title'] = custom_title if db_type in ('movie', 'movies'): custom_year = kodi_utils.dialog.input('%s (%s)' % (ls(32543), ls(32669)), type=kodi_utils.numeric_input, defaultt=str(meta['year'])) if custom_year: play_params['custom_year'] = int(custom_year) choice = open_window( ('windows.yes_no_progress_media', 'YesNoProgressMedia'), 'yes_no_progress_media.xml', meta=meta, enable_buttons='playmode_status', resume_dialog='%s?' % ls(32006), percent=0) if choice == True: play_params['disabled_ignored'] = 'true' elif choice == None: return Sources().playback_prep(play_params)
def playback_choice(content, poster, meta): items = [{ 'line': ls(32014), 'function': 'clear_and_rescrape' }, { 'line': ls(32006), 'function': 'rescrape_with_disabled' }, { 'line': ls(32135), 'function': 'scrape_with_custom_values' }] choice = open_window(['windows.extras', 'ShowSelectMedia'], 'select_media.xml', items=items, poster=poster) if choice == None: return from modules.source_utils import clear_and_rescrape, rescrape_with_disabled, scrape_with_custom_values if choice == 'clear_and_rescrape': clear_and_rescrape(content, meta) elif choice == 'rescrape_with_disabled': rescrape_with_disabled(content, meta) else: scrape_with_custom_values(content, meta)
def confirm_dialog(heading='Fen', text='', highlight='royalblue', ok_label=local_string(32839), cancel_label=local_string(32840), top_space=False, default_control=11): from windows import open_window if isinstance(heading, int): heading = local_string(heading) if isinstance(text, int): text = local_string(text) if isinstance(ok_label, int): ok_label = local_string(ok_label) if isinstance(cancel_label, int): cancel_label = local_string(cancel_label) if not text: text = '[CR][CR]%s' % local_string(32580) elif top_space: text = '[CR][CR]%s' % text kwargs = { 'heading': heading, 'text': text, 'highlight': highlight, 'ok_label': ok_label, 'cancel_label': cancel_label, 'default_control': default_control } return open_window(('windows.select_ok', 'YesNo'), 'yesno.xml', **kwargs)
def _confirm_threshold(): nextep_threshold = nextep_settings['threshold'] if nextep_threshold == 0: return True try: current_number = int( kodi_utils.get_property('fen_total_autoplays')) except: current_number = 1 if current_number == nextep_threshold: current_number = 1 kodi_utils.set_property('fen_total_autoplays', str(current_number)) if open_window(('windows.next_episode', 'NextEpisode'), 'next_episode.xml', meta=nextep_meta, function='confirm'): return True else: kodi_utils.notification(32736, 1500) return False else: current_number += 1 kodi_utils.set_property('fen_total_autoplays', str(current_number)) return True
def trailer_choice(db_type, poster, tmdb_id, trailer_url, all_trailers=[]): if settings.get_language( ) != 'en' and not trailer_url and not all_trailers: from apis.tmdb_api import tmdb_media_videos try: all_trailers = tmdb_media_videos(db_type, tmdb_id)['results'] except: pass if all_trailers: from modules.utils import clean_file_name, to_utf8 if len(all_trailers) == 1: video_id = all_trailers[0].get('key') else: items = [{ 'line': clean_file_name(i['name']), 'function': i['key'] } for i in all_trailers] video_id = open_window(['windows.extras', 'ShowSelectMedia'], 'select_media.xml', items=items, poster=poster) if video_id == None: return 'canceled' trailer_url = 'plugin://plugin.video.youtube/play/?video_id=%s' % video_id return trailer_url
def open_window_xml(self): open_window(('windows.imageviewer', 'ThumbImageViewer'), 'thumbviewer.xml', list_items=self.list_items, next_page_params=self.next_page_params, ImagesInstance=self)
def slideshow_image(self): return open_window(('windows.imageviewer', 'SlideShow'), 'slideshow.xml', all_images=json.loads(self.params['all_images']), index=int(self.params['current_index']))
def results_layout_choice(): screenshots_directory = 'special://home/addons/script.tikiart/resources/screenshots/results/%s' xml_choices = [ ('List Default', kodi_utils.translate_path(screenshots_directory % 'source_results_list.default.jpg')), ('List Contrast Default', kodi_utils.translate_path( screenshots_directory % 'source_results_list.contrast.default.jpg')), ('List Details', kodi_utils.translate_path(screenshots_directory % 'source_results_list.details.jpg')), ('List Contrast Details', kodi_utils.translate_path( screenshots_directory % 'source_results_list.contrast.details.jpg')), ('InfoList Default', kodi_utils.translate_path(screenshots_directory % 'source_results_infolist.default.jpg')), ('InfoList Contrast Default', kodi_utils.translate_path( screenshots_directory % 'source_results_infolist.contrast.default.jpg')), ('InfoList Details', kodi_utils.translate_path(screenshots_directory % 'source_results_infolist.details.jpg')), ('InfoList Contrast Details', kodi_utils.translate_path( screenshots_directory % 'source_results_infolist.contrast.details.jpg')), ('Rows Default', kodi_utils.translate_path(screenshots_directory % 'source_results_rows.default.jpg')), ('Rows Contrast Default', kodi_utils.translate_path( screenshots_directory % 'source_results_rows.contrast.default.jpg')), ('Rows Details', kodi_utils.translate_path(screenshots_directory % 'source_results_rows.details.jpg')), ('Rows Contrast Details', kodi_utils.translate_path( screenshots_directory % 'source_results_rows.contrast.details.jpg')), ('Shift Default', kodi_utils.translate_path(screenshots_directory % 'source_results_shift.default.jpg')), ('Shift Contrast Default', kodi_utils.translate_path( screenshots_directory % 'source_results_shift.contrast.default.jpg')), ('Shift Details', kodi_utils.translate_path(screenshots_directory % 'source_results_shift.details.jpg')), ('Shift Contrast Details', kodi_utils.translate_path( screenshots_directory % 'source_results_shift.contrast.details.jpg')), ('Thumb Default', kodi_utils.translate_path(screenshots_directory % 'source_results_thumb.default.jpg')), ('Thumb Contrast Default', kodi_utils.translate_path( screenshots_directory % 'source_results_thumb.contrast.default.jpg')), ('Thumb Details', kodi_utils.translate_path(screenshots_directory % 'source_results_thumb.details.jpg')), ('Thumb Contrast Details', kodi_utils.translate_path( screenshots_directory % 'source_results_thumb.contrast.details.jpg')) ] choice = open_window(['windows.sources', 'SourceResultsChooser'], 'sources_chooser.xml', xml_choices=xml_choices) if choice: set_setting('results.xml_style', choice)
def person_data_dialog(params): if 'query' in params: query = unquote(params['query']) else: query = None open_window(['windows.people', 'People'], 'people.xml', query=params.get('query', None), actor_name=params.get('actor_name'), actor_image=params.get('actor_image'), actor_id=params.get('actor_id'))
def extras_lists_choice(): screenshots_directory = 'special://home/addons/script.tikiart/resources/screenshots/extras/%s' fl = [ 2051, 2052, 2053, 2054, 2055, 2056, 2057, 2058, 2059, 2060, 2061, 2062 ] dl = [{ 'name': ls(32503), 'image': kodi_utils.translate_path(screenshots_directory % '001_recommended.jpg') }, { 'name': ls(32607), 'image': kodi_utils.translate_path(screenshots_directory % '002_reviews.jpg') }, { 'name': ls(32984), 'image': kodi_utils.translate_path(screenshots_directory % '003_trivia.jpg') }, { 'name': ls(32986), 'image': kodi_utils.translate_path(screenshots_directory % '004_blunders.jpg') }, { 'name': ls(32989), 'image': kodi_utils.translate_path(screenshots_directory % '005_parentalguide.jpg') }, { 'name': ls(33032), 'image': kodi_utils.translate_path(screenshots_directory % '006_videos.jpg') }, { 'name': ls(32616), 'image': kodi_utils.translate_path(screenshots_directory % '007_posters.jpg') }, { 'name': ls(32617), 'image': kodi_utils.translate_path(screenshots_directory % '008_fanart.jpg') }, { 'name': '%s %s' % (ls(32612), ls(32543)), 'image': kodi_utils.translate_path(screenshots_directory % '009_morefromyear.jpg') }, { 'name': '%s %s' % (ls(32612), ls(32470)), 'image': kodi_utils.translate_path(screenshots_directory % '010_morefromgenres.jpg') }, { 'name': '%s %s' % (ls(32612), ls(32480)), 'image': kodi_utils.translate_path(screenshots_directory % '011_morefromnetwork.jpg') }, { 'name': '%s %s' % (ls(32612), ls(32499)), 'image': kodi_utils.translate_path(screenshots_directory % '012_collection.jpg') }] try: preselect = [fl.index(i) for i in settings.extras_enabled_lists()] except: preselect = [] kwargs = {'items': json.dumps(dl), 'preselect': preselect} selection = open_window(('windows.extras', 'ExtrasChooser'), 'extras_chooser.xml', **kwargs) if selection == []: return set_setting('extras.enabled_lists', 'noop') elif selection == None: return selection = [str(fl[i]) for i in selection] set_setting('extras.enabled_lists', ','.join(selection))