def internal_scrapers_order_choice(): import xbmcgui from modules.nav_utils import toggle_setting window = xbmcgui.Window(10000) try: current_ordering = window.getProperty('FEN_internal_scrapers_order').split(', ') except: current_ordering = [''] if len(current_ordering) != 4: from modules.settings import internal_scraper_order current_ordering = internal_scraper_order() default = [('FILES', current_ordering.index("FILES")), ('FURK', current_ordering.index("FURK")), ('EASYNEWS', current_ordering.index("EASYNEWS")), ('CLOUD', current_ordering.index("CLOUD"))] choices = sorted(default, key=lambda x: x[1]) adjust_scraper = selection_dialog([i[0] for i in choices], [i[0] for i in choices], 'Fen - Choose Scraper to Change Order') if not adjust_scraper: return window.clearProperty('FEN_internal_scrapers_order') choices = [('Place [B]%s[/B] 1st' % adjust_scraper, (0, current_ordering.index(adjust_scraper))), ('Place [B]%s[/B] 2nd' % adjust_scraper, (1, current_ordering.index(adjust_scraper))), ('Place [B]%s[/B] 3rd' % adjust_scraper, (2, current_ordering.index(adjust_scraper))), ('Place [B]%s[/B] 4th' % adjust_scraper, (3, current_ordering.index(adjust_scraper)))] positioning_info = selection_dialog([i[0] for i in choices], [i[1] for i in choices], 'Fen - Choose %s Scraper Position' % adjust_scraper) if not positioning_info: return internal_scrapers_order_choice() new_position = positioning_info[0] current_position = positioning_info[1] current_ordering.insert(new_position, current_ordering.pop(current_position)) new_order_setting = (', ').join(current_ordering) window.setProperty('FEN_internal_scrapers_order', new_order_setting) toggle_setting('internal_scrapers_order', new_order_setting) return internal_scrapers_order_choice()
def toggle_jump_to(): from modules.nav_utils import toggle_setting, notification from modules.settings import nav_jump_use_alphabet use_alphabet = nav_jump_use_alphabet() (setting, new_action) = ('0', 'PAGE') if use_alphabet == True else ('1', 'ALPHABET') toggle_setting(setting_id='nav_jump', setting_value=setting, refresh=True) notification('Jump To Action Switched to [B]%s[/B]' % new_action)
def switch_settings(): from modules.nav_utils import toggle_setting, settings_layout choices = ('Basic', 'Advanced (Multiple Submenus)') choice = selection_dialog(choices, choices, 'Fen - Choose Settings Layout') if choice: toggle_setting('settings_layout', choice) settings_layout(choice)
def scraper_quality_color_choice(): try: from urlparse import parse_qsl except ImportError: from urllib.parse import parse_qsl from modules.nav_utils import toggle_setting params = dict(parse_qsl(sys.argv[2].replace('?',''))) setting = params['setting'] dialog = 'Please Choose Color for Scraper Quality Highlight' chosen_color = color_chooser(dialog) if chosen_color: toggle_setting(setting, chosen_color)
def scraper_dialog_color_choice(): try: from urlparse import parse_qsl except ImportError: from urllib.parse import parse_qsl from modules.nav_utils import toggle_setting params = dict(parse_qsl(sys.argv[2].replace('?',''))) setting ='int_dialog_highlight' if params['setting'] == 'internal' else 'ext_dialog_highlight' dialog = 'Please Choose Color for Internal Scrapers Progress Dialog Highlight' chosen_color = color_chooser(dialog) if chosen_color: toggle_setting(setting, chosen_color)
def set_autoplay_hevc(): from modules.settings import active_scrapers from modules.nav_utils import toggle_setting options = ['Include', 'Exclude', 'Prefer'] options_choice = selection_dialog(options, options, 'Choose HEVC Autoplay Setting') if options_choice < 0: return return toggle_setting('autoplay_hevc', options_choice)
def set_display_mode(): test = "Directory|Very Simple Directory|Dialog" from modules.nav_utils import toggle_setting names = ('Directory', 'Very Simple Directory', 'Dialog') settings = ('0', '1', '2') choice = selection_dialog(names, settings, 'Fen - Choose Display Mode') if choice: return toggle_setting('display_mode', choice)
def set_quality(quality_setting=None): try: from urlparse import parse_qsl except ImportError: from urllib.parse import parse_qsl params = dict(parse_qsl(sys.argv[2].replace('?',''))) quality_setting = quality_setting if quality_setting else params['quality_setting'] string = 'Please Choose Autoplay Filters' if quality_setting == 'autoplay' else 'Please Choose Result Filters:' setting = 'autoplay_quality' if quality_setting == 'autoplay' else 'results_quality' dl = ['Include SD', 'Include 720p', 'Include 1080p', 'Include 4K'] fl = ['SD', '720p', '1080p', '4K'] try: preselect = [fl.index(i) for i in __addon__.getSetting(setting).split(', ')] except: preselect = [] filters = multiselect_dialog(string, dl, fl, preselect) if filters is None: return if filters == []: import xbmcgui xbmcgui.Dialog().ok('FEN Filters', 'You must select at least 1 Filter Setting.', '', 'Please Retry.....') return set_quality(quality_setting) from modules.nav_utils import toggle_setting toggle_setting(setting, ', '.join(filters))
def scraper_color_choice(): try: from urlparse import parse_qsl except ImportError: from urllib.parse import parse_qsl from modules.nav_utils import toggle_setting params = dict(parse_qsl(sys.argv[2].replace('?',''))) choices = [('furk', 'provider.furk_colour'), ('easynews', 'provider.easynews_colour'), ('pm-cloud', 'provider.pm-cloud_colour'), ('rd-cloud', 'provider.rd-cloud_colour'), ('ad-cloud', 'provider.ad-cloud_colour'), ('local', 'provider.local_colour'), ('downloads', 'provider.downloads_colour'), ('folders', 'provider.folders_colour'), ('premium', 'prem.identify'), ('torrent', 'torrent.identify'), ('second_line', 'secondline.identify')] title, setting = [(i[0], i[1]) for i in choices if i[0] == params.get('setting')][0] dialog = 'Please Choose Color for %s Results Highlight' % title.upper() chosen_color = color_chooser(dialog, no_color=True) if chosen_color: toggle_setting(setting, chosen_color)
def enable_scrapers(): from modules.settings import active_scrapers from modules.nav_utils import toggle_setting scrapers = ['external', 'furk', 'easynews', 'pm-cloud', 'rd-cloud', 'ad-cloud', 'local', 'downloads', 'folder1', 'folder2', 'folder3', 'folder4', 'folder5'] preselect = [scrapers.index(i) for i in active_scrapers()] scrapers_dialog = ['%s (%s)' % (x, __addon__.getSetting('folder1.display_name')) if x=='folder1' else x for x in scrapers] scrapers_dialog = ['%s (%s)' % (x, __addon__.getSetting('folder2.display_name')) if x=='folder2' else x for x in scrapers_dialog] scrapers_dialog = ['%s (%s)' % (x, __addon__.getSetting('folder3.display_name')) if x=='folder3' else x for x in scrapers_dialog] scrapers_dialog = ['%s (%s)' % (x, __addon__.getSetting('folder4.display_name')) if x=='folder4' else x for x in scrapers_dialog] scrapers_dialog = ['%s (%s)' % (x, __addon__.getSetting('folder5.display_name')) if x=='folder5' else x for x in scrapers_dialog] scrapers_dialog = [i.upper() for i in scrapers_dialog] scraper_choice = multiselect_dialog('Choose Fen Scrapers', scrapers_dialog, scrapers, preselect=preselect) if scraper_choice is None: return return [toggle_setting('provider.%s' % i, ('true' if i in scraper_choice else 'false')) for i in scrapers]
def subscriptions_update_interval(): try: from urlparse import parse_qsl except ImportError: from urllib.parse import parse_qsl from modules.nav_utils import toggle_setting import time from datetime import datetime, timedelta from modules.nav_utils import open_settings params = dict(parse_qsl(sys.argv[2].replace('?',''))) subscription_timer = __addon__.getSetting('subscription_timer') if params['update_type'] == 'interval': subscriptions_update_label = 'subscriptions_update_label1' intervals = [('1 Hour', 1), ('2 Hours', 2), ('4 Hours', 4), ('8 Hours', 8), ('12 Hours', 12), ('16 Hours', 16), ('24 Hours', 24)] try: last_run_time = datetime.strptime(__addon__.getSetting('service_time'), "%Y-%m-%d %H:%M:%S") - timedelta(hours=int(subscription_timer)) except TypeError: last_run_time = datetime(*(time.strptime(__addon__.getSetting('service_time'), "%Y-%m-%d %H:%M:%S")[0:6])) - timedelta(hours=int(subscription_timer)) choice = selection_dialog([i[0] for i in intervals], intervals, 'Fen - Choose Subscription Update Interval') if not choice: choice = ('24 Hours', 24) interval = str(choice[1]) interval_display = choice[0] new_run_time = last_run_time + timedelta(hours=int(interval)) new_run_time = new_run_time.strftime("%Y-%m-%d %H:%M:%S") else: subscriptions_update_label = 'subscriptions_update_label2' intervals = [] for i in range(24): intervals.append(('%02d:00' % i, i)) choice = selection_dialog([i[0] for i in intervals], intervals, 'Fen - Choose Daily Subscription Update Time') if not choice: choice = ('06:00', 6) sub_hour = choice[1] interval_display = choice[0] interval = subscription_timer now = datetime.today() sub_day = now.day + 1 if sub_hour == 0 else now.day new_run_time = now.replace(day=sub_day, hour=sub_hour, minute=0, second=0, microsecond=0) + timedelta(days=1) difference = new_run_time - now if '1 day' in str(difference): new_run_time = now.replace(day=sub_day, hour=sub_hour, minute=0, second=0, microsecond=0) new_run_time = new_run_time.strftime("%Y-%m-%d %H:%M:%S") toggle_setting('subscription_timer', interval) toggle_setting(subscriptions_update_label, interval_display) toggle_setting('service_time', new_run_time) return open_settings('8.7')
def next_episode_context_choice(): from modules.utils import selection_dialog from modules.nav_utils import toggle_setting, build_url params = dict(parse_qsl(sys.argv[2].replace('?', ''))) content_settings = settings.nextep_content_settings() display_settings = settings.nextep_display_settings() airdate_replacement = [('%d-%m-%Y', 'Day-Month-Year'), ('%Y-%m-%d', 'Year-Month-Day'), ('%m-%d-%Y', 'Month-Day-Year')] sort_type_status = ('Recently Watched', 'Airdate', 'Title')[content_settings['sort_type']] sort_order_status = ('Descending', 'Ascending')[content_settings['sort_order']] toggle_sort_order_SETTING = ('nextep.sort_order', ('0' if sort_order_status == 'Ascending' else '1')) cache_to_disk_status = str(content_settings['cache_to_disk']) toggle_cache_to_disk_SETTING = ('nextep.cache_to_disk', ('true' if cache_to_disk_status == 'False' else 'false')) unaired_status = str(content_settings['include_unaired']) toggle_unaired_SETTING = ('nextep.include_unaired', ('true' if unaired_status == 'False' else 'false')) unwatched_status = str(content_settings['include_unwatched']) toggle_unwatched_SETTING = ('nextep.include_unwatched', ('true' if unwatched_status == 'False' else 'false')) airdate_status = str(display_settings['include_airdate']) toggle_airdate_SETTING = ('nextep.include_airdate', ('true' if airdate_status == 'False' else 'false')) airdate_format = settings.nextep_airdate_format() airdate_format_status = [ airdate_format.replace(i[0], i[1]) for i in airdate_replacement if i[0] == airdate_format ][0] airdate_highlight = display_settings['airdate_colour'].capitalize() unaired_highlight = display_settings['unaired_colour'].capitalize() unwatched_highlight = display_settings['unwatched_colour'].capitalize() choices = [ ('MANAGE IN PROGRESS SHOWS', 'manage_in_progress'), ('SORT TYPE: [I]Currently [B]%s[/B][/I]' % sort_type_status, 'Sort Type'), ('SORT ORDER: [I]Currently [B]%s[/B][/I]' % sort_order_status, 'toggle_cache_to_disk'), ('CACHE TO DISK: [I]Currently [B]%s[/B][/I]' % cache_to_disk_status, 'toggle_cache_to_disk'), ('INCLUDE UNAIRED EPISODES: [I]Currently [B]%s[/B][/I]' % unaired_status, 'toggle_unaired'), ('INCLUDE WATCHLIST/UNWATCHED TV: [I]Currently [B]%s[/B][/I]' % unwatched_status, 'toggle_unwatched'), ('INCLUDE AIRDATE: [I]Currently [B]%s[/B][/I]' % airdate_status, 'toggle_airdate'), ('AIRDATE FORMAT: [I]Currently [B]%s[/B][/I]' % airdate_format_status, 'Airdate Format'), ('AIRDATE HIGHLIGHT: [I]Currently [B]%s[/B][/I]' % airdate_highlight, 'Airdate'), ('UNAIRED HIGHLIGHT: [I]Currently [B]%s[/B][/I]' % unaired_highlight, 'Unaired'), ('UNWATCHED HIGHLIGHT: [I]Currently [B]%s[/B][/I]' % unwatched_highlight, 'Unwatched') ] if settings.watched_indicators() == 0: choices.append(('MANAGE UNWATCHED TV SHOWS', 'manage_unwatched')) if settings.watched_indicators() in (1, 2): choices.append(('CLEAR TRAKT CACHE', 'clear_cache')) string = 'Next Episode Manager' dialog_list = [i[0] for i in choices] function_list = [i[1] for i in choices] choice = selection_dialog(dialog_list, function_list, string) if not choice: return if choice in ('toggle_sort_order', 'toggle_cache_to_disk', 'toggle_unaired', 'toggle_unwatched', 'toggle_airdate'): setting = eval(choice + '_SETTING') toggle_setting(setting[0], setting[1]) elif choice == 'clear_cache': from modules.nav_utils import clear_cache clear_cache('trakt') else: if choice in ('manage_in_progress', 'manage_unwatched'): xbmc.executebuiltin('Container.Update(%s)' % build_url({ 'mode': 'build_next_episode_manager', 'action': choice })) return elif choice in ('Airdate', 'Unaired', 'Unwatched'): function = next_episode_color_choice else: function = next_episode_options_choice function(choice) xbmc.executebuiltin("Container.Refresh") xbmc.executebuiltin('RunPlugin(%s)' % build_url({'mode': 'next_episode_context_choice'}))
if mode == 'external_scrapers_disable': from modules.external_source_utils import external_scrapers_disable external_scrapers_disable() elif mode == 'external_scrapers_reset_stats': from modules.external_source_utils import external_scrapers_reset_stats external_scrapers_reset_stats() elif mode == 'external_scrapers_toggle_all': from modules.external_source_utils import toggle_all toggle_all(params.get('folder'), params.get('setting')) elif mode == 'external_scrapers_enable_disable_specific_all': from modules.external_source_utils import enable_disable_specific_all enable_disable_specific_all(params.get('folder')) elif 'toggle' in mode: if mode == 'toggle_setting': from modules.nav_utils import toggle_setting toggle_setting() elif mode == 'toggle_jump_to': from modules.utils import toggle_jump_to toggle_jump_to() elif mode == 'toggle_provider': from modules.utils import toggle_provider toggle_provider() elif 'history' in mode: if mode == 'search_history': from modules.history import search_history search_history() elif mode == 'clear_search_history': from modules.history import clear_search_history clear_search_history() elif mode == 'remove_from_history': from modules.history import remove_from_history
def playback_menu(from_results=False, suggestion=None, list_name=None, play_params=None): try: from urlparse import parse_qsl except ImportError: from urllib.parse import parse_qsl from modules.nav_utils import toggle_setting, build_url, open_settings, clear_cache, cached_page_clear, clear_and_rescrape from modules import settings params = dict(parse_qsl(sys.argv[2].replace('?',''))) content = xbmc.getInfoLabel('Container.Content') if not content: content = params.get('content', None) from_results = params.get('from_results', from_results) suggestion = params.get('suggestion', suggestion) list_name = params.get('list_name', list_name) play_params = params.get('play_params', play_params) autoplay_status, autoplay_toggle, filter_setting = ('On', 'false', 'autoplay_quality') if settings.auto_play() else ('Off', 'true', 'results_quality') quality_filter_setting = 'autoplay' if autoplay_status == 'On' else 'results' autoplay_next_status, autoplay_next_toggle = ('On', 'false') if settings.autoplay_next_episode() else ('Off', 'true') display_mode = settings.display_mode() display_mode_status = 'Directory' if display_mode == 0 else 'Very Simple Directory' if display_mode == 1 else 'Dialog' autoplay_hevc_status = settings.autoplay_hevc() current_subs_action_status = __addon__.getSetting('subtitles.subs_action') active_scrapers = [i.replace('-', '').replace('folder', 'f') for i in settings.active_scrapers()] current_scrapers_status = ', '.join([i.upper()[:3] for i in active_scrapers]) if len(active_scrapers) > 0 else 'NONE' current_filter_status = ', '.join(settings.quality_filter(filter_setting)) indicators_status, indicators_toggle = ('Trakt', '0') if settings.watched_indicators() in (1, 2) else ('Fen', '1') cached_torrents_status, cached_torrents_toggle = ('On', 'false') if __addon__.getSetting('torrent.check.cache') =='true' else ('Off', 'true') uncached_torrents_status, uncached_torrents_toggle = ('On', 'false') if __addon__.getSetting('torrent.display.uncached') =='true' else ('Off', 'true') active_cloud_store = settings.active_store_torrent_to_cloud() active_cloud_store_status = ', '.join([i[1] for i in active_cloud_store]) if len(active_cloud_store) > 0 else 'NONE' furk_easy_suggestion = params.get('suggestion', '') listing = [] if play_params: listing += [('RESCRAPE & SELECT SOURCE', 'rescrape_select')] listing += [('AUTOPLAY: [I]Currently [B]%s[/B][/I]' % autoplay_status, 'toggle_autoplay')] if autoplay_status == 'On': listing += [('HEVC AUTOPLAY FILTER: [I]Currently [B]%s[/B][/I]' % autoplay_hevc_status, 'set_autoplay_hevc')] listing += [('AUTOPLAY NEXT EPISODE: [I]Currently [B]%s[/B][/I]' % autoplay_next_status, 'toggle_autoplay_next')] listing += [('ENABLE SCRAPERS: [I]Currently [B]%s[/B][/I]' % current_scrapers_status, 'enable_scrapers')] if autoplay_status == 'Off': listing += [('DISPLAY MODE: [I]Currently [B]%s[/B][/I]' % display_mode_status, 'set_display_mode')] listing += [('QUALITY FILTERS: [I]Currently [B]%s[/B][/I]' % current_filter_status, 'set_filters')] listing += [('DOWNLOAD SUBTITLES: [I]Currently [B]%s[/B][/I]' % current_subs_action_status, 'set_subs_action')] if settings.cache_page(): listing += [('CLEAR RESUME BROWSING PAGE', 'clear_cache_page')] listing += [('SWITCH INDICATOR PROVIDER: [I]Currently [B]%s[/B][/I]' % indicators_status, 'toggle_indicators')] if 'external' in active_scrapers: listing += [('CHECK FOR CACHED TORRENTS: [I]Currently [B]%s[/B][/I]' % cached_torrents_status, 'toggle_cached_torrents')] if cached_torrents_status == 'On': listing += [(' - SHOW UNCACHED TORRENTS: [I]Currently [B]%s[/B][/I]' % uncached_torrents_status, 'toggle_torrents_display_uncached')] listing += [(' - ADD TORRENTS TO CLOUD: [I]Currently [B]%s[/B][/I]' % active_cloud_store_status, 'set_active_cloud_store')] if content in ('movies', 'episodes', 'movie', 'episode'): listing += [('FURK/EASYNEWS SEARCH: [B][I]%s[/I][/B]' % furk_easy_suggestion, 'search_directly')] if settings.watched_indicators() in (1,2): listing += [('CLEAR TRAKT CACHE', 'clear_trakt_cache')] listing += [('EXTERNAL SCRAPERS MANAGER', 'open_external_scrapers_manager')] listing += [('OPEN TIKI META SETTINGS', 'open_meta_settings')] listing += [('OPEN OPENSCRAPERS SETTINGS', 'open_scraper_settings')] listing += [('OPEN FEN SETTINGS', 'open_fen_settings')] listing += [('[B]SAVE SETTINGS AND EXIT[/B]', 'save_and_exit')] xbmc.sleep(500) choice = selection_dialog([i[0] for i in listing], [i[1] for i in listing], 'Fen Options...') if choice == 'rescrape_select': return clear_and_rescrape(play_params) elif choice == 'toggle_autoplay': toggle_setting('auto_play', autoplay_toggle) elif choice == 'set_autoplay_hevc': set_autoplay_hevc() elif choice == 'toggle_autoplay_next': toggle_setting('autoplay_next_episode', autoplay_next_toggle) elif choice == 'enable_scrapers': enable_scrapers() elif choice == 'set_display_mode': set_display_mode() elif choice == 'set_filters': set_quality(quality_filter_setting) elif choice == 'set_subs_action': set_subtitle_action() elif choice == 'clear_cache_page': cached_page_clear(action=list_name) elif choice == 'toggle_indicators': toggle_setting('watched_indicators', indicators_toggle) elif choice == 'toggle_cached_torrents': toggle_setting('torrent.check.cache', cached_torrents_toggle) elif choice == 'toggle_torrents_display_uncached': toggle_setting('torrent.display.uncached', uncached_torrents_toggle) elif choice == 'set_active_cloud_store': set_active_cloud_store(active_cloud_store) elif choice == 'search_directly': furk_easynews_direct_search_choice(suggestion, from_results, list_name) elif choice == 'clear_trakt_cache': clear_cache('trakt') elif choice == 'open_external_scrapers_manager': external_scrapers_manager() elif choice == 'open_meta_settings': xbmc.executebuiltin('Addon.OpenSettings(script.module.tikimeta)') elif choice == 'open_scraper_settings': xbmc.executebuiltin('Addon.OpenSettings(script.module.openscrapers)') elif choice == 'open_fen_settings': open_settings('0.0') if choice in ('clear_cache_page', 'toggle_indicators', 'clear_trakt_cache') and content in ('movies', 'tvshows', 'seasons', 'episodes'): xbmc.executebuiltin('Container.Refresh') if choice in (None, 'rescrape_select', 'save_and_exit', 'clear_cache_page', 'toggle_indicators', 'clear_trakt_cache', 'search_directly', 'open_meta_settings', 'open_scraper_settings', 'open_fen_settings', 'open_external_scrapers_manager'): return xbmc.executebuiltin('RunPlugin(%s)' % build_url({'mode': 'playback_menu', 'from_results': from_results, 'suggestion': suggestion, 'list_name': list_name, 'play_params': play_params}))
def unaired_episode_color_choice(): from modules.nav_utils import toggle_setting dialog = 'Please Choose Color for Unaired Episodes' chosen_color = color_chooser(dialog, no_color=True) if chosen_color: toggle_setting('unaired_episode_colour', chosen_color)
def set_subtitle_action(): from modules.nav_utils import toggle_setting choices = ('Auto', 'Select', 'Off') choice = selection_dialog(choices, choices, 'Fen - Choose Subtitles Action') if choice: return toggle_setting('subtitles.subs_action', choice)