Python xbmcvfs 模块,mkdir() 实例源码

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

项目: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.video.netflix    作者:asciidisco    | 项目源码 | 文件源码
def __init__(self, kodi_helper):
        """
        The Constructor checks for already existing crypto Keys.
        If they exist it will load the existing keys
        """
        self.kodi_helper = kodi_helper
        try:
            xbmcvfs.mkdir(path=self.kodi_helper.msl_data_path)
        except OSError:
            pass

        if self.file_exists(self.kodi_helper.msl_data_path, 'msl_data.json'):
            self.init_msl_data()
        elif self.file_exists(self.kodi_helper.msl_data_path, 'rsa_key.bin'):
            self.init_rsa_keys()
        else:
            self.init_generate_rsa_keys()
项目:plugin.program.indigo    作者:tvaddonsco    | 项目源码 | 文件源码
def make_dir(mypath, dirname):
    ''' Creates sub-directories if they are not found. '''
    import xbmcvfs

    if not xbmcvfs.exists(mypath):
        try:
            xbmcvfs.mkdirs(mypath)
        except:
            xbmcvfs.mkdir(mypath)

    subpath = os.path.join(mypath, dirname)

    if not xbmcvfs.exists(subpath):
        try:
            xbmcvfs.mkdirs(subpath)
        except:
            xbmcvfs.mkdir(subpath)

    return subpath


# -----------------------------------------------------------------------------------------------------------------
项目:script.skin.helper.skinbackup    作者:marcelveldt    | 项目源码 | 文件源码
def __init__(self):
        self.userthemes_path = u"special://profile/addon_data/%s/themes/" % xbmc.getSkinDir()
        if not xbmcvfs.exists(self.userthemes_path):
            xbmcvfs.mkdir(self.userthemes_path)
        self.skinthemes_path = u"special://skin/extras/skinthemes/"
        if xbmcvfs.exists("special://home/addons/resource.skinthemes.%s/resources/" % get_skin_name()):
            self.skinthemes_path = u"special://home/addons/resource.skinthemes.%s/resources/" % get_skin_name()
        self.addon = xbmcaddon.Addon(ADDON_ID)
项目:script.skin.helper.skinbackup    作者:marcelveldt    | 项目源码 | 文件源码
def backup_skinshortcuts(self, dest_path):
        '''backup skinshortcuts including images'''
        source_path = u'special://profile/addon_data/script.skinshortcuts/'
        if not xbmcvfs.exists(dest_path):
            xbmcvfs.mkdir(dest_path)
        for file in xbmcvfs.listdir(source_path)[1]:
            file = file.decode("utf-8")
            sourcefile = source_path + file
            destfile = dest_path + file
            if xbmc.getCondVisibility("SubString(Skin.String(skinshortcuts-sharedmenu),false)"):
                # User is not sharing menu, so strip the skin name out of the destination file
                destfile = destfile.replace("%s." % (xbmc.getSkinDir()), "")
            if (file.endswith(".DATA.xml") and (not xbmc.getCondVisibility(
                    "SubString(Skin.String(skinshortcuts-sharedmenu),false)") or file.startswith(xbmc.getSkinDir()))):
                xbmcvfs.copy(sourcefile, destfile)
                # parse shortcuts file and look for any images - if found copy them to addon folder
                self.backup_skinshortcuts_images(destfile, dest_path)

            elif file.endswith(".properties") and xbmc.getSkinDir() in file:
                if xbmc.getSkinDir() in file:
                    destfile = dest_path + file.replace(xbmc.getSkinDir(), "SKINPROPERTIES")
                    copy_file(sourcefile, destfile)
                    self.backup_skinshortcuts_properties(destfile, dest_path)
            else:
                # just copy the remaining files
                copy_file(sourcefile, destfile)
项目:plugin.video.bdyun    作者:caasiu    | 项目源码 | 文件源码
def data_dir():
    """"get user data directory of this addon. 
    according to http://wiki.xbmc.org/index.php?title=Add-on_Rules#Requirements_for_scripts_and_plugins
    """
    __datapath__ = xbmc.translatePath( __Addon.getAddonInfo('profile') ).decode('utf-8')
    if not xbmcvfs.exists(__datapath__):
        xbmcvfs.mkdir(__datapath__)
    return __datapath__
项目:plugin.video.netflix    作者:asciidisco    | 项目源码 | 文件源码
def setup_local_netflix_library(self, source):
        """Sets up the basic directories

        Parameters
        ----------
        source : :obj:`dict` of :obj:`str`
            Dicitionary with directories to be created
        """
        for label in source:
            exists = xbmcvfs.exists(
                path=self.kodi_helper.check_folder_path(source[label]))
            if not exists:
                xbmcvfs.mkdir(source[label])
项目:kodi-espnplayer    作者:emilsvennesson    | 项目源码 | 文件源码
def __init__(self, base_url=None, handle=None):
        addon = self.get_addon()
        self.base_url = base_url
        self.handle = handle
        self.addon_path = xbmc.translatePath(addon.getAddonInfo('path'))
        self.addon_profile = xbmc.translatePath(addon.getAddonInfo('profile'))
        self.addon_name = addon.getAddonInfo('id')
        self.addon_version = addon.getAddonInfo('version')
        self.language = addon.getLocalizedString
        self.logging_prefix = '[%s-%s]' % (self.addon_name, self.addon_version)
        if not xbmcvfs.exists(self.addon_profile):
            xbmcvfs.mkdir(self.addon_profile)
        self.espn = ESPNPlayer(self.addon_profile, True)
项目:kodi-viaplay    作者:emilsvennesson    | 项目源码 | 文件源码
def __init__(self, base_url=None, handle=None):
        addon = self.get_addon()
        self.base_url = base_url
        self.handle = handle
        self.addon_path = xbmc.translatePath(addon.getAddonInfo('path'))
        self.addon_profile = xbmc.translatePath(addon.getAddonInfo('profile'))
        self.addon_name = addon.getAddonInfo('id')
        self.addon_version = addon.getAddonInfo('version')
        self.language = addon.getLocalizedString
        self.logging_prefix = '[%s-%s]' % (self.addon_name, self.addon_version)
        if not xbmcvfs.exists(self.addon_profile):
            xbmcvfs.mkdir(self.addon_profile)
        self.vp = Viaplay(self.addon_profile, self.get_country_code(), True)
项目:plugin.video.prime_instant    作者:liberty-developer    | 项目源码 | 文件源码
def addMovieToLibrary(movieID, title):
    #title = title.decode('iso-8859-1').encode('iso-8859-1')
    movieFolderName = (''.join(c for c in title if c not in '/\\:?"*|<>')).strip(' .')
    dir = os.path.join(libraryFolderMovies, movieFolderName)
    if not os.path.exists(dir):
        xbmcvfs.mkdir(unicode(dir).encode("iso-8859-1"))
        fh = xbmcvfs.File(unicode(os.path.join(dir, "movie.strm")).encode("iso-8859-1"), 'w')
        fh.write(unicode('plugin://'+addonID+'/?mode=playVideo&url='+movieID).encode("utf-8"))
        fh.close()
    if updateDB:
        xbmc.executebuiltin(unicode('UpdateLibrary(video)').encode("utf-8"))
项目:plugin.video.prime_instant    作者:liberty-developer    | 项目源码 | 文件源码
def addSeasonToLibrary(seriesID, seriesTitle, seasonID):
    seriesFolderName = (''.join(c for c in seriesTitle if c not in '/\\:?"*|<>')).strip(' .')
    seriesDir = os.path.join(libraryFolderTV, seriesFolderName)
    if not os.path.isdir(seriesDir):
        xbmcvfs.mkdir(unicode(seriesDir).encode("iso-8859-1"))
    content = getUnicodePage(urlMain+"/gp/product/"+seasonID)
    matchSeason = re.compile('"seasonNumber":"(.+?)"', re.DOTALL).findall(content)
    spl = content.split('href="'+urlMain+'/gp/product')
    for i in range(1, len(spl), 1):
        entry = spl[i]
        match = re.compile('class="episode-title">(.+?)<', re.DOTALL).findall(entry)
        if match:
            title = match[0]
            title = cleanTitle(title)
            episodeNr = title[:title.find('.')]
            title = title[title.find('.')+1:].strip()
            match = re.compile('/(.+?)/', re.DOTALL).findall(entry)
            episodeID = match[0]
            if len(episodeNr) > 2:
                episodeNr = ''.join(re.findall(r'\d+', episodeNr))
            if len(episodeNr) == 1:
                episodeNr = "0"+episodeNr
            seasonNr = matchSeason[0]
            if len(seasonNr) == 1:
                seasonNr = "0"+seasonNr
            filename = "S"+seasonNr+"E"+episodeNr+" - "+title+".strm"
            filename = (''.join(c for c in filename if c not in '/\\:?"*|<>')).strip(' .')
            print type(filename)
            fh = xbmcvfs.File(unicode(os.path.join(seriesDir, filename)).encode('utf-8'), 'w')
            fh.write(unicode('plugin://'+addonID+'/?mode=playVideo&url='+episodeID).encode("utf-8"))
            fh.close()
    if updateDB:
        xbmc.executebuiltin('UpdateLibrary(video)')
项目:script.module.metadatautils    作者:marcelveldt    | 项目源码 | 文件源码
def download_artwork(folderpath, artwork):
    '''download artwork to local folder'''
    efa_path = ""
    new_dict = {}
    if not xbmcvfs.exists(folderpath):
        xbmcvfs.mkdir(folderpath)
    for key, value in artwork.iteritems():
        if key == "fanart":
            new_dict[key] = download_image(os.path.join(folderpath, "fanart.jpg"), value)
        elif key == "thumb":
            new_dict[key] = download_image(os.path.join(folderpath, "folder.jpg"), value)
        elif key == "discart":
            new_dict[key] = download_image(os.path.join(folderpath, "disc.png"), value)
        elif key == "banner":
            new_dict[key] = download_image(os.path.join(folderpath, "banner.jpg"), value)
        elif key == "clearlogo":
            new_dict[key] = download_image(os.path.join(folderpath, "logo.png"), value)
        elif key == "clearart":
            new_dict[key] = download_image(os.path.join(folderpath, "clearart.png"), value)
        elif key == "characterart":
            new_dict[key] = download_image(os.path.join(folderpath, "characterart.png"), value)
        elif key == "poster":
            new_dict[key] = download_image(os.path.join(folderpath, "poster.jpg"), value)
        elif key == "landscape":
            new_dict[key] = download_image(os.path.join(folderpath, "landscape.jpg"), value)
        elif key == "thumbback":
            new_dict[key] = download_image(os.path.join(folderpath, "thumbback.jpg"), value)
        elif key == "spine":
            new_dict[key] = download_image(os.path.join(folderpath, "spine.jpg"), value)
        elif key == "fanarts" and value:
            # copy extrafanarts only if the directory doesn't exist at all
            delim = "\\" if "\\" in folderpath else "/"
            efa_path = "%sextrafanart" % folderpath + delim
            if not xbmcvfs.exists(efa_path):
                xbmcvfs.mkdir(efa_path)
                images = []
                for count, image in enumerate(value):
                    image = download_image(os.path.join(efa_path, "fanart%s.jpg" % count), image)
                    images.append(image)
                    if LIMIT_EXTRAFANART and count == LIMIT_EXTRAFANART:
                        break
                new_dict[key] = images
        elif key == "posters" and value:
            # copy extraposters only if the directory doesn't exist at all
            delim = "\\" if "\\" in folderpath else "/"
            efa_path = "%sextraposter" % folderpath + delim
            if not xbmcvfs.exists(efa_path):
                xbmcvfs.mkdir(efa_path)
                images = []
                for count, image in enumerate(value):
                    image = download_image(os.path.join(efa_path, "poster%s.jpg" % count), image)
                    images.append(image)
                    if LIMIT_EXTRAFANART and count == LIMIT_EXTRAFANART:
                        break
                new_dict[key] = images
        else:
            new_dict[key] = value
    if efa_path:
        new_dict["extrafanart"] = efa_path
    return new_dict
项目:plugin.video.youtube    作者:jdf76    | 项目源码 | 文件源码
def __init__(self, path='/', params=None, plugin_name=u'', plugin_id=u'', override=True):
        AbstractContext.__init__(self, path, params, plugin_name, plugin_id)

        if plugin_id:
            self._addon = xbmcaddon.Addon(id=plugin_id)
        else:
            self._addon = xbmcaddon.Addon()

        self._system_version = None

        """
        I don't know what xbmc/kodi is doing with a simple uri, but we have to extract the information from the
        sys parameters and re-build our clean uri.
        Also we extract the path and parameters - man, that would be so simple with the normal url-parsing routines.
        """
        # first the path of the uri
        if override:
            self._uri = sys.argv[0]
            comps = urlparse.urlparse(self._uri)
            self._path = urllib.unquote(comps.path).decode('utf-8')

            # after that try to get the params
            if len(sys.argv) > 2:
                params = sys.argv[2][1:]
                if len(params) > 0:
                    self._uri = self._uri + '?' + params

                    self._params = {}
                    params = dict(urlparse.parse_qsl(params))
                    for _param in params:
                        item = params[_param]
                        self._params[_param] = item.decode('utf-8')

        self._ui = None
        self._video_playlist = None
        self._audio_playlist = None
        self._video_player = None
        self._audio_player = None
        self._plugin_handle = int(sys.argv[1]) if len(sys.argv) > 1 else None
        self._plugin_id = plugin_id or self._addon.getAddonInfo('id')
        self._plugin_name = plugin_name or self._addon.getAddonInfo('name')
        self._version = self._addon.getAddonInfo('version')
        self._native_path = xbmc.translatePath(self._addon.getAddonInfo('path'))
        self._settings = XbmcPluginSettings(self._addon)

        """
        Set the data path for this addon and create the folder
        """
        self._data_path = xbmc.translatePath('special://profile/addon_data/%s' % self._plugin_id)
        if isinstance(self._data_path, str):
            self._data_path = self._data_path.decode('utf-8')
        if not xbmcvfs.exists(self._data_path):
            xbmcvfs.mkdir(self._data_path)
项目:plugin.video.youtube    作者:Kolifanes    | 项目源码 | 文件源码
def __init__(self, path='/', params=None, plugin_name=u'', plugin_id=u'', override=True):
        AbstractContext.__init__(self, path, params, plugin_name, plugin_id)

        if plugin_id:
            self._addon = xbmcaddon.Addon(id=plugin_id)
        else:
            self._addon = xbmcaddon.Addon()
            pass

        self._system_version = None

        """
        I don't know what xbmc/kodi is doing with a simple uri, but we have to extract the information from the
        sys parameters and re-build our clean uri.
        Also we extract the path and parameters - man, that would be so simple with the normal url-parsing routines.
        """
        # first the path of the uri
        if override:
            self._uri = sys.argv[0]
            comps = urlparse.urlparse(self._uri)
            self._path = urllib.unquote(comps.path).decode('utf-8')

            # after that try to get the params
            if len(sys.argv) > 2:
                params = sys.argv[2][1:]
                if len(params) > 0:
                    self._uri = self._uri + '?' + params

                    self._params = {}
                    params = dict(urlparse.parse_qsl(params))
                    for _param in params:
                        item = params[_param]
                        self._params[_param] = item.decode('utf-8')
                        pass
                    pass
                pass

        self._ui = None
        self._video_playlist = None
        self._audio_playlist = None
        self._video_player = None
        self._audio_player = None
        self._plugin_handle = int(sys.argv[1]) if len(sys.argv) > 1 else None
        self._plugin_id = plugin_id or self._addon.getAddonInfo('id')
        self._plugin_name = plugin_name or self._addon.getAddonInfo('name')
        self._version = self._addon.getAddonInfo('version')
        self._native_path = xbmc.translatePath(self._addon.getAddonInfo('path'))
        self._settings = XbmcPluginSettings(self._addon)

        """
        Set the data path for this addon and create the folder
        """
        self._data_path = xbmc.translatePath('special://profile/addon_data/%s' % self._plugin_id)
        if isinstance(self._data_path, str):
            self._data_path = self._data_path.decode('utf-8')
            pass
        if not xbmcvfs.exists(self._data_path):
            xbmcvfs.mkdir(self._data_path)
            pass
        pass