Beispiel #1
0
def scraper_dialog_color_choice():
    from urlparse import parse_qsl
    from resources.lib.modules.nav_utils import open_settings, toggle_setting
    params = dict(parse_qsl(sys.argv[2].replace('?','')))
    setting, setting_nav = ('int_dialog_highlight', '3.6') if params['setting'] == 'internal' else ('ext_dialog_highlight', '3.7')
    dialog = 'Please Choose Color for Internal Scrapers Progress Dialog Highlight'
    chosen_color = color_chooser(dialog)
    if chosen_color: toggle_setting(setting, chosen_color)
    open_settings(setting_nav)
Beispiel #2
0
def playback_menu(from_results=False, suggestion=None):
    from urlparse import parse_qsl
    from resources.lib.modules.nav_utils import toggle_setting, build_url, open_settings, clear_cache
    from resources.lib.modules import settings
    content = xbmc.getInfoLabel('Container.Content')
    params = dict(parse_qsl(sys.argv[2].replace('?','')))
    from_results = params.get('from_results', from_results)
    suggestion = params.get('suggestion', suggestion)
    autoplay_status, autoplay_toggle, filter_setting = ('On', 'false', 'autoplay_quality') if settings.auto_play() else ('Off', 'true', 'results_quality')
    autoplay_next_status, autoplay_next_toggle = ('On', 'false') if settings.autoplay_next_episode() else ('Off', 'true')
    results_display_status, results_display_toggle = ('Dialog', '0') if settings.use_dialog() else ('Directory', '1')
    prefer_hevc_status, prefer_hevc_toggle = ('On', 'false') if settings.prefer_hevc() else ('Off', 'true')
    auto_resolve_status, auto_resolve_toggle = ('On', 'false') if settings.auto_resolve() else ('Off', 'true')
    active_scrapers = settings.active_scrapers()
    current_scrapers_status = ', '.join([i.capitalize() for i in active_scrapers]) if len(active_scrapers) >= 1 else 'None Active'
    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')
    string = 'Please choose Fen Setting to Change...'
    listing = [('AUTOPLAY: [I]Currently [B]%s[/B][/I]' % autoplay_status, 'toggle_autoplay')]
    if autoplay_status == 'On':
        listing += [('PREFER HEVC IN AUTOPLAY: [I]Currently [B]%s[/B][/I]' % prefer_hevc_status, 'toggle_prefer_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 RESULTS: [I]Currently [B]%s[/B][/I]' % results_display_status, 'toggle_display_results')]
        listing += [('AUTO RESOLVE FURK PACKS: [I]Currently [B]%s[/B][/I]' % auto_resolve_status, 'toggle_auto_resolve')]
    listing += [('QUALITY FILTERS: [I]Currently [B]%s[/B][/I]' % current_filter_status, 'set_filters')]
    listing += [('SWITCH INDICATOR PROVIDER: [I]Currently [B]%s[/B][/I]' % indicators_status, 'toggle_indicators')]
    if settings.watched_indicators() in (1,2): listing += [('CLEAR TRAKT CACHE', 'clear_trakt_cache')]
    if content in ('movies', 'episodes'): listing += [('FURK/EASYNEWS SEARCH: [B][I]%s[/I][/B]' % params.get('suggestion', ''), 'search_directly')]
    listing += [('OPEN EXTERNAL SCRAPER 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], string)
    if choice == 'toggle_autoplay': toggle_setting('auto_play', autoplay_toggle)
    elif choice == 'toggle_prefer_hevc': toggle_setting('prefer_hevc', prefer_hevc_toggle)
    elif choice == 'toggle_autoplay_next': toggle_setting('autoplay_next_episode', autoplay_next_toggle)
    elif choice == 'enable_scrapers': enable_scrapers()
    elif choice == 'toggle_display_results': toggle_setting('use_dialog', results_display_toggle)
    elif choice == 'toggle_auto_resolve': toggle_setting('auto_resolve', auto_resolve_toggle)
    elif choice == 'set_filters': set_autoplay_quality(action=True) if autoplay_status == 'On' else set_results_quality(action=True)
    elif choice == 'toggle_indicators': toggle_setting('watched_indicators', indicators_toggle)
    elif choice == 'clear_trakt_cache': clear_cache('trakt')
    elif choice == 'search_directly': furk_easynews_direct_search_choice(suggestion, from_results)
    elif choice == 'open_scraper_settings': xbmc.executebuiltin('Addon.OpenSettings(%s)' % 'script.module.tikiscrapers')
    elif choice == 'open_fen_settings': open_settings('0.0')
    if choice in ('toggle_indicators', 'clear_trakt_cache') and content in ('movies', 'tvshows', 'seasons', 'episodes'): xbmc.executebuiltin('Container.Refresh')
    if choice in (None, 'save_and_exit', 'toggle_indicators', 'clear_trakt_cache', 'search_directly', 'open_scraper_settings', 'open_fen_settings'): return
    xbmc.executebuiltin('RunPlugin(%s)' % build_url({'mode': 'playback_menu', 'from_results': from_results, 'suggestion': suggestion}))
Beispiel #3
0
def next_episode_color_choice(setting=None):
    from urlparse import parse_qsl
    from resources.lib.modules.utils import color_chooser
    from resources.lib.modules.nav_utils import open_settings
    params = dict(parse_qsl(sys.argv[2].replace('?','')))
    choices = [('Airdate', 'nextep.airdate_colour'),
                ('Unaired', 'nextep.unaired_colour'),
                ('Unwatched', 'nextep.unwatched_colour')]
    prelim_setting = params.get('setting', None) if not setting else setting
    title, setting = [(i[0], i[1]) for i in choices if i[0] == prelim_setting][0]
    dialog = 'Please Choose Color for %s Highlight' % title
    chosen_color = color_chooser(dialog, no_color=True)
    if chosen_color: __addon__.setSetting(setting, chosen_color)
    if params.get('from_settings') == 'true':
        setting_nav = ('2.10') if prelim_setting == 'Airdate' else ('2.11') if prelim_setting == 'Unaired' else ('2.12')
        open_settings(setting_nav)
Beispiel #4
0
def set_autoplay_quality(action=False, source='autoplay_quality'):
    from urlparse import parse_qsl
    params = dict(parse_qsl(sys.argv[2].replace('?','')))
    action = params.get('action', action)
    open_setting = ('4.2')
    string = 'Please Choose Autoplay Filters'
    dl = ['Include SD', 'Include 720p', 'Include 1080p', 'Include 4K']
    fl = ['SD', '720p', '1080p', '4K']
    preselect = [fl.index(i) for i in __addon__.getSetting('autoplay_quality').split(', ')]
    filters = multiselect_dialog(string, dl, fl, preselect)
    if not filters: return
    from resources.lib.modules.nav_utils import toggle_setting
    toggle_setting('autoplay_quality', ', '.join(filters))
    if not action:
        from resources.lib.modules.nav_utils import open_settings
        open_settings(open_setting)
Beispiel #5
0
def scraper_color_choice():
    from urlparse import parse_qsl
    from resources.lib.modules.nav_utils import open_settings, toggle_setting
    params = dict(parse_qsl(sys.argv[2].replace('?','')))
    choices = [('local', 'provider.local_colour'),
                ('downloads', 'provider.downloads_colour'),
                ('furk', 'provider.furk_colour'),
                ('easynews', 'provider.easynews_colour'),
                ('premium', 'prem.identify'),
                ('torrent', 'torrent.identify')]
    title, setting = [(i[0], i[1]) for i in choices if i[0] == params.get('setting')][0]
    setting_nav = ('3.15') if setting == 'provider.furk_colour' else ('3.21') if setting == 'provider.easynews_colour' else \
                  ('3.28') if setting == 'provider.local_colour' else ('3.35') if setting == 'provider.downloads_colour' else \
                  ('3.51') if setting == 'prem.identify' else ('3.52')
    dialog = 'Please Choose Color for %s Results Highlight' % title.capitalize()
    chosen_color = color_chooser(dialog, no_color=True)
    if chosen_color: toggle_setting(setting, chosen_color)
    open_settings(setting_nav)
Beispiel #6
0
def set_results_quality(from_results=False, action=False):
    from urlparse import parse_qsl
    params = dict(parse_qsl(sys.argv[2].replace('?','')))
    from_results = True if 'from_results' in params else False
    action = params.get('action', action)
    open_setting = ('4.4')
    string = 'Please Choose Result Filters:'
    dl = ['Include SD', 'Include 720p', 'Include 1080p', 'Include 4K']
    fl = ['SD', '720p', '1080p', '4K']
    preselect = [fl.index(i) for i in __addon__.getSetting('results_quality').split(', ')]
    filters = multiselect_dialog(string, dl, fl, preselect)
    if not filters: return
    from resources.lib.modules.nav_utils import toggle_setting
    toggle_setting('results_quality', ', '.join(filters))
    if from_results == True:
        xbmc.executebuiltin('Container.Refresh')
    if not action:
        from resources.lib.modules.nav_utils import open_settings
        open_settings(open_setting)
    else: pass
Beispiel #7
0
    if mode == 'search_history':
        from resources.lib.modules.history import search_history
        search_history()
    elif mode == 'clear_search_history':
        from resources.lib.modules.history import clear_search_history
        clear_search_history()
    elif mode == 'remove_from_history':
        from resources.lib.modules.history import remove_from_history
        remove_from_history()
##EXTRA MODES##
elif mode == 'container_update':
    from resources.lib.modules.nav_utils import container_update
    container_update()
elif mode == 'open_settings':
    from resources.lib.modules.nav_utils import open_settings
    open_settings(params.get('query'))
elif mode == 'resolveurl_settings':
    try:
        import resolveurl
    except:
        pass
    resolveurl.display_settings()
elif mode == 'external_settings':
    from resources.lib.modules.utils import open_ext_settings
    open_ext_settings(params['ext_addon'])
elif mode == 'add_next_episode_unwatched':
    from resources.lib.modules.next_episode import add_next_episode_unwatched
    add_next_episode_unwatched()
elif mode == 'add_to_remove_from_next_episode_excludes':
    from resources.lib.modules.next_episode import add_to_remove_from_next_episode_excludes
    add_to_remove_from_next_episode_excludes()
Beispiel #8
0
def download(name, image, url):
    from resources.lib.modules import settings
    # from resources.lib.modules.utils import logger
    if url == None:
        from resources.lib.modules.nav_utils import notification
        notification('No URL found for Download. Pick another Source', 6000)
        return

    params = dict(urlparse.parse_qsl(sys.argv[2].replace('?', '')))
    json_meta = params.get('meta')
    if json_meta:
        meta = json.loads(json_meta)
        db_type = meta.get('vid_type')
        title = meta.get('title')
        year = meta.get('year')
        image = meta.get('poster')
        season = meta.get('season')
        episode = meta.get('episode')
    else:
        db_type = params.get('db_type')
        image = params.get('image')

    media_folder = settings.download_directory(db_type)
    if not media_folder:
        resp = xbmcgui.Dialog().yesno(
            "No Download folder set!",
            "Fen requires you to set Download Folders.",
            "Would you like to set a folder now?")
        if resp:
            from resources.lib.modules.nav_utils import open_settings
            open_settings('7.0')
        else:
            return
    if db_type in ('movie', 'episode'):
        folder_rootname = '%s (%s)' % (title, year)
        folder = os.path.join(media_folder, folder_rootname + '/')
    else:
        folder = media_folder
    if not xbmcvfs.exists(folder): xbmcvfs.mkdir(folder)
    if db_type == 'episode':
        folder = os.path.join(folder, 'Season ' + str(season))
        if not xbmcvfs.exists(folder): xbmcvfs.mkdir(folder)

    try:
        headers = dict(urlparse.parse_qsl(url.rsplit('|', 1)[1]))
    except:
        headers = dict('')
    dest = None
    url = url.split('|')[0]
    if not 'http' in url:
        from resources.lib.modules.furk_api import FurkAPI
        from resources.lib.indexers.furk import filter_furk_tlist, seas_ep_query_list
        t_files = FurkAPI().t_files(url)
        t_files = [i for i in t_files if 'video' in i['ct'] and 'bitrate' in i]
        name, url = filter_furk_tlist(
            t_files, (None if db_type == 'movie' else seas_ep_query_list(
                season, episode)))[0:2]
        dest = os.path.join(folder, name)
    if db_type == 'archive':
        ext = 'zip'
    else:
        ext = os.path.splitext(urlparse.urlparse(url).path)[1][1:]
        if not ext in ['mp4', 'mkv', 'flv', 'avi', 'mpg']: ext = 'mp4'

    if not dest:
        transname = name.translate(None, '\/:*?"<>|').strip('.')
        dest = os.path.join(folder, transname + '.' + ext)
    sysheaders = urllib.quote_plus(json.dumps(headers))
    sysurl = urllib.quote_plus(url)
    systitle = urllib.quote_plus(name)
    sysimage = urllib.quote_plus(image)
    sysdest = urllib.quote_plus(dest)

    script = inspect.getfile(inspect.currentframe())
    cmd = 'RunScript(%s, %s, %s, %s, %s, %s)' % (
        script, sysurl, sysdest, systitle, sysimage, sysheaders)

    xbmc.executebuiltin(cmd)
Beispiel #9
0
def unaired_episode_color_choice():
    from resources.lib.modules.nav_utils import open_settings, 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)
    open_settings('0.4')