Beispiel #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"))
Beispiel #2
0
def trakt_movies_watchlist_to_library(preaprove = False, uncached = False):
    from trakt import trakt
    if preaprove  or dialogs.yesno(_("Scan item to library"), "{0}[CR]{1}".format(_("Add %s") % ("'{0} {1} {2}'".format("Trakt", _("movie"), _("Watchlist").lower())),_("Are you sure?"))):
        if uncached:
            movies_add_all_to_library(trakt.trakt_get_watchlist_uncached("movies"), True)
        else:
            movies_add_all_to_library(trakt.trakt_get_watchlist("movies"))
Beispiel #3
0
def setup_library(library_folder):
    if library_folder[-1] != "/":
        library_folder += "/"
    metalliq_playlist_folder = "special://profile/playlists/mixed/MetalliQ/"
    if not xbmcvfs.exists(metalliq_playlist_folder):
        xbmcvfs.mkdir(metalliq_playlist_folder)
    playlist_folder = plugin.get_setting(SETTING_MUSIC_PLAYLIST_FOLDER,
                                         unicode)
    if plugin.get_setting(SETTING_MUSIC_PLAYLIST_FOLDER, unicode)[-1] != "/":
        playlist_folder += "/"
    # create folders
    if not xbmcvfs.exists(playlist_folder): xbmcvfs.mkdir(playlist_folder)
    if not xbmcvfs.exists(library_folder):
        # create folder
        xbmcvfs.mkdir(library_folder)
        msg = _(
            "Would you like to automatically set [COLOR ff0084ff]M[/COLOR]etalli[COLOR ff0084ff]Q[/COLOR] as a music source?"
        )
        if dialogs.yesno("{0} {1}".format(_("Library"), "setup"), msg):
            source_thumbnail = get_icon_path("tv")
            source_name = "[COLOR ff0084ff]M[/COLOR]etalli[COLOR ff0084ff]Q[/COLOR] " + _(
                "Music")
            source_content = "('{0}','musicvideos','metadata.musicvideos.imvdb','',2147483647,0,'<settings/>',0,0,NULL,NULL)".format(
                library_folder)
            add_source(source_name, library_folder, source_content,
                       source_thumbnail)
    # return translated path
    return xbmc.translatePath(library_folder)
Beispiel #4
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()
Beispiel #5
0
def movies_trakt_collection_to_library():
    from trakt import trakt
    if dialogs.yesno(
            _("Add all to library"),
            _("Are you sure you want to add your entire Trakt collection to Kodi library?"
              )):
        movies_add_all_to_library(trakt.trakt_get_collection("movies"))
Beispiel #6
0
def movies_trakt_watchlist_to_library():
    from trakt import trakt
    if dialogs.yesno(
            _("Add all to library"),
            _("Are you sure you want to add your entire Trakt watchlist to Kodi library?"
              )):
        movies_add_all_to_library(trakt.trakt_get_watchlist("movies"))
Beispiel #7
0
def trakt_movies_watchlist_to_library(preaprove = False, uncached = False):
    from trakt import trakt
    if preaprove  or dialogs.yesno(_("Scan item to library"), "{0}[CR]{1}".format(_("Add %s") % ("'{0} {1} {2}'".format("Trakt", _("movie"), _("Watchlist").lower())),_("Are you sure?"))):
        if uncached:
            movies_add_all_to_library(trakt.trakt_get_watchlist_uncached("movies"), True)
        else:
            movies_add_all_to_library(trakt.trakt_get_watchlist("movies"))
Beispiel #8
0
def setup_library(library_folder):
    if library_folder[-1] != "/":
        library_folder += "/"
    chappaai_playlist_folder = "special://profile/playlists/mixed/Chappaai/"
    if not xbmcvfs.exists(chappaai_playlist_folder):
        xbmcvfs.mkdir(chappaai_playlist_folder)
    playlist_folder = plugin.get_setting(SETTING_MOVIES_PLAYLIST_FOLDER,
                                         unicode)
    if plugin.get_setting(SETTING_MOVIES_PLAYLIST_FOLDER, unicode)[-1] != "/":
        playlist_folder += "/"
    # create folders
    if not xbmcvfs.exists(playlist_folder): xbmcvfs.mkdir(playlist_folder)
    if not xbmcvfs.exists(library_folder):
        # create folder
        xbmcvfs.mkdir(library_folder)
        # auto configure folder
        msg = _(
            "Would you like to automatically set Chappaai as a movies video source?"
        )
        if dialogs.yesno(_("Library setup"), msg):
            source_thumbnail = get_icon_path("movies")
            source_name = "Chappaai " + _("Movies")
            source_content = "('{0}','movies','metadata.themoviedb.org','',2147483647,1,'<settings><setting id=\"RatingS\" value=\"TMDb\" /><setting id=\"certprefix\" value=\"Rated \" /><setting id=\"fanart\" value=\"true\" /><setting id=\"keeporiginaltitle\" value=\"false\" /><setting id=\"language\" value=\"{1}\" /><setting id=\"tmdbcertcountry\" value=\"us\" /><setting id=\"trailer\" value=\"true\" /></settings>',0,0,NULL,NULL)".format(
                library_folder, LANG)
            add_source(source_name, library_folder, source_content,
                       source_thumbnail)
    # return translated path
    return xbmc.translatePath(library_folder)
Beispiel #9
0
def setup_library(library_folder):
    if library_folder[-1] != "/": library_folder += "/"
    playlist_folder = plugin.get_setting(SETTING_TV_PLAYLIST_FOLDER, unicode)
    if plugin.get_setting(SETTING_TV_PLAYLIST_FOLDER, unicode)[-1] != "/":
        playlist_folder += "/"
    if not xbmcvfs.exists(playlist_folder): xbmcvfs.mkdir(playlist_folder)
    if not xbmcvfs.exists(library_folder):
        xbmcvfs.mkdir(library_folder)
        # auto configure folder
        msg = _(
            "Would you like to automatically set [COLOR limegreen]M[/COLOR]etalli[COLOR limegreen]Q[/COLOR] 4[COLOR limegreen]Q[/COLOR]ed as a tv shows source?"
        )
        if dialogs.yesno("{0} {1}".format(_("Library"), "setup"), msg):
            try:
                source_thumbnail = get_icon_path("tv")
                source_name = "[COLOR limegreen]M[/COLOR]etalli[COLOR limegreen]Q[/COLOR] 4[COLOR limegreen]Q[/COLOR]ed " + _(
                    "TV shows")
                source_content = "('{0}','tvshows','metadata.tvdb.com','',0,0,'<settings><setting id=\"RatingS\" value=\"TheTVDB\" /><setting id=\"absolutenumber\" value=\"false\" /><setting id=\"dvdorder\" value=\"false\" /><setting id=\"fallback\" value=\"true\" /><setting id=\"fanart\" value=\"true\" /><setting id=\"language\" value=\"{1}\" /></settings>',0,0,NULL,NULL)".format(
                    library_folder, LANG)
                add_source(source_name, library_folder, source_content,
                           source_thumbnail)
            except:
                pass
    # return translated path
    return xbmc.translatePath(library_folder)
Beispiel #10
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()
Beispiel #11
0
def setup_library(library_folder):
    if library_folder[-1] != "/":
        library_folder += "/"
    playlist_folder = plugin.get_setting(SETTING_MUSIC_PLAYLIST_FOLDER,
                                         unicode)
    if plugin.get_setting(SETTING_MUSIC_PLAYLIST_FOLDER, unicode)[-1] != "/":
        playlist_folder += "/"
    # create folders
    if not xbmcvfs.exists(playlist_folder): xbmcvfs.mkdir(playlist_folder)
    if not xbmcvfs.exists(library_folder):
        # create folder
        xbmcvfs.mkdir(library_folder)
        msg = _(
            "Would you like to automatically set [COLOR limegreen]M[/COLOR]etalli[COLOR limegreen]Q[/COLOR] 4[COLOR limegreen]Q[/COLOR]ed as a music source?"
        )
        if dialogs.yesno("{0} {1}".format(_("Library"), "setup"), msg):
            source_thumbnail = get_icon_path("musicvideos")
            source_name = "[COLOR limegreen]M[/COLOR]etalli[COLOR limegreen]Q[/COLOR] 4[COLOR limegreen]Q[/COLOR]ed " + _(
                "Music videos")
            source_content = "('{0}','musicvideos','metadata.musicvideos.theaudiodb.com','',2147483647,0,'<settings><setting id=\"fanarttvalbumthumbs\" value=\"true\" /><setting id=\"tadbalbumthumbs\" value=\"true\" /></settings>',0,0,NULL,NULL)".format(
                library_folder)
            add_source(source_name, library_folder, source_content,
                       source_thumbnail)
    # return translated path
    return xbmc.translatePath(library_folder)
Beispiel #12
0
def setup_library(library_folder):
    if library_folder[-1] != "/":
        library_folder += "/"
    chappaai_playlist_folder = "special://home/playlists/mixed/Chappaai/"
    if not xbmcvfs.exists(chappaai_playlist_folder):
        xbmcvfs.mkdir(chappaai_playlist_folder)
    playlist_folder = plugin.get_setting(SETTING_LIVE_PLAYLIST_FOLDER, unicode)
    # create folders
    if not xbmcvfs.exists(playlist_folder): xbmcvfs.mkdir(playlist_folder)
    if not xbmcvfs.exists(library_folder):
        # create folder
        xbmcvfs.mkdir(library_folder)
        # auto configure folder
        msg = _(
            "Would you like to automatically set Chappaai as a channel video source?"
        )
        if dialogs.yesno("{0} {1}".format(_("Library"), "setup"), msg):
            source_thumbnail = get_icon_path("live")
            source_name = "Chappaai " + _("Channels")
            source_content = "('{0}','','','',0,0,'<settings></settings>',0,0,NULL,NULL)".format(
                library_folder)
            add_source(source_name, library_folder, source_content,
                       source_thumbnail)
    # return translated path
    return xbmc.translatePath(library_folder)
Beispiel #13
0
def setup_library(library_folder):
    if library_folder[-1] != "/":
        library_folder += "/"
    metalliq_playlist_folder = "special://profile/playlists/mixed/MetalliQ/"
    if not xbmcvfs.exists(metalliq_playlist_folder):
        xbmcvfs.mkdir(metalliq_playlist_folder)
    playlist_folder = plugin.get_setting(SETTING_MOVIES_PLAYLIST_FOLDER, converter=str)
    if plugin.get_setting(SETTING_MOVIES_PLAYLIST_FOLDER, converter=str)[-1] != "/":
        playlist_folder += "/"
    # create folders
    if not xbmcvfs.exists(playlist_folder):
        xbmcvfs.mkdir(playlist_folder)
    if not xbmcvfs.exists(library_folder):
        # create folder
        xbmcvfs.mkdir(library_folder)
        # auto configure folder
        msg = _(
            "Would you like to automatically set [COLOR ff0084ff]M[/COLOR]etalli[COLOR ff0084ff]Q[/COLOR] as a movies video source?"
        )
        if dialogs.yesno(_("Library setup"), msg):
            source_thumbnail = get_icon_path("movies")
            source_name = "[COLOR ff0084ff]M[/COLOR]etalli[COLOR ff0084ff]Q[/COLOR] " + _("Movies")
            source_content = '(\'{0}\',\'movies\',\'metadata.themoviedb.org\',\'\',2147483647,1,\'<settings><setting id="RatingS" value="TMDb" /><setting id="certprefix" value="Rated " /><setting id="fanart" value="true" /><setting id="keeporiginaltitle" value="false" /><setting id="language" value="{1}" /><setting id="tmdbcertcountry" value="us" /><setting id="trailer" value="true" /></settings>\',0,0,NULL,NULL)'.format(
                library_folder, LANG
            )
            add_source(source_name, library_folder, source_content, source_thumbnail)
    # return translated path
    return xbmc.translatePath(library_folder)
Beispiel #14
0
def trakt_movies_watchlist_to_library():
    from trakt import trakt
    if dialogs.yesno(
            _("Scan item to library"), "{0}[CR]{1}".format(
                _("Add %s") % ("'{0} {1} {2}'".format("Trakt", _("movie"),
                                                      _("Watchlist").lower())),
                _("Are you sure?"))):
        movies_add_all_to_library(trakt.trakt_get_watchlist("movies"))
Beispiel #15
0
def trakt_movies_recommendations_to_library():
    from trakt import trakt
    if dialogs.yesno(
            _("Scan item to library"), "{0}[CR]{1}".format(
                _("Add %s") %
                ("'{0} {1} {2}'".format("Trakt", _("movie"),
                                        _("Recommendations").lower())),
                _("Are you sure?"))):
        movies_add_all_to_library(trakt.get_recommendations("movies"))
Beispiel #16
0
def call_trakt(path, params={}, data=None, is_delete=False, with_auth=True, pagination = False):
    params = dict([(k, to_utf8(v)) for k, v in params.items() if v])
    
    headers = {
        'Content-Type': 'application/json',
        'trakt-api-version': '2',
        'trakt-api-key': CLIENT_ID
    }

    def send_query():
        if with_auth:
            try:
                expires_at = plugin.get_setting(SETTING_TRAKT_EXPIRES_AT, converter=int)
                if time.time() > expires_at:
                    trakt_refresh_token()
            except:
                pass
                
            token = plugin.get_setting(SETTING_TRAKT_ACCESS_TOKEN)
            if token:
                headers['Authorization'] = 'Bearer ' + token
        if data is not None:
            assert not params
            return requests.post("{0}/{1}".format(API_ENDPOINT, path), json=data, headers=headers)
        elif is_delete:
            return requests.delete("{0}/{1}".format(API_ENDPOINT, path), headers=headers)
        else:
            return requests.get("{0}/{1}".format(API_ENDPOINT, path), params, headers=headers)

    def paginated_query():
        page = 1
        lists = []
        while True:
            params['page'] = page
            results = send_query()
            if with_auth and results.status_code == 401 and dialogs.yesno(_("Authenticate Trakt"), _(
                    "You must authenticate with Trakt. Do you want to authenticate now?")) and trakt_authenticate():
                response = paginated_query()
                return response
            results.raise_for_status()
            results.encoding = 'utf-8'
            lists.extend(results.json())
            if int(results.headers["X-Pagination-Page-Count"]) <= page:
                return lists
            page += 1

    if pagination == False:
        response = send_query()
        if with_auth and response.status_code == 401 and dialogs.yesno(_("Authenticate Trakt"), _(
                "You must authenticate with Trakt. Do you want to authenticate now?")) and trakt_authenticate():
            response = send_query()
        response.raise_for_status()
        response.encoding = 'utf-8'
        return response.json()
    else:
        response = paginated_query()
        return response
Beispiel #17
0
def call_trakt(path, params={}, data=None, is_delete=False, with_auth=True, pagination = False, page = 1):
    params = dict([(k, to_utf8(v)) for k, v in params.items() if v])
    
    headers = {
        'Content-Type': 'application/json',
        'trakt-api-version': '2',
        'trakt-api-key': CLIENT_ID
    }

    def send_query():
        if with_auth:
            try:
                expires_at = plugin.get_setting(SETTING_TRAKT_EXPIRES_AT, converter=int)
                if time.time() > expires_at:
                    trakt_refresh_token()
            except:
                pass
                
            token = plugin.get_setting(SETTING_TRAKT_ACCESS_TOKEN)
            if token:
                headers['Authorization'] = 'Bearer ' + token
        if data is not None:
            assert not params
            return requests.post("{0}/{1}".format(API_ENDPOINT, path), json=data, headers=headers)
        elif is_delete:
            return requests.delete("{0}/{1}".format(API_ENDPOINT, path), headers=headers)
        else:
            return requests.get("{0}/{1}".format(API_ENDPOINT, path), params, headers=headers)

    def paginated_query(page):
        lists = []
        params['page'] = page
        results = send_query()
        if with_auth and results.status_code == 401 and dialogs.yesno(_("Authenticate Trakt"), _(
                "You must authenticate with Trakt. Do you want to authenticate now?")) and trakt_authenticate():
            response = paginated_query(1)
            return response
        results.raise_for_status()
        results.encoding = 'utf-8'
        lists.extend(results.json())
        return lists, results.headers["X-Pagination-Page-Count"]

    if pagination == False:
        response = send_query()
        if with_auth and response.status_code == 401 and dialogs.yesno(_("Authenticate Trakt"), _(
                "You must authenticate with Trakt. Do you want to authenticate now?")) and trakt_authenticate():
            response = send_query()
        response.raise_for_status()
        response.encoding = 'utf-8'
        return response.json()
    else:
        (response, numpages) = paginated_query(page)
        return response, numpages
Beispiel #18
0
 def paginated_query(page):
     lists = []
     params['page'] = page
     results = send_query()
     if with_auth and results.status_code == 401 and dialogs.yesno(_("Authenticate Trakt"), _(
             "You must authenticate with Trakt. Do you want to authenticate now?")) and trakt_authenticate():
         response = paginated_query(1)
         return response
     results.raise_for_status()
     results.encoding = 'utf-8'
     lists.extend(results.json())
     return lists, results.headers["X-Pagination-Page-Count"]
Beispiel #19
0
 def paginated_query(page):
     lists = []
     params['page'] = page
     results = send_query()
     if with_auth and results.status_code == 401 and dialogs.yesno(_("Authenticate Trakt"), _(
             "You must authenticate with Trakt. Do you want to authenticate now?")) and trakt_authenticate():
         response = paginated_query()
         return response
     results.raise_for_status()
     results.encoding = 'utf-8'
     lists.extend(results.json())
     return lists, results.headers["X-Pagination-Page-Count"]
Beispiel #20
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()
Beispiel #21
0
def flat_extract(z, extract_to, members=None):
    if members is None:
        members = z.namelist()

    if not os.path.exists(extract_to):
        os.makedirs(extract_to)
    else:
        if dialogs.yesno(_("Update players"), _("Do you want to remove your existing players first?")):
            empty_folder(extract_to)
        
    for member in members:
        with contextlib.closing(z.open(member)) as source:
            target_path = os.path.join(extract_to, os.path.basename(member))
            with open(target_path, "wb") as target:
                shutil.copyfileobj(source, target)
Beispiel #22
0
def flat_extract(z, extract_to, members=None):
    if members is None:
        members = z.namelist()

    if not os.path.exists(extract_to):
        os.makedirs(extract_to)
    else:
        if dialogs.yesno(_("Update players"), _("Do you want to remove your existing players first?")):
            empty_folder(extract_to)
        
    for member in members:
        with contextlib.closing(z.open(member)) as source:
            target_path = os.path.join(extract_to, os.path.basename(member))
            with open(target_path, "wb") as target:
                shutil.copyfileobj(source, target)
Beispiel #23
0
def setup_library(library_folder):
    if library_folder[-1] != "/": library_folder += "/"
    playlist_folder = plugin.get_setting(SETTING_TV_PLAYLIST_FOLDER, unicode)
    if plugin.get_setting(SETTING_TV_PLAYLIST_FOLDER, unicode)[-1] != "/": playlist_folder += "/"
    if not xbmcvfs.exists(playlist_folder): xbmcvfs.mkdir(playlist_folder)
    if not xbmcvfs.exists(library_folder):
        xbmcvfs.mkdir(library_folder)
        # auto configure folder
        msg = _("Would you like to automatically set [COLOR ff0084ff]M[/COLOR]etalli[COLOR ff0084ff]Q[/COLOR] as a tv shows source?")
        if dialogs.yesno("{0} {1}".format(_("Library"), "setup"), msg):
            try:
                source_thumbnail = get_icon_path("tv")
                source_name = "[COLOR ff0084ff]M[/COLOR]etalli[COLOR ff0084ff]Q[/COLOR] " + _("TV shows")
                source_content = "('{0}','tvshows','metadata.tvdb.com','',0,0,'<settings><setting id=\"RatingS\" value=\"TheTVDB\" /><setting id=\"absolutenumber\" value=\"false\" /><setting id=\"dvdorder\" value=\"false\" /><setting id=\"fallback\" value=\"true\" /><setting id=\"fanart\" value=\"true\" /><setting id=\"language\" value=\"{1}\" /></settings>',0,0,NULL,NULL)".format(library_folder, LANG)
                add_source(source_name, library_folder, source_content, source_thumbnail)
            except: pass
    # return translated path
    return xbmc.translatePath(library_folder)
Beispiel #24
0
def setup_library(library_folder):
    if library_folder[-1] != "/":
        library_folder += "/"

    if not xbmcvfs.exists(library_folder):
        # create folder
        xbmcvfs.mkdir(library_folder)
        
        # auto configure folder
        msg = _("Would you like to automatically set Meta as a movies video source?")
        if dialogs.yesno(_("Library setup"), msg):
            source_name = "Meta Movies"
            
            source_content = "('{0}','movies','metadata.themoviedb.org','',2147483647,0,'<settings><setting id=\"RatingS\" value=\"TMDb\" /><setting id=\"certprefix\" value=\"Rated \" /><setting id=\"fanart\" value=\"true\" /><setting id=\"keeporiginaltitle\" value=\"false\" /><setting id=\"language\" value=\"{1}\" /><setting id=\"tmdbcertcountry\" value=\"us\" /><setting id=\"trailer\" value=\"true\" /></settings>',0,0,NULL,NULL)".format(library_folder, LANG)

            add_source(source_name, library_folder, source_content)

    # return translated path
    return xbmc.translatePath(library_folder)
Beispiel #25
0
def setup_library(library_folder):
    if library_folder[-1] != "/":
        library_folder += "/"

    if not xbmcvfs.exists(library_folder):
        # create folder
        xbmcvfs.mkdir(library_folder)
        
        # auto configure folder
        msg = _("Would you like to automatically set Meta as a tv shows source?")
        if dialogs.yesno(_("Library setup"), msg):
            source_name = "Meta TVShows"
            
            source_content = "('{0}','tvshows','metadata.tvdb.com','',0,0,'<settings><setting id=\"RatingS\" value=\"TheTVDB\" /><setting id=\"absolutenumber\" value=\"false\" /><setting id=\"dvdorder\" value=\"false\" /><setting id=\"fallback\" value=\"true\" /><setting id=\"fanart\" value=\"true\" /><setting id=\"language\" value=\"{1}\" /></settings>',0,0,NULL,NULL)".format(library_folder, LANG)

            add_source(source_name, library_folder, source_content)

    # return translated path
    return xbmc.translatePath(library_folder)
Beispiel #26
0
def setup_library(library_folder):
    if library_folder[-1] != "/":
        library_folder += "/"
    metalliq_playlist_folder = "special://profile/playlists/mixed/MetalliQ/"
    if not xbmcvfs.exists(metalliq_playlist_folder): xbmcvfs.mkdir(metalliq_playlist_folder)
    playlist_folder = plugin.get_setting(SETTING_MUSIC_PLAYLIST_FOLDER, unicode)
    if plugin.get_setting(SETTING_MUSIC_PLAYLIST_FOLDER, unicode)[-1] != "/": playlist_folder += "/"
    # create folders
    if not xbmcvfs.exists(playlist_folder): xbmcvfs.mkdir(playlist_folder)
    if not xbmcvfs.exists(library_folder):
        # create folder
        xbmcvfs.mkdir(library_folder)
        msg = _("Would you like to automatically set [COLOR ff0084ff]M[/COLOR]etalli[COLOR ff0084ff]Q[/COLOR] as a music source?")
        if dialogs.yesno("{0} {1}".format(_("Library"), "setup"), msg):
            source_thumbnail = get_icon_path("tv")
            source_name = "[COLOR ff0084ff]M[/COLOR]etalli[COLOR ff0084ff]Q[/COLOR] "  + _("Music")
            source_content = "('{0}','musicvideos','metadata.musicvideos.imvdb','',2147483647,0,'<settings/>',0,0,NULL,NULL)".format(library_folder)
            add_source(source_name, library_folder, source_content, source_thumbnail)
    # return translated path
    return xbmc.translatePath(library_folder)
Beispiel #27
0
def setup_library(library_folder):
    if library_folder[-1] != "/":
        library_folder += "/"
    metalliq_playlist_folder = "special://profile/playlists/mixed/MetalliQ/"
    if not xbmcvfs.exists(metalliq_playlist_folder): xbmcvfs.mkdir(metalliq_playlist_folder)
    playlist_folder = plugin.get_setting(SETTING_LIVE_PLAYLIST_FOLDER, converter=str)
    # create folders
    if not xbmcvfs.exists(playlist_folder): xbmcvfs.mkdir(playlist_folder)
    if not xbmcvfs.exists(library_folder):
        # create folder
        xbmcvfs.mkdir(library_folder)
        # auto configure folder
        msg = _("Would you like to automatically set [COLOR ff0084ff]M[/COLOR]etalli[COLOR ff0084ff]Q[/COLOR] as a channel video source?")
        if dialogs.yesno(_("Library setup"), msg):
            source_thumbnail = get_icon_path("live")
            source_name = "[COLOR ff0084ff]M[/COLOR]etalli[COLOR ff0084ff]Q[/COLOR] " + _("Channels")
            source_content = "('{0}','','','',0,0,'<settings></settings>',0,0,NULL,NULL)".format(library_folder)
            add_source(source_name, library_folder, source_content, source_thumbnail)
    # return translated path
    return xbmc.translatePath(library_folder)
Beispiel #28
0
def call_trakt(path, params={}, data=None, is_delete=False, with_auth=True):
    params = dict([(k, to_utf8(v)) for k, v in params.items() if v])

    headers = {"Content-Type": "application/json", "trakt-api-version": "2", "trakt-api-key": CLIENT_ID}

    def send_query():
        if with_auth:
            try:
                expires_at = plugin.get_setting(SETTING_TRAKT_EXPIRES_AT, converter=int)
                if time.time() > expires_at:
                    trakt_refresh_token()
            except:
                pass

            token = plugin.get_setting(SETTING_TRAKT_ACCESS_TOKEN)
            if token:
                headers["Authorization"] = "Bearer " + token
        if data is not None:
            assert not params
            return requests.post("{0}/{1}".format(API_ENDPOINT, path), json=data, headers=headers)
        elif is_delete:
            return requests.delete("{0}/{1}".format(API_ENDPOINT, path), headers=headers)
        else:
            return requests.get("{0}/{1}".format(API_ENDPOINT, path), params, headers=headers)

    response = send_query()
    if (
        with_auth
        and response.status_code == 401
        and dialogs.yesno(
            _("Authenticate Trakt"), _("You must authenticate with Trakt. Do you want to authenticate now?")
        )
        and trakt_authenticate()
    ):
        response = send_query()

    response.raise_for_status()
    response.encoding = "utf-8"
    return response.json()
Beispiel #29
0
def setup_library(library_folder):
    if library_folder[-1] != "/":
        library_folder += "/"

    if not xbmcvfs.exists(library_folder):
        # create folder
        xbmcvfs.mkdir(library_folder)

        # auto configure folder
        msg = _(
            "Would you like to automatically set Meta as a movies video source?"
        )
        if dialogs.yesno(_("Library setup"), msg):
            source_name = "Meta Movies"

            source_content = "('{0}','movies','metadata.themoviedb.org','',2147483647,0,'<settings><setting id=\"RatingS\" value=\"TMDb\" /><setting id=\"certprefix\" value=\"Rated \" /><setting id=\"fanart\" value=\"true\" /><setting id=\"keeporiginaltitle\" value=\"false\" /><setting id=\"language\" value=\"{1}\" /><setting id=\"tmdbcertcountry\" value=\"us\" /><setting id=\"trailer\" value=\"true\" /></settings>',0,0,NULL,NULL)".format(
                library_folder, LANG)

            add_source(source_name, library_folder, source_content)

    # return translated path
    return xbmc.translatePath(library_folder)
Beispiel #30
0
def setup_library(library_folder):
    if library_folder[-1] != "/":
        library_folder += "/"
    metalliq_playlist_folder = "special://profile/playlists/mixed/MetalliQ/"
    if not xbmcvfs.exists(metalliq_playlist_folder):
        xbmcvfs.mkdir(metalliq_playlist_folder)
    playlist_folder = plugin.get_setting(SETTING_LIVE_PLAYLIST_FOLDER, converter=str)
    # create folders
    if not xbmcvfs.exists(playlist_folder):
        xbmcvfs.mkdir(playlist_folder)
    if not xbmcvfs.exists(library_folder):
        # create folder
        xbmcvfs.mkdir(library_folder)
        # auto configure folder
        msg = _(
            "Would you like to automatically set [COLOR ff0084ff]M[/COLOR]etalli[COLOR ff0084ff]Q[/COLOR] as a channel video source?"
        )
        if dialogs.yesno(_("Library setup"), msg):
            source_thumbnail = get_icon_path("live")
            source_name = "[COLOR ff0084ff]M[/COLOR]etalli[COLOR ff0084ff]Q[/COLOR] " + _("Channels")
            source_content = "('{0}','','','',0,0,'<settings></settings>',0,0,NULL,NULL)".format(library_folder)
            add_source(source_name, library_folder, source_content, source_thumbnail)
    # return translated path
    return xbmc.translatePath(library_folder)
Beispiel #31
0
def settings_set_players(media):
    playericon = get_icon_path("player")
    medias = ["movies", "tvshows", "musicvideos", "music", "live"]
    if media == "all":
        for med in medias:
            mediatype = med.replace('es', 'e').replace('ws', 'w').replace(
                'all', '').replace('os', 'o').replace('vs', 'v s').replace(
                    'tv', 'TV').replace('musicvideo',
                                        'Music video').replace('live', 'TV')
            players = get_players(med)
            selected = [p.id for p in players]
            if selected is not None:
                if med == "movies":
                    plugin.set_setting(SETTING_MOVIES_ENABLED_PLAYERS,
                                       selected)
                elif med == "tvshows":
                    plugin.set_setting(SETTING_TV_ENABLED_PLAYERS, selected)
                elif med == "musicvideos":
                    plugin.set_setting(SETTING_MUSICVIDEOS_ENABLED_PLAYERS,
                                       selected)
                elif med == "music":
                    plugin.set_setting(SETTING_MUSIC_ENABLED_PLAYERS, selected)
                elif med == "live":
                    plugin.set_setting(SETTING_LIVE_ENABLED_PLAYERS, selected)
                else:
                    raise Exception("invalid parameter %s" % media)
            dialogs.notify(msg="{0} {1}".format(
                _(mediatype).capitalize(),
                _("Player").lower()),
                           title=_('Enabled'),
                           delay=1000,
                           image=get_icon_path("player"))
        dialogs.notify(msg="{0}".format(_("Player")),
                       title="{0} {1}".format(_("All"),
                                              _('Enabled').lower()),
                       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('os', 'o').replace('vs', 'v s').replace(
                'tv', 'TV').replace('musicvideo',
                                    'Music video').replace('live', 'TV')
        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(
                    "{0} {1} {2} {3}s".format(_("Enable"),
                                              _("All").lower(), mediatype,
                                              _("Player").lower()), _(msg)):
                selected = [p.id for p in players]
            else:
                result = dialogs.multichoice(
                    "{0}: {1} {2} {3}".format(_("Enable"), _("Select"),
                                              _("Player").lower()),
                    [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)
        dialogs.notify(msg="{0} {1} {2}".format(_("Enable"),
                                                _(mediatype).lower(),
                                                _("Player").lower()),
                       title=_('Done'),
                       delay=1000,
                       image=get_icon_path("player"))
    plugin.open_settings()
Beispiel #32
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()
Beispiel #33
0
def patch(mode):
    import xbmcaddon
    adir = "special://home/addons/"
    AUTOS = eval(plugin.get_setting(SETTING_AUTOPATCHES, unicode))
    #    try: AUTOS = plugin.get_setting(SETTING_AUTOPATCHES, unicode)
    #    except: AUTOS = [[], [], [], []]
    #    return [p for p in get_players() if p.id in AUTOS]
    #    xbmc.log("QQQQQ AUTOS = {0}".format(str(AUTOS)), xbmc.LOGNOTICE)
    INSTALLED = [i for i in xbmcvfs.listdir(adir)[0]]
    PATCHES = [
        [], ["resources/lib/modules/control.py", "pass", "sys.exit()"],
        [
            "default.py", "",
            "\n    cool_down_active = kodi.get_setting('cool_down') == 'true'\n    if not salts_utils.is_salts() or cool_down_active:\n        kodi.notify(msg=i18n('playback_limited'))\n        return False"
        ],
        [
            "lib/dudehere/routines/scrapers/__init__.py", "",
            "\n\t\tif self._caller not in ALLOWED_CALLERS and self._caller: \n\t\t\tplugin.log('Caller not allowed')\n\t\t\tplugin.raise_error('Violation', 'This addon is not allowed.', 'Please do not use %s with %s' % (self._caller, ADDON_NAME))\n\t\t\tif return_sources:\n\t\t\t\treturn [], [], []\n\t\t\telse:\n\t\t\t\treturn []"
        ]
    ]
    if mode == "auto":
        if AUTOS != [[], [], [], []]:
            ADDONS = AUTOS
        else:
            if dialogs.yesno(
                    '{0}: Patch'.format(plugin.name),
                    '{0}.[CR]{1} & {2}'.format(
                        _("%s not found") % 'Auto-patches', _("Enable"),
                        _("Continue?"))):
                return patch("all")
            else:
                plugin.set_setting(SETTING_AUTOPATCH, "false")
                return
    else:
        ADDONS = [
            [],
            [
                i for i in INSTALLED if i.startswith("plugin.video.")
                and xbmcvfs.exists("{0}{1}/{2}".format(adir, i, PATCHES[1][0]))
            ],
            [
                i for i in INSTALLED if i.startswith("plugin.video.")
                and xbmcvfs.exists("{0}{1}/{2}".format(adir, i, PATCHES[2][0]))
            ],
            [
                i for i in INSTALLED if i.startswith("script.module.")
                and xbmcvfs.exists("{0}{1}/{2}".format(adir, i, PATCHES[3][0]))
            ]
        ]
    count = 0
    for i in range(1, len(ADDONS)):
        for a in ADDONS[i]:
            count = count + 1
            b = "{0}{1}/{2}".format(adir, a, PATCHES[i][0])
            c = xbmcvfs.File(b)
            d = c.read()
            c.close()
            if PATCHES[i][2] in d:
                ADDON = xbmcaddon.Addon(a)
                if mode == "auto" or dialogs.yesno(
                        '{0}: Patch "{1}"?'.format(plugin.name,
                                                   ADDON.getAddonInfo("name")),
                        '"{0}" {1} block-code.[CR]{2}'.format(
                            ADDON.getAddonInfo("name"), _("contains"),
                            _("Would you like to remove it from the library?").
                            replace(_("Library").lower(),
                                    _("Add-on").lower()))):
                    h = xbmcvfs.File(b, 'w')
                    d = d.replace(PATCHES[i][2], PATCHES[i][1])
                    result = h.write(d)
                    h.close()
                    if mode != "auto" and dialogs.yesno(
                            "{0}: {1} Patch?".format(plugin.name, _("Auto")),
                            '"{0}"[CR]{1} {2} re-patching?'.format(
                                ADDON.getAddonInfo("name"), _("Enable"),
                                _("Auto").lower())):
                        if ADDON.getAddonInfo("id") not in AUTOS[i]:
                            AUTOS[i].append(ADDON.getAddonInfo("id"))
    if AUTOS != [[], [], [], []] and AUTOS != ADDONS:
        plugin.set_setting(SETTING_AUTOPATCHES, AUTOS)
Beispiel #34
0
def clear_trakt():
    msg = "{0} {1} {2}?".format(_("Remove"), "Trakt", _("Settings").lower())
    if dialogs.yesno("{0} {1}".format(_("Unlock"), "Trakt"), msg):
        plugin.set_setting(SETTING_TRAKT_ACCESS_TOKEN, "")
        plugin.set_setting(SETTING_TRAKT_REFRESH_TOKEN, "")
        plugin.set_setting(SETTING_TRAKT_EXPIRES_AT, "")
Beispiel #35
0
def settings_set_players(media):
    playericon = get_icon_path("player")
    medias = ["movies","tvshows","musicvideos","music","live"]
    if media == "all":
        for med in medias:
            mediatype = med.replace('es','e').replace('ws','w').replace('all','').replace('os','o').replace('vs','v s').replace('tv','TV').replace('musicvideo','Music video').replace('live','TV')
            players = get_players(med)
            selected = [p.id for p in players]
            if selected is not None:
                if med == "movies":
                    plugin.set_setting(SETTING_MOVIES_ENABLED_PLAYERS, selected)
                elif med == "tvshows":
                    plugin.set_setting(SETTING_TV_ENABLED_PLAYERS, selected)
                elif med == "musicvideos":
                    plugin.set_setting(SETTING_MUSICVIDEOS_ENABLED_PLAYERS, selected)
                elif med == "music":
                    plugin.set_setting(SETTING_MUSIC_ENABLED_PLAYERS, selected)
                elif med == "live":
                    plugin.set_setting(SETTING_LIVE_ENABLED_PLAYERS, selected)
                else:
                    raise Exception("invalid parameter %s" % media)
            dialogs.notify(msg="{0} {1}".format(_(mediatype).capitalize(), _("Player").lower()), title=_('Enabled'), delay=1000, image=get_icon_path("player"))
        dialogs.notify(msg="{0}".format(_("Player")), title="{0} {1}".format(_("All"), _('Enabled').lower()), 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('os','o').replace('vs','v s').replace('tv','TV').replace('musicvideo','Music video').replace('live','TV')
        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("{0} {1} {2} {3}s".format(_("Enable"), _("All").lower(), mediatype, _("Player").lower()), _(msg)):
                selected = [p.id for p in players]
            else:
                result = dialogs.multichoice("{0}: {1} {2} {3}".format(_("Enable"), _("Select"), _("Player").lower()), [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)
        dialogs.notify(msg="{0} {1} {2}".format(_("Enable"), _(mediatype).lower(), _("Player").lower()), title=_('Done'), delay=1000, image=get_icon_path("player"))
    plugin.open_settings()
Beispiel #36
0
def settings_set_players(media):
    playericon = get_icon_path("player")
    if media == "all":
        medias = ["live"]
        for media in medias:
            mediatype = media.replace('es', 'e').replace('ws', 'w').replace(
                '_', '').replace('all', '').replace('ve', 've')
            players = get_players(media)
            selected = [p.id for p in players]
            if selected is not None:
                if media == "live":
                    plugin.set_setting(SETTING_LIVE_ENABLED_PLAYERS, selected)
                else:
                    raise Exception("invalid parameter %s" % media)
            plugin.notify(msg=_('cCloudMeta Enabled'),
                          title=_('Enabled'),
                          delay=1000,
                          image=get_icon_path("icon"))
        plugin.notify(msg=_('cCloudMeta'),
                      title=_('Enabled'),
                      delay=1000,
                      image=get_icon_path("icon"))
        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 == "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"))
Beispiel #37
0
def trakt_movies_recommendations_to_library():
    from trakt import trakt
    if dialogs.yesno(_("Scan item to library"), "{0}[CR]{1}".format(_("Add %s") % ("'{0} {1} {2}'".format("Trakt", _("movie"), _("Recommendations").lower())),_("Are you sure?"))):
        movies_add_all_to_library(trakt.get_recommendations("movies"))
Beispiel #38
0
def movies_trakt_watchlist_to_library():
    from trakt import trakt
    if dialogs.yesno(_("Add all to library"), _("Are you sure you want to add your entire Trakt watchlist to Kodi library?")):
        movies_add_all_to_library(trakt.trakt_get_watchlist("movies"))
Beispiel #39
0
def movies_trakt_collection_to_library():
    from trakt import trakt
    if dialogs.yesno(_("Add all to library"), _("Are you sure you want to add your entire Trakt collection to Kodi library?")):
        movies_add_all_to_library(trakt.trakt_get_collection("movies"))
Beispiel #40
0
def clear_trakt():
    msg = "{0} {1} {2}?".format(_("Remove"), "Trakt", _("Settings").lower())
    if dialogs.yesno("{0} {1}".format(_("Unlock"), "Trakt"), msg):
        plugin.set_setting(SETTING_TRAKT_ACCESS_TOKEN, "")
        plugin.set_setting(SETTING_TRAKT_REFRESH_TOKEN, "")
        plugin.set_setting(SETTING_TRAKT_EXPIRES_AT, "")