Python xbmc 模块,getLocalizedString() 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用xbmc.getLocalizedString()

项目:script.skin.helper.skinbackup    作者:marcelveldt    | 项目源码 | 文件源码
def daynightthemes(self, dayornight):
        '''allow user to set a specific theme during day/night time'''

        if dayornight not in ["day", "night"]:
            log_msg("Invalid parameter for day/night theme - must be day or night")
            return

        # show listing with themes
        listitems = self.get_skin_colorthemes()
        listitems += self.get_user_colorthemes()
        header = self.addon.getLocalizedString(32031)
        curvalue = xbmc.getInfoLabel("Skin.String(SkinHelper.ColorTheme.%s.theme)" % dayornight).decode("utf-8")
        dialog = DialogSelect("DialogSelect.xml", "", windowtitle=header,
                              richlayout=True, listing=listitems, autofocus=curvalue)
        dialog.doModal()
        result = dialog.result
        del dialog
        if result:
            themefile = result.getfilename().decode("utf-8")
            themename = result.getLabel().decode("utf-8")
            self.set_day_night_theme(dayornight, themename, themefile)
项目:script.skin.helper.skinbackup    作者:marcelveldt    | 项目源码 | 文件源码
def set_day_night_theme(self, dayornight, themename, themefile):
        ''' Sets a new daynight theme'''
        currenttimevalue = xbmc.getInfoLabel("Skin.String(SkinHelper.ColorTheme.%s.time)" % dayornight)
        if not currenttimevalue:
            currenttimevalue = "20:00" if dayornight == "night" else "07:00"
        timevalue = xbmcgui.Dialog().input(self.addon.getLocalizedString(32017),
                                           currenttimevalue).decode("utf-8")
        try:
            # check if the time is valid
            check_date = datetime(*(time.strptime(timevalue, "%H:%M")[0:6]))
            del check_date
            base_setting = "SkinHelper.ColorTheme.%s" % dayornight
            xbmc.executebuiltin("Skin.SetString(%s.theme,%s)" % (base_setting, themename.encode("utf-8")))
            xbmc.executebuiltin("Skin.SetString(%s.time,%s)" % (base_setting, timevalue))
            label = "%s  (%s %s)" % (themename.encode("utf-8"), self.addon.getLocalizedString(32019), timevalue)
            xbmc.executebuiltin("Skin.SetString(%s.label,%s)" % (base_setting, label))
            xbmc.executebuiltin("Skin.SetString(%s.file,%s)" % (base_setting, themefile.encode("utf-8")))
        except Exception as exc:
            log_exception(__name__, exc)
            xbmcgui.Dialog().ok(xbmc.getLocalizedString(329), self.addon.getLocalizedString(32018))
项目:script.skin.helper.skinbackup    作者:marcelveldt    | 项目源码 | 文件源码
def backup_theme(self, themename):
        '''backup a colortheme to a zipfile'''
        import zipfile
        backup_path = xbmcgui.Dialog().browse(3, self.addon.getLocalizedString(32029), "files").decode("utf-8")
        if backup_path:
            xbmc.executebuiltin("ActivateWindow(busydialog)")
            backup_name = u"%s ColorTheme - %s" % (get_skin_name().capitalize(), themename)
            backupfile = os.path.join(backup_path, backup_name + u".zip")
            zip_temp = u'special://temp/%s.zip' % backup_name
            xbmcvfs.delete(zip_temp)
            xbmcvfs.delete(backupfile)
            zip_temp = xbmc.translatePath(zip_temp).decode("utf-8")
            zip_file = zipfile.ZipFile(zip_temp, "w", zipfile.ZIP_DEFLATED)
            abs_src = os.path.abspath(xbmc.translatePath(self.userthemes_path).decode("utf-8"))
            for filename in xbmcvfs.listdir(self.userthemes_path)[1]:
                if (filename.startswith("%s_" % themename) or
                        filename.replace(".theme", "").replace(".jpg", "") == themename):
                    filename = filename.decode("utf-8")
                    filepath = xbmc.translatePath(self.userthemes_path + filename).decode("utf-8")
                    absname = os.path.abspath(filepath)
                    arcname = absname[len(abs_src) + 1:]
                    zip_file.write(absname, arcname)
            zip_file.close()
            xbmcvfs.copy(zip_temp, backupfile)
            xbmc.executebuiltin("Dialog.Close(busydialog)")
项目:script.skin.helper.skinbackup    作者:marcelveldt    | 项目源码 | 文件源码
def get_user_colorthemes(self):
        '''get all user stored color themes as listitems'''
        listitems = []
        for file in xbmcvfs.listdir(self.userthemes_path)[1]:
            if file.endswith(".theme"):
                file = file.decode("utf-8")
                themefile = self.userthemes_path + file
                label = file.replace(".theme", "")
                icon = themefile.replace(".theme", ".jpg")
                if not xbmcvfs.exists(icon):
                    icon = ""
                desc = "user defined theme"
                if label == self.get_activetheme():
                    desc = xbmc.getLocalizedString(461)
                listitem = xbmcgui.ListItem(label, iconImage=icon)
                listitem.setLabel2(desc)
                listitem.setPath(themefile)
                listitems.append(listitem)
        return listitems
项目:script.skin.helper.skinbackup    作者:marcelveldt    | 项目源码 | 文件源码
def restore_colortheme(self):
        '''restore zipbackup of colortheme to colorthemes folder'''
        zip_path = xbmcgui.Dialog().browse(1, self.addon.getLocalizedString(32030), "files", ".zip")
        if zip_path and zip_path.endswith(".zip"):

            # create temp path
            temp_path = u'special://temp/skinbackup/'
            temp_zip = u"special://temp/colortheme.zip"
            if xbmcvfs.exists(temp_path):
                recursive_delete_dir(temp_path)
            xbmcvfs.mkdir(temp_path)

            # unzip to temp
            xbmcvfs.copy(zip_path, temp_zip)
            unzip_fromfile(temp_zip, temp_path)
            for filename in xbmcvfs.listdir(temp_path)[1]:
                filename = filename.decode("utf-8")
                sourcefile = os.path.join(temp_path, filename)
                destfile = os.path.join(self.userthemes_path, filename)
                xbmcvfs.copy(sourcefile, destfile)
            # cleanup temp
            xbmcvfs.delete(temp_zip)
            recursive_delete_dir(temp_path)
            xbmcgui.Dialog().ok(self.addon.getLocalizedString(32026), self.addon.getLocalizedString(32027))
项目:plugin.audio.spotify    作者:marcelveldt    | 项目源码 | 文件源码
def set_playback_device(self):
        '''set the active playback device'''
        deviceid = self.params["deviceid"][0]
        if deviceid == "local":
            self.addon.setSetting("playback_device", "local")
        elif deviceid == "remote":
            headertxt = self.addon.getLocalizedString(11039)
            bodytxt = self.addon.getLocalizedString(11061)
            dialog = xbmcgui.Dialog()
            dialog.textviewer(headertxt, bodytxt)
            result = dialog.input(self.addon.getLocalizedString(11062))
            if result:
                self.addon.setSetting("playback_device", "remote")
                self.addon.setSetting("connect_id", result)
            del dialog
        elif deviceid == "squeezebox":
            self.addon.setSetting("playback_device", "squeezebox")
        else:
            self.sp.transfer_playback(deviceid, False)
            self.addon.setSetting("playback_device", "connect")
            self.addon.setSetting("connect_id", deviceid)
        xbmc.executebuiltin("Container.Refresh")
项目:plugin.audio.spotify    作者:marcelveldt    | 项目源码 | 文件源码
def search_artists(self):
        xbmcplugin.setContent(self.addon_handle, "artists")
        xbmcplugin.setProperty(self.addon_handle, 'FolderName', xbmc.getLocalizedString(133))
        result = self.sp.search(
            q="artist:%s" %
            self.artistid,
            type='artist',
            limit=self.limit,
            offset=self.offset,
            market=self.usercountry)
        artists = self.prepare_artist_listitems(result['artists']['items'])
        self.add_artist_listitems(artists)
        self.add_next_button(result['artists']['total'])
        xbmcplugin.addSortMethod(self.addon_handle, xbmcplugin.SORT_METHOD_UNSORTED)
        xbmcplugin.endOfDirectory(handle=self.addon_handle)
        if self.defaultview_artists:
            xbmc.executebuiltin('Container.SetViewMode(%s)' % self.defaultview_artists)
项目:plugin.audio.spotify    作者:marcelveldt    | 项目源码 | 文件源码
def search_tracks(self):
        xbmcplugin.setContent(self.addon_handle, "songs")
        xbmcplugin.setProperty(self.addon_handle, 'FolderName', xbmc.getLocalizedString(134))
        result = self.sp.search(
            q="track:%s" %
            self.trackid,
            type='track',
            limit=self.limit,
            offset=self.offset,
            market=self.usercountry)
        tracks = self.prepare_track_listitems(tracks=result["tracks"]["items"])
        self.add_track_listitems(tracks, True)
        self.add_next_button(result['tracks']['total'])
        xbmcplugin.addSortMethod(self.addon_handle, xbmcplugin.SORT_METHOD_UNSORTED)
        xbmcplugin.endOfDirectory(handle=self.addon_handle)
        if self.defaultview_songs:
            xbmc.executebuiltin('Container.SetViewMode(%s)' % self.defaultview_songs)
项目:plugin.audio.spotify    作者:marcelveldt    | 项目源码 | 文件源码
def search_playlists(self):
        xbmcplugin.setContent(self.addon_handle, "files")
        result = self.sp.search(
            q=self.playlistid,
            type='playlist',
            limit=self.limit,
            offset=self.offset,
            market=self.usercountry)
        log_msg(result)
        xbmcplugin.setProperty(self.addon_handle, 'FolderName', xbmc.getLocalizedString(136))
        playlists = self.prepare_playlist_listitems(result['playlists']['items'])
        self.add_playlist_listitems(playlists)
        self.add_next_button(result['playlists']['total'])
        xbmcplugin.endOfDirectory(handle=self.addon_handle)
        if self.defaultview_playlists:
            xbmc.executebuiltin('Container.SetViewMode(%s)' % self.defaultview_playlists)
项目:plugin.audio.spotify    作者:marcelveldt    | 项目源码 | 文件源码
def add_next_button(self, listtotal):
        # adds a next button if needed
        params = self.params
        if listtotal > self.offset + self.limit:
            params["offset"] = self.offset + self.limit
            url = "plugin://plugin.audio.spotify/"
            for key, value in params.iteritems():
                if key == "action":
                    url += "?%s=%s" % (key, value[0])
                elif key == "offset":
                    url += "&%s=%s" % (key, value)
                else:
                    url += "&%s=%s" % (key, value[0])
            li = xbmcgui.ListItem(
                xbmc.getLocalizedString(33078),
                path=url,
                iconImage="DefaultMusicAlbums.png"
            )
            li.setProperty('do_not_analyze', 'true')
            li.setProperty('IsPlayable', 'false')
            xbmcplugin.addDirectoryItem(handle=self.addon_handle, url=url, listitem=li, isFolder=True)
项目:script.module.metadatautils    作者:marcelveldt    | 项目源码 | 文件源码
def music_artwork_options(self, artist, album, track, disc):
        '''show options for music artwork'''
        options = []
        options.append(self._mutils.addon.getLocalizedString(32028))  # Refresh item (auto lookup)
        options.append(self._mutils.addon.getLocalizedString(32036))  # Choose art
        options.append(self._mutils.addon.getLocalizedString(32034))  # Open addon settings
        header = self._mutils.addon.getLocalizedString(32015)
        dialog = xbmcgui.Dialog()
        ret = dialog.select(header, options)
        del dialog
        if ret == 0:
            # Refresh item (auto lookup)
            self.get_music_artwork(artist, album, track, disc, ignore_cache=True)
        elif ret == 1:
            # Choose art
            self.get_music_artwork(artist, album, track, disc, ignore_cache=True, manual=True)
        elif ret == 2:
            # Open addon settings
            xbmc.executebuiltin("Addon.OpenSettings(%s)" % ADDON_ID)
项目:plugin.video.youtube    作者:jdf76    | 项目源码 | 文件源码
def localize(self, text_id, default_text=u''):
        if isinstance(text_id, int):
            """
            We want to use all localization strings!
            Addons should only use the range 30000 thru 30999 (see: http://kodi.wiki/view/Language_support) but we
            do it anyway. I want some of the localized strings for the views of a skin.
            """
            if text_id >= 0 and (text_id < 30000 or text_id > 30999):
                result = xbmc.getLocalizedString(text_id)
                if result is not None and result:
                    return utils.to_unicode(result)

        result = self._addon.getLocalizedString(int(text_id))
        if result is not None and result:
            return utils.to_unicode(result)

        return utils.to_unicode(default_text)
项目:plugin.video.youtube    作者:Kolifanes    | 项目源码 | 文件源码
def localize(self, text_id, default_text=u''):
        if isinstance(text_id, int):
            """
            We want to use all localization strings!
            Addons should only use the range 30000 thru 30999 (see: http://kodi.wiki/view/Language_support) but we
            do it anyway. I want some of the localized strings for the views of a skin.
            """
            if text_id >= 0 and (text_id < 30000 or text_id > 30999):
                result = xbmc.getLocalizedString(text_id)
                if result is not None and result:
                    return utils.to_unicode(result)
                pass
            pass

        result = self._addon.getLocalizedString(int(text_id))
        if result is not None and result:
            return utils.to_unicode(result)

        return utils.to_unicode(default_text)
项目:plugin.video.exodus    作者:lastship    | 项目源码 | 文件源码
def get(version):
    try:
        import xbmc,xbmcgui,xbmcaddon,xbmcvfs

        f = xbmcvfs.File(xbmcaddon.Addon().getAddonInfo('changelog'))
        text = f.read() ; f.close()

        label = '%s - %s' % (xbmc.getLocalizedString(24054), xbmcaddon.Addon().getAddonInfo('name'))

        id = 10147

        xbmc.executebuiltin('ActivateWindow(%d)' % id)
        xbmc.sleep(100)

        win = xbmcgui.Window(id)

        retry = 50
        while (retry > 0):
            try:
                xbmc.sleep(10)
                win.getControl(1).setLabel(label)
                win.getControl(5).setText(text)
                retry = 0
            except:
                retry -= 1

        return '1'
    except:
        return '1'
项目:script.skin.helper.skinbackup    作者:marcelveldt    | 项目源码 | 文件源码
def set_icon_for_theme(filename):
        '''sets an icon for an existing theme'''
        iconpath = filename.replace(".theme", ".jpg")
        dialog = xbmcgui.Dialog()
        custom_thumbnail = dialog.browse(2, xbmc.getLocalizedString(1030), 'files')
        if custom_thumbnail:
            xbmcvfs.delete(iconpath)
            xbmcvfs.copy(custom_thumbnail, iconpath)
项目:script.skin.helper.skinbackup    作者:marcelveldt    | 项目源码 | 文件源码
def set_cancel_button(self):
        '''set cancel button if exists'''
        try:
            self.getControl(7).setLabel(xbmc.getLocalizedString(222))
            self.getControl(7).setVisible(True)
            self.getControl(7).setEnabled(True)
        except Exception:
            pass
项目:plugin.audio.spotify    作者:marcelveldt    | 项目源码 | 文件源码
def get_authkey(self):
        '''get authentication key'''
        auth_token = self.win.getProperty("spotify-token").decode("utf-8")
        if not auth_token:
            dialog = xbmcgui.Dialog()
            header = self.addon.getAddonInfo("name")
            msg = self.addon.getLocalizedString(11050)
            dialog.ok(header, msg)
            del dialog
            xbmc.executebuiltin("Addon.OpenSettings(%s)" % ADDON_ID)
        return auth_token
项目:plugin.audio.spotify    作者:marcelveldt    | 项目源码 | 文件源码
def switch_user(self):
        '''switch the currently logged in user'''
        usernames = []
        count = 1
        while True:
            username = self.addon.getSetting("username%s" % count).decode("utf-8")
            count += 1
            if not username:
                break
            else:
                display_name = ""
                try:
                    display_name = self.sp.user(username)["display_name"]
                except Exception:
                    pass
                if not display_name:
                    display_name = username
                usernames.append(display_name)
        dialog = xbmcgui.Dialog()
        ret = dialog.select(self.addon.getLocalizedString(11048), usernames)
        del dialog
        if ret != -1:
            ret += 1
            new_user = self.addon.getSetting("username%s" % ret)
            new_pass = self.addon.getSetting("password%s" % ret)
            self.addon.setSetting("username", new_user)
            self.addon.setSetting("password", new_pass)
项目:plugin.audio.spotify    作者:marcelveldt    | 项目源码 | 文件源码
def browse_main(self):
        # main listing
        xbmcplugin.setContent(self.addon_handle, "files")
        items = []
        items.append(
            (self.addon.getLocalizedString(11013),
             "plugin://plugin.audio.spotify/?action=browse_main_library",
             "DefaultMusicCompilations.png", True))
        items.append(
            (self.addon.getLocalizedString(11014),
             "plugin://plugin.audio.spotify/?action=browse_main_explore",
             "DefaultMusicGenres.png", True))
        items.append(
            (xbmc.getLocalizedString(137),
             "plugin://plugin.audio.spotify/?action=search",
             "DefaultMusicSearch.png", True))
        items.append(
            ("%s: %s" % (self.addon.getLocalizedString(11039), self.playername),
             "plugin://plugin.audio.spotify/?action=browse_playback_devices",
             "DefaultMusicPlugins.png", True))
        if self.addon.getSetting("multi_account") == "true":
            cur_user_label = self.sp.me()["display_name"]
            if not cur_user_label:
                cur_user_label = self.sp.me()["id"]
            label = "%s: %s" % (self.addon.getLocalizedString(11047), cur_user_label)
            items.append(
                (label,
                 "plugin://plugin.audio.spotify/?action=switch_user",
                 "DefaultActor.png", False))
        for item in items:
            li = xbmcgui.ListItem(
                item[0],
                path=item[1],
                iconImage=item[2]
            )
            li.setProperty('IsPlayable', 'false')
            li.setArt({"fanart": "special://home/addons/plugin.audio.spotify/fanart.jpg"})
            li.addContextMenuItems([], True)
            xbmcplugin.addDirectoryItem(handle=self.addon_handle, url=item[1], listitem=li, isFolder=item[3])
        xbmcplugin.addSortMethod(self.addon_handle, xbmcplugin.SORT_METHOD_UNSORTED)
        xbmcplugin.endOfDirectory(handle=self.addon_handle)
项目:plugin.audio.spotify    作者:marcelveldt    | 项目源码 | 文件源码
def browse_main_explore(self):
        # explore nodes
        xbmcplugin.setContent(self.addon_handle, "files")
        xbmcplugin.setProperty(self.addon_handle, 'FolderName', self.addon.getLocalizedString(11014))
        items = []
        items.append(
            (self.addon.getLocalizedString(11015),
             "plugin://plugin.audio.spotify/?action=browse_playlists&applyfilter=featured",
             "DefaultMusicPlaylists.png"))
        items.append(
            (self.addon.getLocalizedString(11016),
             "plugin://plugin.audio.spotify/?action=browse_newreleases",
             "DefaultMusicAlbums.png"))

        # add categories
        items += self.get_explore_categories()

        for item in items:
            li = xbmcgui.ListItem(
                item[0],
                path=item[1],
                iconImage=item[2]
            )
            li.setProperty('do_not_analyze', 'true')
            li.setProperty('IsPlayable', 'false')
            li.setArt({"fanart": "special://home/addons/plugin.audio.spotify/fanart.jpg"})
            li.addContextMenuItems([], True)
            xbmcplugin.addDirectoryItem(handle=self.addon_handle, url=item[1], listitem=li, isFolder=True)
        xbmcplugin.addSortMethod(self.addon_handle, xbmcplugin.SORT_METHOD_UNSORTED)
        xbmcplugin.endOfDirectory(handle=self.addon_handle)
项目:plugin.audio.spotify    作者:marcelveldt    | 项目源码 | 文件源码
def artist_toptracks(self):
        xbmcplugin.setContent(self.addon_handle, "songs")
        xbmcplugin.setProperty(self.addon_handle, 'FolderName', self.addon.getLocalizedString(11011))
        tracks = self.sp.artist_top_tracks(self.artistid, country=self.usercountry)
        tracks = self.prepare_track_listitems(tracks=tracks["tracks"])
        self.add_track_listitems(tracks)
        xbmcplugin.addSortMethod(self.addon_handle, xbmcplugin.SORT_METHOD_UNSORTED)
        xbmcplugin.addSortMethod(self.addon_handle, xbmcplugin.SORT_METHOD_TRACKNUM)
        xbmcplugin.addSortMethod(self.addon_handle, xbmcplugin.SORT_METHOD_TITLE)
        xbmcplugin.addSortMethod(self.addon_handle, xbmcplugin.SORT_METHOD_VIDEO_YEAR)
        xbmcplugin.addSortMethod(self.addon_handle, xbmcplugin.SORT_METHOD_SONG_RATING)
        xbmcplugin.endOfDirectory(handle=self.addon_handle)
        if self.defaultview_songs:
            xbmc.executebuiltin('Container.SetViewMode(%s)' % self.defaultview_songs)
项目:plugin.audio.spotify    作者:marcelveldt    | 项目源码 | 文件源码
def related_artists(self):
        xbmcplugin.setContent(self.addon_handle, "artists")
        xbmcplugin.setProperty(self.addon_handle, 'FolderName', self.addon.getLocalizedString(11012))
        cachestr = "spotify.relatedartists.%s" % self.artistid
        checksum = self.cache_checksum()
        artists = self.cache.get(cachestr, checksum=checksum)
        if not artists:
            artists = self.sp.artist_related_artists(self.artistid)
            artists = self.prepare_artist_listitems(artists['artists'])
            self.cache.set(cachestr, artists, checksum=checksum)
        self.add_artist_listitems(artists)
        xbmcplugin.addSortMethod(self.addon_handle, xbmcplugin.SORT_METHOD_UNSORTED)
        xbmcplugin.endOfDirectory(handle=self.addon_handle)
        if self.defaultview_artists:
            xbmc.executebuiltin('Container.SetViewMode(%s)' % self.defaultview_artists)
项目:plugin.audio.spotify    作者:marcelveldt    | 项目源码 | 文件源码
def add_track_to_playlist(self):
        xbmc.executebuiltin("ActivateWindow(busydialog)")

        if not self.trackid and xbmc.getInfoLabel("MusicPlayer.(1).Property(spotifytrackid)"):
            self.trackid = xbmc.getInfoLabel("MusicPlayer.(1).Property(spotifytrackid)")

        playlists = self.sp.user_playlists(self.userid, limit=50, offset=0)
        ownplaylists = []
        ownplaylistnames = []
        for playlist in playlists['items']:
            if playlist["owner"]["id"] == self.userid:
                ownplaylists.append(playlist)
                ownplaylistnames.append(playlist["name"])
        ownplaylistnames.append(xbmc.getLocalizedString(525))
        xbmc.executebuiltin("Dialog.Close(busydialog)")
        select = xbmcgui.Dialog().select(xbmc.getLocalizedString(524), ownplaylistnames)
        if select != -1 and ownplaylistnames[select] == xbmc.getLocalizedString(525):
            # create new playlist...
            kb = xbmc.Keyboard('', xbmc.getLocalizedString(21381))
            kb.setHiddenInput(False)
            kb.doModal()
            if kb.isConfirmed():
                name = kb.getText()
                playlist = self.sp.user_playlist_create(self.userid, name, False)
                self.sp.user_playlist_add_tracks(self.userid, playlist["id"], [self.trackid])
        elif select != -1:
            playlist = ownplaylists[select]
            self.sp.user_playlist_add_tracks(self.userid, playlist["id"], [self.trackid])
项目:plugin.audio.spotify    作者:marcelveldt    | 项目源码 | 文件源码
def browse_newreleases(self):
        xbmcplugin.setContent(self.addon_handle, "albums")
        xbmcplugin.setProperty(self.addon_handle, 'FolderName', self.addon.getLocalizedString(11005))
        albums = self.get_newreleases()
        self.add_album_listitems(albums)
        xbmcplugin.addSortMethod(self.addon_handle, xbmcplugin.SORT_METHOD_UNSORTED)
        xbmcplugin.endOfDirectory(handle=self.addon_handle)
        if self.defaultview_albums:
            xbmc.executebuiltin('Container.SetViewMode(%s)' % self.defaultview_albums)
项目:plugin.audio.spotify    作者:marcelveldt    | 项目源码 | 文件源码
def prepare_playlist_listitems(self, playlists):
        playlists2 = []
        followed_playlists = self.get_curuser_playlistids()
        for item in playlists:

            if item.get("images"):
                item["thumb"] = item["images"][0]['url']
            else:
                item["thumb"] = "DefaultMusicAlbums.png"

            item['url'] = self.build_url(
                {'action': 'browse_playlist', 'playlistid': item['id'],
                 'ownerid': item['owner']['id']})

            contextitems = []
            # play
            contextitems.append(
                (xbmc.getLocalizedString(208),
                 "RunPlugin(plugin://plugin.audio.spotify/?action=play_playlist&playlistid=%s&ownerid=%s)" %
                 (item["id"], item['owner']['id'])))
            if item['owner']['id'] != self.userid and item['id'] in followed_playlists:
                # unfollow playlist
                contextitems.append(
                    (self.addon.getLocalizedString(11010),
                     "RunPlugin(plugin://plugin.audio.spotify/?action=unfollow_playlist&playlistid=%s&ownerid=%s)" %
                     (item['id'],
                      item['owner']['id'])))
            elif item['owner']['id'] != self.userid:
                # follow playlist
                contextitems.append(
                    (self.addon.getLocalizedString(11009),
                     "RunPlugin(plugin://plugin.audio.spotify/?action=follow_playlist&playlistid=%s&ownerid=%s)" %
                     (item['id'],
                      item['owner']['id'])))

            contextitems.append((self.addon.getLocalizedString(11027),
                                 "RunPlugin(plugin://plugin.audio.spotify/?action=refresh_listing)"))
            item["contextitems"] = contextitems
            playlists2.append(item)
        return playlists2
项目:plugin.audio.spotify    作者:marcelveldt    | 项目源码 | 文件源码
def browse_artistalbums(self):
        xbmcplugin.setContent(self.addon_handle, "albums")
        xbmcplugin.setProperty(self.addon_handle, 'FolderName', xbmc.getLocalizedString(132))
        artist = self.sp.artist(self.artistid)
        artistalbums = self.sp.artist_albums(
            self.artistid,
            limit=50,
            offset=0,
            market=self.usercountry,
            album_type='album,single,compilation')
        count = len(artistalbums['items'])
        albumids = []
        while artistalbums['total'] > count:
            artistalbums['items'] += self.sp.artist_albums(self.artistid,
                                                           limit=50,
                                                           offset=count,
                                                           market=self.usercountry,
                                                           album_type='album,single,compilation')['items']
            count += 50
        for album in artistalbums['items']:
            albumids.append(album["id"])
        albums = self.prepare_album_listitems(albumids)
        self.add_album_listitems(albums)
        xbmcplugin.addSortMethod(self.addon_handle, xbmcplugin.SORT_METHOD_VIDEO_YEAR)
        xbmcplugin.addSortMethod(self.addon_handle, xbmcplugin.SORT_METHOD_ALBUM_IGNORE_THE)
        xbmcplugin.addSortMethod(self.addon_handle, xbmcplugin.SORT_METHOD_SONG_RATING)
        xbmcplugin.addSortMethod(self.addon_handle, xbmcplugin.SORT_METHOD_UNSORTED)
        xbmcplugin.endOfDirectory(handle=self.addon_handle)
        if self.defaultview_albums:
            xbmc.executebuiltin('Container.SetViewMode(%s)' % self.defaultview_albums)
项目:plugin.audio.spotify    作者:marcelveldt    | 项目源码 | 文件源码
def browse_savedtracks(self):
        xbmcplugin.setContent(self.addon_handle, "songs")
        xbmcplugin.setProperty(self.addon_handle, 'FolderName', xbmc.getLocalizedString(134))
        tracks = self.get_saved_tracks()
        self.add_track_listitems(tracks, True)
        xbmcplugin.addSortMethod(self.addon_handle, xbmcplugin.SORT_METHOD_UNSORTED)
        xbmcplugin.endOfDirectory(handle=self.addon_handle)
        if self.defaultview_songs:
            xbmc.executebuiltin('Container.SetViewMode(%s)' % self.defaultview_songs)
项目:plugin.audio.spotify    作者:marcelveldt    | 项目源码 | 文件源码
def browse_savedartists(self):
        xbmcplugin.setContent(self.addon_handle, "artists")
        xbmcplugin.setProperty(self.addon_handle, 'FolderName', xbmc.getLocalizedString(133))
        artists = self.get_savedartists()
        self.add_artist_listitems(artists)
        xbmcplugin.addSortMethod(self.addon_handle, xbmcplugin.SORT_METHOD_TITLE)
        xbmcplugin.endOfDirectory(handle=self.addon_handle)
        if self.defaultview_artists:
            xbmc.executebuiltin('Container.SetViewMode(%s)' % self.defaultview_artists)
项目:plugin.audio.spotify    作者:marcelveldt    | 项目源码 | 文件源码
def browse_followedartists(self):
        xbmcplugin.setContent(self.addon_handle, "artists")
        xbmcplugin.setProperty(self.addon_handle, 'FolderName', xbmc.getLocalizedString(133))
        artists = self.get_followedartists()
        self.add_artist_listitems(artists)
        xbmcplugin.endOfDirectory(handle=self.addon_handle)
        if self.defaultview_artists:
            xbmc.executebuiltin('Container.SetViewMode(%s)' % self.defaultview_artists)
项目:weather.clue    作者:stefandmn    | 项目源码 | 文件源码
def execute(self, data=''):
        # evaluate input argument and depends on run add-on event/action
        if data.startswith('Location'):
            keyboard = xbmc.Keyboard('', xbmc.getLocalizedString(14024), False)
            keyboard.doModal()
            if keyboard.isConfirmed() and keyboard.getText() != '':
                text = keyboard.getText()
                locationNames, locationIds = self.provider.location(text)
                dialog = xbmcgui.Dialog()
                if locationNames != []:
                    selected = dialog.select(xbmc.getLocalizedString(396), locationNames)
                    if selected != -1:
                        commons.setSetting('Enabled', 'true')
                        commons.setSetting(data, locationNames[selected])
                        commons.debug('Selected location: %s' % locationNames[selected])
                        commons.setSetting(data + 'id', locationIds[selected])
                        commons.debug('Selected location id: %s' % locationIds[selected])
                else:
                    dialog.ok(commons.AddonName(), commons.translate(284))
        elif commons.setting('Enabled'):
            location = commons.setting('Location%s' % data)
            locationid = commons.setting('Location%sid' % data)
            if (locationid == '') and (data != '1'):
                location = commons.setting('Location1')
                locationid = commons.setting('Location1id')
                commons.debug('Trying first location instead: %s (%s)' % (location, locationid))
            if locationid == '':
                commons.debug('Fallback to GeoIP')
                location, locationid = self.provider.geoip()
            if not locationid == '':
                commons.debug('Call forecast for location %s (%s)' % (location, locationid))
                self.provider.forecast(location, locationid)
            else:
                commons.debug('No location found')
                self.provider.clear()
            self.provider.refresh()
        else:
            commons.debug('You need to enable weather retrieval in the weather underground add-on settings')
            self.provider.clear()
项目:plugin.video.lastship    作者:lastship    | 项目源码 | 文件源码
def get(version):
    try:
        import xbmc,xbmcgui,xbmcaddon,xbmcvfs

        f = xbmcvfs.File(xbmcaddon.Addon().getAddonInfo('changelog'))
        text = f.read() ; f.close()

        label = '%s - %s' % (xbmc.getLocalizedString(24054), xbmcaddon.Addon().getAddonInfo('name'))

        id = 10147

        xbmc.executebuiltin('ActivateWindow(%d)' % id)
        xbmc.sleep(100)

        win = xbmcgui.Window(id)

        retry = 50
        while (retry > 0):
            try:
                xbmc.sleep(10)
                win.getControl(1).setLabel(label)
                win.getControl(5).setText(text)
                retry = 0
            except:
                retry -= 1

        return '1'
    except:
        return '1'
项目:plugin.video.exodus    作者:huberyhe    | 项目源码 | 文件源码
def get(version):
    try:
        import xbmc,xbmcgui,xbmcaddon,xbmcvfs

        f = xbmcvfs.File(xbmcaddon.Addon().getAddonInfo('changelog'))
        text = f.read() ; f.close()

        label = '%s - %s' % (xbmc.getLocalizedString(24054), xbmcaddon.Addon().getAddonInfo('name'))

        id = 10147

        xbmc.executebuiltin('ActivateWindow(%d)' % id)
        xbmc.sleep(100)

        win = xbmcgui.Window(id)

        retry = 50
        while (retry > 0):
            try:
                xbmc.sleep(10)
                win.getControl(1).setLabel(label)
                win.getControl(5).setText(text)
                retry = 0
            except:
                retry -= 1

        return '1'
    except:
        return '1'
项目:exodus-favourite-library    作者:arcane47    | 项目源码 | 文件源码
def get(version):
    try:
        import xbmc,xbmcgui,xbmcaddon,xbmcvfs

        f = xbmcvfs.File(xbmcaddon.Addon().getAddonInfo('changelog'))
        text = f.read() ; f.close()

        label = '%s - %s' % (xbmc.getLocalizedString(24054), xbmcaddon.Addon().getAddonInfo('name'))

        id = 10147

        xbmc.executebuiltin('ActivateWindow(%d)' % id)
        xbmc.sleep(100)

        win = xbmcgui.Window(id)

        retry = 50
        while (retry > 0):
            try:
                xbmc.sleep(10)
                win.getControl(1).setLabel(label)
                win.getControl(5).setText(text)
                retry = 0
            except:
                retry -= 1

        return '1'
    except:
        return '1'
项目:plugin.video.stream-cinema    作者:bbaronSVK    | 项目源码 | 文件源码
def render_video(self,item):
        #util.debug("_render_video")

        params = self.params()
        params.update({'play':item['url'],'dtitle':item['title']})
        #for k,v in item.iteritems():
        #    params.update({k: str(v)})
        downparams = self.params()
        if item.get('originaltitle_seo'):
            downparams.update({'title':"%s%s" % (item['originaltitle_seo'], item['extension']), 'down':item['url']})
        else:
            downparams.update({'title':"%s.%s" % (item['title'], 'mp4'), 'down':item['url']})
        title = item['title'] #'%s%s' % (item['title'],item['size'])
        menuItems = {}
        if "!download" not in self.provider.capabilities():
            menuItems[xbmc.getLocalizedString(33003)] = downparams
        if 'trailer' in item.keys() and item['trailer'] != '' and item['trailer'] is not None:
            trailerparams = {'action-type': 'trailer', 'url': item['trailer']}
            menuItems['Trailer'] = trailerparams
        if 'menu' in item.keys():
            for ctxtitle, value in item['menu'].iteritems():
                if ctxtitle.find('$') == 0:
                    try:
                        ctxtitle = self.addon.getLocalizedString(int(ctxtitle[1:]))
                    except:
                        pass
                menuItems[ctxtitle] = value
        #util.debug("menuItems: %s" % str(menuItems))
        self.add_video(title,
                params,
                item['img'],
                infoLabels=item,
                menuItems=menuItems
                )
项目:plugin.video.stream-cinema    作者:bbaronSVK    | 项目源码 | 文件源码
def getString(self, string_id):
        return self.addon.getLocalizedString(string_id)
项目:plugin.video.stream-cinema    作者:bbaronSVK    | 项目源码 | 文件源码
def set_list_control(self):
        '''select correct list (3=small, 6=big with icons)'''

        # set list id 6 if available for rich dialog
        if self.richlayout:
            self.list_control = self.getControl(6)
            self.getControl(3).setVisible(False)
        else:
            self.list_control = self.getControl(3)
            self.getControl(6).setVisible(False)

        self.list_control.setEnabled(True)
        self.list_control.setVisible(True)

        # enable cancel button
        self.set_cancel_button()

        # show get more button
        if self.getmorebutton:
            util.debug("[SC] dialog 1")
            self.getControl(5).setVisible(True)
            self.getControl(5).setLabel(xbmc.getLocalizedString(21452))
        elif not self.multiselect:
            util.debug("[SC] dialog 2")
            self.getControl(5).setLabel(xbmc.getLocalizedString(186))
            self.getControl(5).setVisible(True)
        else:
            util.debug("[SC] dialog 3")
            self.getControl(5).setVisible(True)
            self.getControl(5).setEnabled(True)
项目:specto    作者:mrknow    | 项目源码 | 文件源码
def get(version):
    try:
        import xbmc,xbmcgui,xbmcaddon,xbmcvfs

        f = xbmcvfs.File(xbmcaddon.Addon().getAddonInfo('changelog'))
        text = f.read() ; f.close()

        label = '%s - %s' % (xbmc.getLocalizedString(24054), xbmcaddon.Addon().getAddonInfo('name'))

        id = 10147

        xbmc.executebuiltin('ActivateWindow(%d)' % id)
        xbmc.sleep(100)

        win = xbmcgui.Window(id)

        retry = 50
        while (retry > 0):
            try:
                xbmc.sleep(10)
                win.getControl(1).setLabel(label)
                win.getControl(5).setText(text)
                retry = 0
            except:
                retry -= 1

        return '1'
    except:
        return '1'
项目:pelisalacarta-ce    作者:pelisalacarta-ce    | 项目源码 | 文件源码
def get_localized_string(code):
    dev = xbmc.getLocalizedString(code)

    try:
        dev = dev.encode("utf-8")
    except:
        pass

    return dev
项目:script.module.metadatautils    作者:marcelveldt    | 项目源码 | 文件源码
def manual_set_music_artwork(self, details, mediatype):
        '''manual override artwork options'''
        from utils import manual_set_artwork
        if mediatype == "artist" and "artist" in details:
            header = "%s: %s" % (xbmc.getLocalizedString(13511), details["artist"])
        else:
            header = "%s: %s" % (xbmc.getLocalizedString(13511), xbmc.getLocalizedString(558))
        changemade, artwork = manual_set_artwork(details["art"], mediatype, header)
        # save results if any changes made
        if changemade:
            details["art"] = artwork
            refresh_needed = False
            download_art = self._mutils.addon.getSetting("music_art_download") == "true"
            download_art_custom = self._mutils.addon.getSetting("music_art_download_custom") == "true"
            # download artwork to music folder if needed
            if details.get("diskpath") and download_art:
                details["art"] = download_artwork(details["diskpath"], details["art"])
                refresh_needed = True
            # download artwork to custom folder if needed
            if details.get("customartpath") and download_art_custom:
                details["art"] = download_artwork(details["customartpath"], details["art"])
                refresh_needed = True
            # reload skin to make sure new artwork is visible
            if refresh_needed:
                xbmc.sleep(500)
                xbmc.executebuiltin("ReloadSkin()")
        # return endresult
        return details
项目:script.module.metadatautils    作者:marcelveldt    | 项目源码 | 文件源码
def select_art(items, manual_select=False, art_type=""):
        '''select the preferred image from the list'''
        image = None
        if manual_select:
            # show selectdialog to manually select the item
            results_list = []
            # add none and browse entries
            listitem = xbmcgui.ListItem(label=xbmc.getLocalizedString(231), iconImage="DefaultAddonNone.png")
            results_list.append(listitem)
            listitem = xbmcgui.ListItem(label=xbmc.getLocalizedString(1030), iconImage="DefaultFolder.png")
            results_list.append(listitem)
            for item in items:
                labels = [item["contributedby"], item["dateadded"], item["language"], item["source"]]
                label = " / ".join(labels)
                listitem = xbmcgui.ListItem(label=label, iconImage=item["thumb"])
                results_list.append(listitem)
            if manual_select and results_list:
                dialog = DialogSelect("DialogSelect.xml", "", listing=results_list, window_title=art_type)
                dialog.doModal()
                selected_item = dialog.result
                del dialog
                if selected_item == 0:
                    image = ""
                if selected_item == 1:
                    # browse for image
                    dialog = xbmcgui.Dialog()
                    image = dialog.browse(2, xbmc.getLocalizedString(1030), 'files', mask='.gif').decode("utf-8")
                    del dialog
                elif selected_item > 1:
                    # user has selected an image from online results
                    image = items[selected_item - 2]["image"]
        elif items:
            # just grab the first item as best match
            image = items[0]["image"]
        return image
项目:script.module.metadatautils    作者:marcelveldt    | 项目源码 | 文件源码
def pvr_proceed_lookup(self, title, channel, genre, recordingdetails):
        '''perform some checks if we can proceed with the lookup'''
        filters = []
        if not title:
            filters.append("Title is empty")
        for item in self._mutils.addon.getSetting("pvr_art_ignore_titles").split("|"):
            if item and item.lower() == title.lower():
                filters.append("Title is in list of titles to ignore")
        for item in self._mutils.addon.getSetting("pvr_art_ignore_channels").split("|"):
            if item and item.lower() == channel.lower():
                filters.append("Channel is in list of channels to ignore")
        for item in self._mutils.addon.getSetting("pvr_art_ignore_genres").split("|"):
            if genre and item and item.lower() in genre.lower():
                filters.append("Genre is in list of genres to ignore")
        if self._mutils.addon.getSetting("pvr_art_ignore_commongenre") == "true":
            # skip common genres like sports, weather, news etc.
            genre = genre.lower()
            kodi_strings = [19516, 19517, 19518, 19520, 19548, 19549, 19551,
                            19552, 19553, 19554, 19555, 19556, 19557, 19558, 19559]
            for kodi_string in kodi_strings:
                kodi_string = xbmc.getLocalizedString(kodi_string).lower()
                if (genre and (genre in kodi_string or kodi_string in genre)) or kodi_string in title:
                    filters.append("Common genres like weather/sports are set to be ignored")
        if self._mutils.addon.getSetting("pvr_art_recordings_only") == "true" and not recordingdetails:
            filters.append("PVR Artwork is enabled for recordings only")
        if filters:
            filterstr = " - ".join(filters)
            log_msg("PVR artwork - filter active for title: %s - channel %s --> %s" % (title, channel, filterstr))
            return filterstr
        else:
            return ""
项目:script.module.metadatautils    作者:marcelveldt    | 项目源码 | 文件源码
def search_image(self, search_query, manual_select=False):
        '''
            search google images with the given query, returns first/best match
            optional parameter: manual_select (bool), will show selectdialog to allow manual select by user
        '''
        image = ""
        images_list = []
        for img in self.get_data(search_query):
            img = img.replace(" ", "%20")  # fix for spaces in url
            if xbmcvfs.exists(img):
                if not manual_select:
                    # just return the first image found (assuming that will be the best match)
                    return img
                else:
                    # manual lookup, list results and let user pick one
                    listitem = xbmcgui.ListItem(label=img, iconImage=img)
                    images_list.append(listitem)
        if manual_select and images_list:
            dialog = DialogSelect("DialogSelect.xml", "", listing=images_list, window_title="%s - Google"
                                  % xbmc.getLocalizedString(283))
            dialog.doModal()
            selected_item = dialog.result
            del dialog
            if selected_item != -1:
                selected_item = images_list[selected_item]
                image = selected_item.getLabel().decode("utf-8")
        return image
项目:script.module.metadatautils    作者:marcelveldt    | 项目源码 | 文件源码
def get_duration(duration):
    '''transform duration time in minutes to hours:minutes'''
    if not duration:
        return {}
    if isinstance(duration, (unicode, str)):
        duration.replace("min", "").replace("", "").replace(".", "")
    try:
        total_minutes = int(duration)
        if total_minutes < 60:
            hours = 0
        else:
            hours = total_minutes / 60
        minutes = total_minutes - (hours * 60)
        formatted_time = "%s:%s" % (hours, str(minutes).zfill(2))
    except Exception as exc:
        log_exception(__name__, exc)
        return {}
    return {
        "Duration": formatted_time,
        "Duration.Hours": hours,
        "Duration.Minutes": minutes,
        "Runtime": total_minutes,
        "RuntimeExtended": "%s %s" % (total_minutes, xbmc.getLocalizedString(12391)),
        "DurationAndRuntime": "%s (%s min.)" % (formatted_time, total_minutes),
        "DurationAndRuntimeExtended": "%s (%s %s)" % (formatted_time, total_minutes, xbmc.getLocalizedString(12391))
    }
项目:script.module.metadatautils    作者:marcelveldt    | 项目源码 | 文件源码
def onInit(self):
        '''called when the dialog is drawn'''
        self.list_control = self.getControl(6)
        self.getControl(1).setLabel(self.window_title)
        self.getControl(3).setVisible(False)
        try:
            self.getControl(7).setLabel(xbmc.getLocalizedString(222))
        except Exception:
            pass

        self.getControl(5).setVisible(False)

        # add our items to the listing  and focus the control
        self.list_control.addItems(self.listing)
        self.setFocus(self.list_control)
项目:plugin.video.amazon65    作者:phil65    | 项目源码 | 文件源码
def getPlaybackInfo(url):
    if addon.getSetting("framerate") == 'false':
        return ''
    Dialog.notification(xbmc.getLocalizedString(20186), '', xbmcgui.NOTIFICATION_INFO, 60000, False)
    values = getFlashVars(url)
    if not values:
        return ''
    data = getUrldata(mode='catalog/GetPlaybackResources',
                      values=values,
                      extra=True)
    fr = getStreams(*data)
    Dialog.notification(xbmc.getLocalizedString(20186), '', xbmcgui.NOTIFICATION_INFO, 10, False)
    return fr
项目:plugin.video.jen    作者:midraal    | 项目源码 | 文件源码
def get_string(t):
        import xbmc, xbmcaddon
        ADDON = xbmcaddon.Addon()
        ADDON_ID = ADDON.getAddonInfo("id")
        id = _strings.get(t.lower())
        if not id:
            xbmc.log("LANGUAGE: missing translation for '%s'" % t.lower())
            return t
        elif id in range(30000, 31000) and ADDON_ID.startswith("plugin"): return ADDON.getLocalizedString(id)
        elif id in range(31000, 32000) and ADDON_ID.startswith("skin"): return ADDON.getLocalizedString(id)
        elif id in range(32000, 33000) and ADDON_ID.startswith("script"): return ADDON.getLocalizedString(id)
        elif not id in range(30000, 33000): return xbmc.getLocalizedString(id)
    #setattr(__builtin__, "_", get_string)

# SYSTEM LANGUAGE STRINGS: Only the ones that are available AND unchanged in ["Helix", "Isengard", "Jarvis", "Krypton", "Leia"]
项目:repository.midraal    作者:midraal    | 项目源码 | 文件源码
def get_string(t):
        import xbmc, xbmcaddon
        ADDON = xbmcaddon.Addon()
        ADDON_ID = ADDON.getAddonInfo("id")
        id = _strings.get(t.lower())
        if not id:
            xbmc.log("LANGUAGE: missing translation for '%s'" % t.lower())
            return t
        elif id in range(30000, 31000) and ADDON_ID.startswith("plugin"): return ADDON.getLocalizedString(id)
        elif id in range(31000, 32000) and ADDON_ID.startswith("skin"): return ADDON.getLocalizedString(id)
        elif id in range(32000, 33000) and ADDON_ID.startswith("script"): return ADDON.getLocalizedString(id)
        elif not id in range(30000, 33000): return xbmc.getLocalizedString(id)
    #setattr(__builtin__, "_", get_string)

# SYSTEM LANGUAGE STRINGS: Only the ones that are available AND unchanged in ["Helix", "Isengard", "Jarvis", "Krypton", "Leia"]
项目:script.skin.helper.skinbackup    作者:marcelveldt    | 项目源码 | 文件源码
def colorthemes(self):
        '''show dialog with all available color themes'''
        listitems = []
        # create item
        listitem = xbmcgui.ListItem(label=self.addon.getLocalizedString(32035), iconImage="DefaultAddonSkin.png")
        listitem.setLabel2(self.addon.getLocalizedString(32036))
        listitem.setPath("add")
        listitems.append(listitem)
        # import item
        listitem = xbmcgui.ListItem(label=self.addon.getLocalizedString(32037), iconImage="DefaultAddonSkin.png")
        listitem.setLabel2(self.addon.getLocalizedString(32038))
        listitem.setPath("import")
        listitems.append(listitem)
        # get all skin and user defined themes
        listitems += self.get_skin_colorthemes()
        listitems += self.get_user_colorthemes()

        # show dialog and list options
        header = self.addon.getLocalizedString(32020)
        dialog = DialogSelect("DialogSelect.xml", "", windowtitle=header,
                              richlayout=True, listing=listitems)
        dialog.doModal()
        result = dialog.result
        del dialog
        if result:
            themefile = result.getfilename().decode("utf-8")
            themename = result.getLabel().decode("utf-8")
            has_icon = xbmcvfs.exists(themefile.replace(".theme", ".jpg"))
            if themefile == "add":
                # create new colortheme
                self.create_colortheme()
                self.colorthemes()
            elif themefile == "import":
                # import theme file
                self.restore_colortheme()
                self.colorthemes()
            elif self.skinthemes_path in themefile:
                # load skin provided theme
                self.load_colortheme(themefile)
            else:
                # show contextmenu for user custom theme
                menuoptions = []
                menuoptions.append(self.addon.getLocalizedString(32021))
                menuoptions.append(xbmc.getLocalizedString(117))
                if not has_icon:
                    menuoptions.append(xbmc.getLocalizedString(19285))
                menuoptions.append(self.addon.getLocalizedString(32022))
                ret = xbmcgui.Dialog().select(themename, menuoptions)
                if ret == 0:
                    self.load_colortheme(themefile)
                elif ret == 1:
                    self.remove_theme(themefile)
                elif ret == 2 and not has_icon:
                    self.set_icon_for_theme(themefile)
                elif ret == 3 or (ret == 2 and has_icon):
                    self.backup_theme(themename)
                if not ret == 0:
                    # show selection dialog again
                    self.colorthemes()
项目:plugin.audio.spotify    作者:marcelveldt    | 项目源码 | 文件源码
def browse_playback_devices(self):
        '''set the active playback device'''
        xbmcplugin.setContent(self.addon_handle, "files")
        items = []
        if self.win.getProperty("spotify.supportsplayback"):
            # local playback
            label = self.addon.getLocalizedString(11037)
            if self.local_playback:
                label += " [%s]" % self.addon.getLocalizedString(11040)
            url = "plugin://plugin.audio.spotify/?action=set_playback_device&deviceid=local"
            li = xbmcgui.ListItem(label, iconImage="DefaultMusicCompilations.png")
            li.setProperty("isPlayable", "false")
            li.setArt({"fanart": "special://home/addons/plugin.audio.spotify/fanart.jpg"})
            li.addContextMenuItems([], True)
            xbmcplugin.addDirectoryItem(handle=self.addon_handle, url=url, listitem=li, isFolder=False)
        else:
            # local playback using a remote service
            label = self.addon.getLocalizedString(11060)
            if self.addon.getSetting("playback_device") == "remote":
                label += " [%s]" % self.addon.getLocalizedString(11040)
            url = "plugin://plugin.audio.spotify/?action=set_playback_device&deviceid=remote"
            li = xbmcgui.ListItem(label, iconImage="DefaultMusicCompilations.png")
            li.setProperty("isPlayable", "false")
            li.setArt({"fanart": "special://home/addons/plugin.audio.spotify/fanart.jpg"})
            li.addContextMenuItems([], True)
            xbmcplugin.addDirectoryItem(handle=self.addon_handle, url=url, listitem=li, isFolder=False)
        # connect devices
        for device in self.sp.devices()["devices"]:
            label = "Spotify Connect: %s" % device["name"]
            if device["is_active"] and self.addon.getSetting("playback_device") == "connect":
                label += " [%s]" % self.addon.getLocalizedString(11040)
            url = "plugin://plugin.audio.spotify/?action=set_playback_device&deviceid=%s" % device["id"]
            li = xbmcgui.ListItem(label, iconImage="DefaultMusicCompilations.png")
            li.setProperty("isPlayable", "false")
            li.setArt({"fanart": "special://home/addons/plugin.audio.spotify/fanart.jpg"})
            li.addContextMenuItems([], True)
            xbmcplugin.addDirectoryItem(handle=self.addon_handle, url=url, listitem=li, isFolder=False)
        if xbmc.getCondVisibility("System.HasAddon(plugin.audio.squeezebox)"):
            # LMS playback
            label = xbmc.getInfoLabel("System.AddonTitle(plugin.audio.squeezebox)")
            if self.addon.getSetting("playback_device") == "squeezebox":
                label += " [%s]" % self.addon.getLocalizedString(11040)
            url = "plugin://plugin.audio.spotify/?action=set_playback_device&deviceid=squeezebox"
            li = xbmcgui.ListItem(label, iconImage="DefaultMusicCompilations.png")
            li.setProperty("isPlayable", "false")
            li.setArt({"fanart": "special://home/addons/plugin.audio.spotify/fanart.jpg"})
            li.addContextMenuItems([], True)
            xbmcplugin.addDirectoryItem(handle=self.addon_handle, url=url, listitem=li, isFolder=False)
        xbmcplugin.addSortMethod(self.addon_handle, xbmcplugin.SORT_METHOD_UNSORTED)
        xbmcplugin.endOfDirectory(handle=self.addon_handle)
项目:plugin.audio.spotify    作者:marcelveldt    | 项目源码 | 文件源码
def browse_main_library(self):
        # library nodes
        xbmcplugin.setContent(self.addon_handle, "files")
        xbmcplugin.setProperty(self.addon_handle, 'FolderName', self.addon.getLocalizedString(11013))
        items = []
        items.append(
            (xbmc.getLocalizedString(136),
             "plugin://plugin.audio.spotify/?action=browse_playlists&ownerid=%s" %
             (self.userid),
                "DefaultMusicPlaylists.png"))
        items.append(
            (xbmc.getLocalizedString(132),
             "plugin://plugin.audio.spotify/?action=browse_savedalbums",
             "DefaultMusicAlbums.png"))
        items.append(
            (xbmc.getLocalizedString(134),
             "plugin://plugin.audio.spotify/?action=browse_savedtracks",
             "DefaultMusicSongs.png"))
        items.append(
            (xbmc.getLocalizedString(133),
             "plugin://plugin.audio.spotify/?action=browse_savedartists",
             "DefaultMusicArtists.png"))
        items.append(
            (self.addon.getLocalizedString(11023),
             "plugin://plugin.audio.spotify/?action=browse_topartists",
             "DefaultMusicArtists.png"))
        items.append(
            (self.addon.getLocalizedString(11024),
             "plugin://plugin.audio.spotify/?action=browse_toptracks",
             "DefaultMusicSongs.png"))
        for item in items:
            li = xbmcgui.ListItem(
                item[0],
                path=item[1],
                iconImage=item[2]
            )
            li.setProperty('do_not_analyze', 'true')
            li.setProperty('IsPlayable', 'false')
            li.setArt({"fanart": "special://home/addons/plugin.audio.spotify/fanart.jpg"})
            li.addContextMenuItems([], True)
            xbmcplugin.addDirectoryItem(handle=self.addon_handle, url=item[1], listitem=li, isFolder=True)
        xbmcplugin.addSortMethod(self.addon_handle, xbmcplugin.SORT_METHOD_UNSORTED)
        xbmcplugin.endOfDirectory(handle=self.addon_handle)