Пример #1
0
def settings_set_players(media):
    playericon = get_icon_path("player")
    if media == "all":
        medias = ["movies","tvshows","live"]
        for media in medias:
            mediatype = media.replace('es','e ').replace('ws','w ').replace('all','').replace('ve','ve ')
            players = get_players(media)
            selected = [p.id for p in players]
            if selected is not None:
                if media == "movies":
                    plugin.set_setting(SETTING_MOVIES_ENABLED_PLAYERS, selected)
                elif media == "tvshows":
                    plugin.set_setting(SETTING_TV_ENABLED_PLAYERS, selected)
                elif media == "live":
                    plugin.set_setting(SETTING_LIVE_ENABLED_PLAYERS, selected)
                else:
                    raise Exception("invalid parameter %s" % media)
            plugin.notify(msg=_('All '+mediatype+'players'), title=_('Enabled'), delay=1000, image=get_icon_path("player"))
        plugin.notify(msg=_('All players'), title=_('Enabled'), delay=1000, image=get_icon_path("player"))
        return
    else:
        mediatype = media.replace('es','e ').replace('ws','w ').replace('all','').replace('ve','ve ')
        players = get_players(media)
        players = sorted(players,key=lambda player: player.clean_title.lower())
        version = xbmc.getInfoLabel('System.BuildVersion')
        if version.startswith('16') or version.startswith('17'):
            msg = "Do you want to enable all "+mediatype+"players?"
            if dialogs.yesno(_("Enable all "+mediatype+"players"), _(msg)):
                selected = [p.id for p in players]
            else:
                result = dialogs.multiselect(_("Select "+mediatype+"players to enable"), [p.clean_title for p in players])
                if result is not None:
                    selected = [players[i].id for i in result]
        else:
            selected = None
            msg = "Kodi 16 is required for multi-selection. Do you want to enable all "+mediatype+"players instead?"
            if dialogs.yesno(_("Enable all "+mediatype+"players"), _(msg)):
                selected = [p.id for p in players]
            else:
                result = dialogs.multichoice(_("Select "+mediatype+"players to enable"), [p.clean_title for p in players])
                if result is not None:
                    selected = [players[i].id for i in result]
        if selected is not None:
            if media == "movies":
                plugin.set_setting(SETTING_MOVIES_ENABLED_PLAYERS, selected)
            elif media == "tvshows":
                plugin.set_setting(SETTING_TV_ENABLED_PLAYERS, selected)
            elif media == "live":
                plugin.set_setting(SETTING_LIVE_ENABLED_PLAYERS, selected)
            else:
                raise Exception("invalid parameter %s" % media)
        plugin.notify(msg=_('All '+mediatype+'players'), title=_('Updated'), delay=1000, image=get_icon_path("player"))
Пример #2
0
def settings_set_players(media):
    players = get_players(media)
    players = sorted(players,key=lambda player: player.clean_title.lower())

    # Get selection by user
    selected = None
    try:
        result = dialogs.multiselect(_("Enable players"), [p.clean_title for p in players])
        if result is not None:
            selected = [players[i].id for i in result]
    except:
        msg = "Kodi 16 required. Do you want to enable all players instead?"
        if dialogs.yesno(_("Warning"), _(msg)):
            selected = [p.id for p in players]
    
    if selected is not None:
        if media == "movies":
            plugin.set_setting(SETTING_MOVIES_ENABLED_PLAYERS, selected)
        elif media == "tvshows":
            plugin.set_setting(SETTING_TV_ENABLED_PLAYERS, selected)
        elif media == "live":
            plugin.set_setting(SETTING_LIVE_ENABLED_PLAYERS, selected)
        else:
            raise Exception("invalid parameter %s" % media)
    
    plugin.open_settings()
Пример #3
0
def settings_set_players(media):
    players = get_players(media)
    players = sorted(players,key=lambda player: player.clean_title.lower())

    # Get selection by user
    selected = None
    try:
        result = dialogs.multiselect(_("Enable players"), [p.clean_title for p in players])
        if result is not None:
            selected = [players[i].id for i in result]
    except:
        msg = "Kodi 16 required. Do you want to enable all players instead?"
        if dialogs.yesno(_("Warning"), _(msg)):
            selected = [p.id for p in players]
    
    if selected is not None:
        if media == "movies":
            plugin.set_setting(SETTING_MOVIES_ENABLED_PLAYERS, selected)
        elif media == "tvshows":
            plugin.set_setting(SETTING_TV_ENABLED_PLAYERS, selected)
        elif media == "live":
            plugin.set_setting(SETTING_LIVE_ENABLED_PLAYERS, selected)
        else:
            raise Exception("invalid parameter %s" % media)
    
    plugin.open_settings()
Пример #4
0
def active_players(media, filters={}):
    if media == "movies": setting = SETTING_MOVIES_ENABLED_PLAYERS
    elif media == "tvshows": setting = SETTING_TV_ENABLED_PLAYERS
    elif media == "musicvideos": setting = SETTING_MUSICVIDEOS_ENABLED_PLAYERS
    elif media == "music": setting = SETTING_MUSIC_ENABLED_PLAYERS
    elif media == "live": setting = SETTING_LIVE_ENABLED_PLAYERS
    else: raise Exception("invalid parameter %s" % media)
    try: enabled = plugin.get_setting(setting, unicode)
    except: enabled = []
    return [p for p in get_players(media, filters) if p.id in enabled]
Пример #5
0
def play_movie(tmdb_id, mode):
    import_tmdb()
    # Get players to use
    if mode == 'select':
        play_plugin = ADDON_SELECTOR.id
    elif mode == 'context':
        play_plugin = plugin.get_setting(SETTING_MOVIES_DEFAULT_PLAYER_FROM_CONTEXT, unicode)
    elif mode == 'library':
        play_plugin = get_movie_player_plugin_from_library(tmdb_id)
        if not play_plugin or play_plugin == "default":
            play_plugin = plugin.get_setting(SETTING_MOVIES_DEFAULT_PLAYER_FROM_LIBRARY, unicode)
    elif mode == 'default':
        play_plugin = plugin.get_setting(SETTING_MOVIES_DEFAULT_PLAYER, unicode)
    else:
        play_plugin = mode
    if mode == 'default' or mode == 'select': players = active_players("movies")
    else: players = get_players("movies")
    players = [p for p in players if p.id == play_plugin] or players
    if not players:
        xbmc.executebuiltin( "Action(Info)")
        action_cancel()
        return
    # Get movie data from TMDB
    movie = tmdb.Movies(tmdb_id).info(language=LANG, append_to_response="external_ids,videos")
    movie_info = get_movie_metadata(movie)
    # Get movie ids from Trakt
    trakt_ids = get_trakt_ids("tmdb", tmdb_id, movie['original_title'],
                    "movie", parse_year(movie['release_date']))
    # Get parameters
    params = {}
    for lang in get_needed_langs(players):
        if lang == LANG:
            tmdb_data = movie
        else:
            tmdb_data = tmdb.Movies(tmdb_id).info(language=lang)
        params[lang] = get_movie_parameters(tmdb_data)
        if trakt_ids != None:
            params[lang].update(trakt_ids)
        params[lang]['info'] = movie_info
        params[lang] = to_unicode(params[lang])
    # Go for it
    link = on_play_video(mode, players, params, trakt_ids)
    if link:
        movie = tmdb.Movies(tmdb_id).info(language=LANG)
        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'],
            'properties' : {'fanart_image' : movie_info['fanart']},
        })
Пример #6
0
def play_movie(tmdb_id, mode):
    import_tmdb()
    # Get players to use
    if mode == 'select':
        play_plugin = ADDON_SELECTOR.id
    elif mode == 'context':
        play_plugin = plugin.get_setting(SETTING_MOVIES_DEFAULT_PLAYER_FROM_CONTEXT, unicode)
    elif mode == 'library':
        play_plugin = get_movie_player_plugin_from_library(tmdb_id)
        if not play_plugin or play_plugin == "default":
            play_plugin = plugin.get_setting(SETTING_MOVIES_DEFAULT_PLAYER_FROM_LIBRARY, unicode)
    elif mode == 'default':
        play_plugin = plugin.get_setting(SETTING_MOVIES_DEFAULT_PLAYER, unicode)
    else:
        play_plugin = mode
    if mode != 'context': players = active_players("movies")
    else: 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)")
        action_cancel()
        return
    # Get movie data from TMDB
    movie = tmdb.Movies(tmdb_id).info(language=LANG, append_to_response="external_ids,alternative_titles,credits,images,keywords,releases,videos,translations,similar,reviews,lists,rating")
    movie_info = get_movie_metadata(movie)
    # Get movie ids from Trakt
    trakt_ids = get_trakt_ids("tmdb", tmdb_id, movie['original_title'],
                    "movie", parse_year(movie['release_date']))
    # Get parameters
    params = {}
    for lang in get_needed_langs(players):
        if lang == LANG:
            tmdb_data = movie
        else:
                        tmdb_data = tmdb.Movies(tmdb_id).info(language=lang, append_to_response="external_ids,alternative_titles,credits,images,keywords,releases,videos,translations,similar,reviews,lists,rating")
        params[lang] = get_movie_parameters(tmdb_data)
        if trakt_ids != None:
            params[lang].update(trakt_ids)
        params[lang]['info'] = movie_info
        params[lang] = to_unicode(params[lang])
    # Go for it
    link = on_play_video(mode, players, params, trakt_ids)
    if link:
        movie = tmdb.Movies(tmdb_id).info(language=LANG)
        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'],
            'properties' : {'fanart_image' : movie_info['fanart']},
        })
Пример #7
0
def active_players(media, filters={}):
    if media == "movies": setting = SETTING_MOVIES_ENABLED_PLAYERS
    elif media == "tvshows": setting = SETTING_TV_ENABLED_PLAYERS
    elif media == "musicvideos": setting = SETTING_MUSICVIDEOS_ENABLED_PLAYERS
    elif media == "music": setting = SETTING_MUSIC_ENABLED_PLAYERS
    elif media == "live": setting = SETTING_LIVE_ENABLED_PLAYERS
    else: raise Exception("invalid parameter %s" % media)
    try:
        enabled = plugin.get_setting(setting, unicode)
    except:
        enabled = []
    return [p for p in get_players(media, filters) if p.id in enabled]
Пример #8
0
def active_players(media, filters={}):
    if media == "movies":
        setting = SETTING_MOVIES_ENABLED_PLAYERS
    elif media == "tvshows":
        setting = SETTING_TV_ENABLED_PLAYERS
    else:
        raise Exception("invalid parameter %s" % media)
        
    try:
        enabled = plugin.get_setting(setting)
    except:
        enabled = []
        
    return [p for p in get_players(media, filters) \
            if p.id in enabled]
Пример #9
0
def settings_set_players(media):
    players = get_players(media)
    players = sorted(players,key=lambda player: player.clean_title.lower())

    # Get selection by user
    selected = None
    mediatype = media.replace('es','e').replace('ws','w')
    try:
        msg = "Do you want to enable all "+mediatype+" players?"
        if dialogs.yesno(_("Enable all "+mediatype+" players"), _(msg)):
            enableall = True
            selected = [p.id for p in players]
        else:
            enableall = False
            result = dialogs.multiselect(_("Select "+mediatype+" players to enable"), [p.clean_title for p in players])
            if result is not None:
                selected = [players[i].id for i in result]
    except:
        if enableall == False:
            msg = "Kodi 16 required for manual multi-selection. Do you want to enable all "+mediatype+" players instead?"
            if dialogs.yesno(_("Warning"), _(msg)):
                selected = [p.id for p in players]
            else:
                return
        elif enableall == True:
            selected = [p.id for p in players]
        else:
            pass
    
    if selected is not None:
        if media == "movies":
            plugin.set_setting(SETTING_MOVIES_ENABLED_PLAYERS, selected)
        elif media == "tvshows":
            plugin.set_setting(SETTING_TV_ENABLED_PLAYERS, selected)
        elif media == "live":
            plugin.set_setting(SETTING_LIVE_ENABLED_PLAYERS, selected)
        else:
            raise Exception("invalid parameter %s" % media)
    
    plugin.open_settings()
Пример #10
0
def play_episode(id, season, episode, mode):
    import_tvdb()
    id = int(id)
    season = int(season)
    episode = int(episode)
    # Get database id
    dbid = xbmc.getInfoLabel("ListItem.DBID")
    try:
        dbid = int(dbid)
    except:
        dbid = None
    # Get show data from TVDB
    show = tvdb[id]
    show_info = get_tvshow_metadata_tvdb(show, banners=False)
    # Get players to use
    if mode == 'select':
        play_plugin = ADDON_SELECTOR.id
    elif mode == 'context':
        play_plugin = plugin.get_setting(SETTING_TV_DEFAULT_PLAYER_FROM_CONTEXT, unicode)
    elif mode == 'library':
        play_plugin = get_tv_player_plugin_from_library(id)
        if not play_plugin or play_plugin == "default":
            play_plugin = plugin.get_setting(SETTING_TV_DEFAULT_PLAYER_FROM_LIBRARY, unicode)
    elif mode == 'default':
        play_plugin = plugin.get_setting(SETTING_TV_DEFAULT_PLAYER, unicode)
    else:
        play_plugin = mode
    if mode == 'default' or mode == 'select': players = active_players("tvshows", filters = {'network': show.get('network')})
    else: players = get_players("tvshows", filters = {'network': show.get('network')})
    players = [p for p in players if p.id == play_plugin] or players
    if not players: return xbmc.executebuiltin( "Action(Info)")
    # Get show ids from Trakt
    trakt_ids = get_trakt_ids("tvdb", id, show['seriesname'], "show", show.get('year', 0))
    # Get parameters
    params = {}
    for lang in get_needed_langs(players):
        if lang == LANG:
            tvdb_data = show
        else:
            tvdb_data = create_tvdb(lang)[id]
        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, mode)
            elif trakt_ids["tvdb"] == None or trakt_ids["tvdb"] == "":
                msg = "{0} {1} - S{2}E{3}".format(_("No TVDb information found for"), show_info['name'], season, episode)
                return dialogs.ok(_("%s not found") % _("Episode information"), msg)
            else:
                msg = "{0} {1} - S{2}E{3}".format(_("No TVDb or TMDb information found for"), show_info['name'], season, episode)
                return dialogs.ok(_("%s not found") % _("Episode information"), msg)
        if trakt_ids != None: params[lang].update(trakt_ids)
        params[lang]['info'] = show_info
        params[lang] = to_unicode(params[lang])
    # Go for it
    link = on_play_video(mode, players, params, trakt_ids)
    if link:
        # set properties
        set_property("data", json.dumps({'dbid': dbid, 'tvdb': id, 
            'season': season, 'episode': episode}))
        # Play
        season_info = get_season_metadata_tvdb(show_info, show[season], banners=False)
        episode_info = get_episode_metadata_tvdb(season_info, show[season][episode])
        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'],
            'properties' : {'fanart_image' : episode_info['fanart']},
        })
Пример #11
0
def tvmaze_play_episode(id, season, episode, mode, title=None):
    title = ""
    try: id = int(id)
    except: title = id
    if title and title != "":
        url = "http://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 = "http://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 = get_trakt_ids("tvdb", show['externals']['thetvdb'], show['name'], "show", show['premiered'][:4])
        elif show['externals']['imdb']: trakt_ids = get_trakt_ids("imdb", show['externals']['imdb'], show['name'], "show", show['premiered'][:4])
        else: trakt_ids = get_trakt_ids(query=show['name'], type="show", year=show['premiered'][:4])
    else: trakt_ids = get_trakt_ids(query=show['name'], type="show", year=show['premiered'][:4])
    show_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 = get_season_metadata_tvmaze(show_info, preason)
    episode_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 = []
    if mode == 'select': play_plugin = ADDON_SELECTOR.id
    elif mode == 'context': play_plugin = plugin.get_setting(SETTING_TV_DEFAULT_PLAYER_FROM_CONTEXT, unicode)
    elif mode == 'library':
        play_plugin = get_tv_player_plugin_from_library(id)
        if not play_plugin or play_plugin == "default": play_plugin = plugin.get_setting(SETTING_TV_DEFAULT_PLAYER_FROM_LIBRARY, unicode)
    elif mode == 'default': play_plugin = plugin.get_setting(SETTING_TV_DEFAULT_PLAYER, unicode)
    else: play_plugin = mode
    if mode == 'default' or mode == 'select': players = active_players("tvshows")
    else: 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 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, mode)
            elif tried == "tmdb":
                msg = "{0} {1} - S{2}E{3}".format(_("No TVDb or TMDb information found for"), show_info['name'], season, episode)
                dialogs.ok(_("%s not found") % _("Episode information"), msg)
                return
            else:
                msg = "{0} {1} - S{2}E{3}".format(_("No TMDb information found for"), show_info['name'], season, episode)
                dialogs.ok(_("%s not found") % _("Episode information"), msg)
                return
        if trakt_ids != None: params[lang].update(trakt_ids)
        params[lang]['info'] = show_info
        params[lang] = to_unicode(params[lang])
    link = on_play_video(mode, players, params, trakt_ids)
    if link:
        set_property("data", json.dumps({'dbid': dbid, 'tvdb': trakt_ids['tvdb'], 'season': season, 'episode': episode}))
        episode_metadata = get_episode_metadata_tvmaze(season_info, prepisode)
        action_play({
            'label': episode_info['title'],
            'path': link,
            'info': [],
            'is_playable': True,
            'info_type': 'video',
            'thumbnail': episode_info['poster'],
            'poster': episode_info['poster'],
            'properties' : {'fanart_image' : str(show_info['fanart'])},
        })
Пример #12
0
def trakt_play_episode(id, season, episode, mode):
    from trakt import trakt
    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 = trakt.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 = get_trakt_ids("trakt", id, show_title, "show", year)
        preason = trakt.get_season(id, season)
        if preason:
            prepisode = trakt.get_episode(id, season, episode)
        elif not preason and season > 1900: 
            seasons = trakt.get_seasons(id)
            for item in seasons:
                if item['first_aired'] != None:
                    if int(item['first_aired'][:4]) == season: 
                        season_number = item['number']
                        preason = trakt.get_season(id, season_number)
    if not prepisode or not preason or not show: return tvmaze_play_episode(show_title, season, episode, mode)
    show_info = get_tvshow_metadata_trakt(show)
    season_info = get_season_metadata_trakt(show_info, preason)
    episode_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 = []
    if mode == 'select': play_plugin = ADDON_SELECTOR.id
    elif mode == 'context': play_plugin = plugin.get_setting(SETTING_TV_DEFAULT_PLAYER_FROM_CONTEXT, unicode)
    elif mode == 'library':
        play_plugin = get_tv_player_plugin_from_library(id)
        if not play_plugin or play_plugin == "default": play_plugin = plugin.get_setting(SETTING_TV_DEFAULT_PLAYER_FROM_LIBRARY, unicode)
    elif mode == 'default': play_plugin = plugin.get_setting(SETTING_TV_DEFAULT_PLAYER, unicode)
    else: play_plugin = mode
    if mode == 'default' or mode == 'select': players = active_players("tvshows")
    else: 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 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, mode)
            elif tried == "tmdb":
                msg = "{0} {1} - S{2}E{3}".format(_("No TVDb or TMDb information found for"), show_info['name'], season, episode)
                dialogs.ok(_("%s not found") % _("Episode information"), msg)
                return
            else:
                msg = "{0} {1} - S{2}E{3}".format(_("No TMDb information found for"), show_info['name'], season, episode)
                dialogs.ok(_("%s not found") % _("Episode information"), msg)
                return
        if trakt_ids != None: params[lang].update(trakt_ids)
        params[lang]['info'] = show_info
        params[lang] = to_unicode(params[lang])
    link = on_play_video(mode, players, params, trakt_ids)
    if link:
        set_property("data", json.dumps({'dbid': dbid, 'trakt': id, 'season': season, 'episode': episode}))
        episode_metadata = get_episode_metadata_trakt(season_info, prepisode)
        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'],
            'properties' : {'fanart_image' : str(show_info['fanart'])},
        })
Пример #13
0
def play_episode(id, season, episode, mode):
    import_tvdb()
    id = int(id)
    season = int(season)
    episode = int(episode)
    # Get database id
    dbid = xbmc.getInfoLabel("ListItem.DBID")
    try:
        dbid = int(dbid)
    except:
        dbid = None
    # Get show data from TVDB
    show = tvdb[id]
    show_info = get_tvshow_metadata_tvdb(show, banners=False)
    # Get players to use
    if mode == 'select':
        play_plugin = ADDON_SELECTOR.id
    elif mode == 'context':
        play_plugin = plugin.get_setting(SETTING_TV_DEFAULT_PLAYER_FROM_CONTEXT, unicode)
    elif mode == 'library':
        play_plugin = get_tv_player_plugin_from_library(id)
        if not play_plugin or play_plugin == "default":
            play_plugin = plugin.get_setting(SETTING_TV_DEFAULT_PLAYER_FROM_LIBRARY, unicode)
    elif mode == 'default':
        play_plugin = plugin.get_setting(SETTING_TV_DEFAULT_PLAYER, unicode)
    else:
        play_plugin = mode
    if mode == 'default' or mode == 'select': players = active_players("tvshows", filters = {'network': show.get('network')})
    else: players = get_players("tvshows", filters = {'network': show.get('network')})
    players = [p for p in players if p.id == play_plugin] or players
    if not players: return xbmc.executebuiltin( "Action(Info)")
    # Get show ids from Trakt
    trakt_ids = get_trakt_ids("tvdb", id, show['seriesname'], "show", show.get('year', 0))
    # Get parameters
    params = {}
    for lang in get_needed_langs(players):
        if lang == LANG:
            tvdb_data = show
        else:
            tvdb_data = create_tvdb(lang)[id]
        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, mode)
            elif trakt_ids["tvdb"] == None or trakt_ids["tvdb"] == "":
                msg = "{0} {1} - S{2}E{3}".format(_("No TVDb information found for"), show_info['name'], season, episode)
                return dialogs.ok(_("%s not found") % _("Episode information"), msg)
            else:
                msg = "{0} {1} - S{2}E{3}".format(_("No TVDb or TMDb information found for"), show_info['name'], season, episode)
                return dialogs.ok(_("%s not found") % _("Episode information"), msg)
        if trakt_ids != None: params[lang].update(trakt_ids)
        params[lang]['info'] = show_info
        params[lang] = to_unicode(params[lang])
    # Go for it
    link = on_play_video(mode, players, params, trakt_ids)
    if link:
        # set properties
        set_property("data", json.dumps({'dbid': dbid, 'tvdb': id, 
            'season': season, 'episode': episode}))
        # Play
        season_info = get_season_metadata_tvdb(show_info, show[season], banners=False)
        episode_info = get_episode_metadata_tvdb(season_info, show[season][episode])
        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'],
            'properties' : {'fanart_image' : episode_info['fanart']},
        })
Пример #14
0
def tmdb_play_episode(id, season, episode, mode):
    tried = "tvdb"
    import_tmdb()
    id = int(id)
    season = int(season)
    episode = int(episode)
    dbid = xbmc.getInfoLabel("ListItem.DBID")
    try: dbid = int(dbid)
    except: dbid = None
    show = tmdb.TV(id).info(language=LANG, append_to_response="external_ids,images,similar,videos")
    if 'first_air_date' in show and show['first_air_date'] != None: year = show['first_air_date'][:4]
    else: year = None
    trakt_ids = get_trakt_ids("tmdb", id)
    if "status_code" in show: return trakt_play_episode(trakt_ids["trakt"], season, episode, mode)
    if 'name' in show: title = show['name']
    else: title = None
    show_info = get_tvshow_metadata_tmdb(show)
    title = show_info['name']
    preason = tmdb.TV_Seasons(id, season).info(language=LANG, append_to_response="external_ids,images,similar,videos")
    if "The resource you requested could not be found" in str(preason): return trakt_play_episode(trakt_ids["trakt"], season, episode, mode)
    season_info = get_season_metadata_tmdb(show_info, preason)
    prepisode = tmdb.TV_Episodes(id, season, episode).info(language=LANG, append_to_response="external_ids,images,similar,videos")
    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, mode)
    episode_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 = []
    if mode == 'select': play_plugin = ADDON_SELECTOR.id
    elif mode == 'context': play_plugin = plugin.get_setting(SETTING_TV_DEFAULT_PLAYER_FROM_CONTEXT, unicode)
    elif mode == 'library':
        play_plugin = get_tv_player_plugin_from_library(id)
        if not play_plugin or play_plugin == "default": play_plugin = plugin.get_setting(SETTING_TV_DEFAULT_PLAYER_FROM_LIBRARY, unicode)
    elif mode == 'default': play_plugin = plugin.get_setting(SETTING_TV_DEFAULT_PLAYER, unicode)
    else: play_plugin = mode
    if mode == 'default' or mode == 'select': players = active_players("tvshows")
    else: 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 = get_trakt_ids("tmdb", id, show_info['name'], "show", show['first_air_date'][:4])
    params = {}
    for lang in 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, mode)
            else:
                msg = "{0} {1} - S{2}E{3}".format(_("No TMDb information found for"), show_info['name'], season, episode)
                dialogs.ok(_("%s not found") % _("Episode information"), msg)
                return
        if trakt_ids != None: params[lang].update(trakt_ids)
        params[lang]['info'] = show_info
        params[lang] = to_unicode(params[lang])
    link = on_play_video(mode, players, params, trakt_ids)
    if link:
        set_property("data", json.dumps({'dbid': dbid, 'tmdb': id, 'season': season, 'episode': episode}))
        episode_metadata = get_episode_metadata_tmdb(season_info, prepisode)
        action_play({
            'label': episode_info['title'],
            'path': link,
            'info': [],
            'is_playable': True,
            'info_type': 'video',
            'thumbnail': episode_info['poster'],
            'poster': episode_info['poster'],
            'properties' : {'fanart_image' : str(show_info['fanart'])},
        })
Пример #15
0
def settings_set_players(media):
    playericon = get_icon_path("player")
    medias = ["movies", "tvshows", "musicvideos", "music", "live"]
    if media == "all":
        for media in medias:
            mediatype = media.replace('es', 'e').replace('ws', 'w').replace(
                'all', '').replace('os', 'o').replace('vs', 'v s')
            players = get_players(media)
            selected = [p.id for p in players]
            if selected is not None:
                if media == "movies":
                    plugin.set_setting(SETTING_MOVIES_ENABLED_PLAYERS,
                                       selected)
                elif media == "tvshows":
                    plugin.set_setting(SETTING_TV_ENABLED_PLAYERS, selected)
                elif media == "musicvideos":
                    plugin.set_setting(SETTING_MUSICVIDEOS_ENABLED_PLAYERS,
                                       selected)
                elif media == "music":
                    plugin.set_setting(SETTING_MUSIC_ENABLED_PLAYERS, selected)
                elif media == "live":
                    plugin.set_setting(SETTING_LIVE_ENABLED_PLAYERS, selected)
                else:
                    raise Exception("invalid parameter %s" % media)
            plugin.notify(msg=_('All ' + mediatype + ' players'),
                          title=_('Enabled'),
                          delay=1000,
                          image=get_icon_path("player"))
        plugin.notify(msg=_('All players'),
                      title=_('Enabled'),
                      delay=1000,
                      image=get_icon_path("player"))
        return True
    elif media == "tvportal":
        players = get_players("live")
        selected = [p.id for p in players]
        plugin.set_setting(SETTING_LIVE_ENABLED_PLAYERS, selected)
        return
    else:
        mediatype = media.replace('es', 'e ').replace('ws', 'w ').replace(
            'all', '').replace('ve', 've ').replace('_', '')
        players = get_players(media)
        players = sorted(players,
                         key=lambda player: player.clean_title.lower())
        version = xbmc.getInfoLabel('System.BuildVersion')
        selected = None
        if version.startswith('16') or version.startswith('17'):
            msg = "Do you want to enable all " + mediatype + "players?"
            if dialogs.yesno(_("Enable all " + mediatype + "players"), _(msg)):
                selected = [p.id for p in players]
            else:
                result = dialogs.multiselect(
                    _("Select " + mediatype + "players to enable"),
                    [p.clean_title for p in players])
                if result is not None:
                    selected = [players[i].id for i in result]
        else:
            selected = None
            msg = "Kodi 16 is required for multi-selection. Do you want to enable all " + mediatype + "players instead?"
            if dialogs.yesno(_("Enable all " + mediatype + "players"), _(msg)):
                selected = [p.id for p in players]
            else:
                result = dialogs.multichoice(
                    _("Select " + mediatype + "players to enable"),
                    [p.clean_title for p in players])
                if result is not None:
                    selected = [players[i].id for i in result]
        if selected is not None:
            if media == "movies":
                plugin.set_setting(SETTING_MOVIES_ENABLED_PLAYERS, selected)
            elif media == "tvshows":
                plugin.set_setting(SETTING_TV_ENABLED_PLAYERS, selected)
            elif media == "musicvideos":
                plugin.set_setting(SETTING_MUSICVIDEOS_ENABLED_PLAYERS,
                                   selected)
            elif media == "music":
                plugin.set_setting(SETTING_MUSIC_ENABLED_PLAYERS, selected)
            elif media == "live":
                plugin.set_setting(SETTING_LIVE_ENABLED_PLAYERS, selected)
            else:
                raise Exception("invalid parameter %s" % media)
        plugin.notify(msg=_('All ' + mediatype + 'players'),
                      title=_('Updated'),
                      delay=1000,
                      image=get_icon_path("player"))
    plugin.open_settings()
Пример #16
0
def tvmaze_play_episode(id, season, episode, mode, title=None):
    title = ""
    try: id = int(id)
    except: title = id
    if title and title != "":
        url = "http://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 = "http://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 = get_trakt_ids("tvdb", show['externals']['thetvdb'], show['name'], "show", show['premiered'][:4])
        elif show['externals']['imdb']: trakt_ids = get_trakt_ids("imdb", show['externals']['imdb'], show['name'], "show", show['premiered'][:4])
        else: trakt_ids = get_trakt_ids(query=show['name'], type="show", year=show['premiered'][:4])
    else: trakt_ids = get_trakt_ids(query=show['name'], type="show", year=show['premiered'][:4])
    show_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 = get_season_metadata_tvmaze(show_info, preason)
    episode_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 = []
    if mode == 'select': play_plugin = ADDON_SELECTOR.id
    elif mode == 'context': play_plugin = plugin.get_setting(SETTING_TV_DEFAULT_PLAYER_FROM_CONTEXT, unicode)
    elif mode == 'library':
        play_plugin = get_tv_player_plugin_from_library(id)
        if not play_plugin or play_plugin == "default": play_plugin = plugin.get_setting(SETTING_TV_DEFAULT_PLAYER_FROM_LIBRARY, unicode)
    elif mode == 'default': play_plugin = plugin.get_setting(SETTING_TV_DEFAULT_PLAYER, unicode)
    else: play_plugin = mode
    if mode == 'default' or mode == 'select': players = active_players("tvshows")
    else: 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 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, mode)
            elif tried == "tmdb":
                msg = "{0} {1} - S{2}E{3}".format(_("No TVDb or TMDb information found for"), show_info['name'], season, episode)
                dialogs.ok(_("%s not found") % _("Episode information"), msg)
                return
            else:
                msg = "{0} {1} - S{2}E{3}".format(_("No TMDb information found for"), show_info['name'], season, episode)
                dialogs.ok(_("%s not found") % _("Episode information"), msg)
                return
        if trakt_ids != None: params[lang].update(trakt_ids)
        params[lang]['info'] = show_info
        params[lang] = to_unicode(params[lang])
    link = on_play_video(mode, players, params, trakt_ids)
    if link:
        set_property("data", json.dumps({'dbid': dbid, 'tvdb': trakt_ids['tvdb'], 'season': season, 'episode': episode}))
        episode_metadata = get_episode_metadata_tvmaze(season_info, prepisode)
        action_play({
            'label': episode_info['title'],
            'path': link,
            'info': [],
            'is_playable': True,
            'info_type': 'video',
            'thumbnail': episode_info['poster'],
            'poster': episode_info['poster'],
            'properties' : {'fanart_image' : str(show_info['fanart'])},
        })
Пример #17
0
def trakt_play_episode(id, season, episode, mode):
    from trakt import trakt
    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 = trakt.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 = get_trakt_ids("trakt", id, show_title, "show", year)
        preason = trakt.get_season(id, season)
        if preason:
            prepisode = trakt.get_episode(id, season, episode)
        elif not preason and season > 1900: 
            seasons = trakt.get_seasons(id)
            for item in seasons:
                if item['first_aired'] != None:
                    if int(item['first_aired'][:4]) == season: 
                        season_number = item['number']
                        preason = trakt.get_season(id, season_number)
    if not prepisode or not preason or not show: return tvmaze_play_episode(show_title, season, episode, mode)
    show_info = get_tvshow_metadata_trakt(show)
    season_info = get_season_metadata_trakt(show_info, preason)
    episode_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 = []
    if mode == 'select': play_plugin = ADDON_SELECTOR.id
    elif mode == 'context': play_plugin = plugin.get_setting(SETTING_TV_DEFAULT_PLAYER_FROM_CONTEXT, unicode)
    elif mode == 'library':
        play_plugin = get_tv_player_plugin_from_library(id)
        if not play_plugin or play_plugin == "default": play_plugin = plugin.get_setting(SETTING_TV_DEFAULT_PLAYER_FROM_LIBRARY, unicode)
    elif mode == 'default': play_plugin = plugin.get_setting(SETTING_TV_DEFAULT_PLAYER, unicode)
    else: play_plugin = mode
    if mode == 'default' or mode == 'select': players = active_players("tvshows")
    else: 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 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, mode)
            elif tried == "tmdb":
                msg = "{0} {1} - S{2}E{3}".format(_("No TVDb or TMDb information found for"), show_info['name'], season, episode)
                dialogs.ok(_("%s not found") % _("Episode information"), msg)
                return
            else:
                msg = "{0} {1} - S{2}E{3}".format(_("No TMDb information found for"), show_info['name'], season, episode)
                dialogs.ok(_("%s not found") % _("Episode information"), msg)
                return
        if trakt_ids != None: params[lang].update(trakt_ids)
        params[lang]['info'] = show_info
        params[lang] = to_unicode(params[lang])
    link = on_play_video(mode, players, params, trakt_ids)
    if link:
        set_property("data", json.dumps({'dbid': dbid, 'trakt': id, 'season': season, 'episode': episode}))
        episode_metadata = get_episode_metadata_trakt(season_info, prepisode)
        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'],
            'properties' : {'fanart_image' : str(show_info['fanart'])},
        })
Пример #18
0
def tmdb_play_episode(id, season, episode, mode):
    tried = "tvdb"
    import_tmdb()
    id = int(id)
    season = int(season)
    episode = int(episode)
    dbid = xbmc.getInfoLabel("ListItem.DBID")
    try: dbid = int(dbid)
    except: dbid = None
    show = tmdb.TV(id).info(language=LANG, append_to_response="external_ids,images,similar,videos")
    if 'first_air_date' in show and show['first_air_date'] != None: year = show['first_air_date'][:4]
    else: year = None
    trakt_ids = get_trakt_ids("tmdb", id)
    if "status_code" in show: return trakt_play_episode(trakt_ids["trakt"], season, episode, mode)
    if 'name' in show: title = show['name']
    else: title = None
    show_info = get_tvshow_metadata_tmdb(show)
    title = show_info['name']
    preason = tmdb.TV_Seasons(id, season).info(language=LANG, append_to_response="external_ids,images,similar,videos")
    if "The resource you requested could not be found" in str(preason): return trakt_play_episode(trakt_ids["trakt"], season, episode, mode)
    season_info = get_season_metadata_tmdb(show_info, preason)
    prepisode = tmdb.TV_Episodes(id, season, episode).info(language=LANG, append_to_response="external_ids,images,similar,videos")
    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, mode)
    episode_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 = []
    if mode == 'select': play_plugin = ADDON_SELECTOR.id
    elif mode == 'context': play_plugin = plugin.get_setting(SETTING_TV_DEFAULT_PLAYER_FROM_CONTEXT, unicode)
    elif mode == 'library':
        play_plugin = get_tv_player_plugin_from_library(id)
        if not play_plugin or play_plugin == "default": play_plugin = plugin.get_setting(SETTING_TV_DEFAULT_PLAYER_FROM_LIBRARY, unicode)
    elif mode == 'default': play_plugin = plugin.get_setting(SETTING_TV_DEFAULT_PLAYER, unicode)
    else: play_plugin = mode
    if mode == 'default' or mode == 'select': players = active_players("tvshows")
    else: 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 = get_trakt_ids("tmdb", id, show_info['name'], "show", show['first_air_date'][:4])
    params = {}
    for lang in 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, mode)
            else:
                msg = "{0} {1} - S{2}E{3}".format(_("No TMDb information found for"), show_info['name'], season, episode)
                dialogs.ok(_("%s not found") % _("Episode information"), msg)
                return
        if trakt_ids != None: params[lang].update(trakt_ids)
        params[lang]['info'] = show_info
        params[lang] = to_unicode(params[lang])
    link = on_play_video(mode, players, params, trakt_ids)
    if link:
        set_property("data", json.dumps({'dbid': dbid, 'tmdb': id, 'season': season, 'episode': episode}))
        episode_metadata = get_episode_metadata_tmdb(season_info, prepisode)
        action_play({
            'label': episode_info['title'],
            'path': link,
            'info': [],
            'is_playable': True,
            'info_type': 'video',
            'thumbnail': episode_info['poster'],
            'poster': episode_info['poster'],
            'properties' : {'fanart_image' : str(show_info['fanart'])},
        })
Пример #19
0
def settings_set_players(media):
    playericon = get_icon_path("player")
    medias = ["movies", "tvshows", "musicvideos", "music", "live"]
    if media == "all":
        for media in medias:
            mediatype = (
                media.replace("es", "e").replace("ws", "w").replace("all", "").replace("os", "o").replace("vs", "v s")
            )
            players = get_players(media)
            selected = [p.id for p in players]
            if selected is not None:
                if media == "movies":
                    plugin.set_setting(SETTING_MOVIES_ENABLED_PLAYERS, selected)
                elif media == "tvshows":
                    plugin.set_setting(SETTING_TV_ENABLED_PLAYERS, selected)
                elif media == "musicvideos":
                    plugin.set_setting(SETTING_MUSICVIDEOS_ENABLED_PLAYERS, selected)
                elif media == "music":
                    plugin.set_setting(SETTING_MUSIC_ENABLED_PLAYERS, selected)
                elif media == "live":
                    plugin.set_setting(SETTING_LIVE_ENABLED_PLAYERS, selected)
                else:
                    raise Exception("invalid parameter %s" % media)
            plugin.notify(
                msg=_("All " + mediatype + " players"), title=_("Enabled"), delay=1000, image=get_icon_path("player")
            )
        plugin.notify(msg=_("All players"), title=_("Enabled"), delay=1000, image=get_icon_path("player"))
        return True
    elif media == "tvportal":
        players = get_players("live")
        selected = [p.id for p in players]
        plugin.set_setting(SETTING_LIVE_ENABLED_PLAYERS, selected)
        return
    else:
        mediatype = (
            media.replace("es", "e ").replace("ws", "w ").replace("all", "").replace("ve", "ve ").replace("_", "")
        )
        players = get_players(media)
        players = sorted(players, key=lambda player: player.clean_title.lower())
        version = xbmc.getInfoLabel("System.BuildVersion")
        selected = None
        if version.startswith("16") or version.startswith("17"):
            msg = "Do you want to enable all " + mediatype + "players?"
            if dialogs.yesno(_("Enable all " + mediatype + "players"), _(msg)):
                selected = [p.id for p in players]
            else:
                result = dialogs.multiselect(
                    _("Select " + mediatype + "players to enable"), [p.clean_title for p in players]
                )
                if result is not None:
                    selected = [players[i].id for i in result]
        else:
            selected = None
            msg = "Kodi 16 is required for multi-selection. Do you want to enable all " + mediatype + "players instead?"
            if dialogs.yesno(_("Enable all " + mediatype + "players"), _(msg)):
                selected = [p.id for p in players]
            else:
                result = dialogs.multichoice(
                    _("Select " + mediatype + "players to enable"), [p.clean_title for p in players]
                )
                if result is not None:
                    selected = [players[i].id for i in result]
        if selected is not None:
            if media == "movies":
                plugin.set_setting(SETTING_MOVIES_ENABLED_PLAYERS, selected)
            elif media == "tvshows":
                plugin.set_setting(SETTING_TV_ENABLED_PLAYERS, selected)
            elif media == "musicvideos":
                plugin.set_setting(SETTING_MUSICVIDEOS_ENABLED_PLAYERS, selected)
            elif media == "music":
                plugin.set_setting(SETTING_MUSIC_ENABLED_PLAYERS, selected)
            elif media == "live":
                plugin.set_setting(SETTING_LIVE_ENABLED_PLAYERS, selected)
            else:
                raise Exception("invalid parameter %s" % media)
        plugin.notify(
            msg=_("All " + mediatype + "players"), title=_("Updated"), delay=1000, image=get_icon_path("player")
        )
    plugin.open_settings()