当前位置: 首页>>代码示例>>Python>>正文


Python xbmcvfs.mkdir函数代码示例

本文整理汇总了Python中xbmcvfs.mkdir函数的典型用法代码示例。如果您正苦于以下问题:Python mkdir函数的具体用法?Python mkdir怎么用?Python mkdir使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了mkdir函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: add_to_addon_favourites

def add_to_addon_favourites(name,url,iconimage):
	name = name.replace("[b]","").replace("[/b]","").replace("[color orange]","").replace("[/color]","").replace("[B]","").replace("[/B]","")
	if "runplugin" in url:
		match = re.compile("url=(.+?)&mode=(.+?)&").findall(url.replace(";",""))
		for url,mode in match:
			favourite_text = str(name) + " (" + str(url) + ")|" + str(mode) + "|" + str(url) + '|' + str(iconimage)
			favouritetxt = os.path.join(pastaperfil,"Favourites",url.replace(":","").replace("/","") + ".txt")
			if not xbmcvfs.exists(os.path.join(pastaperfil,"Favourites")): xbmcvfs.mkdir(os.path.join(pastaperfil,"Favourites"))
			save(favouritetxt, favourite_text)
			xbmc.executebuiltin("Notification(%s,%s,%i,%s)" % (translate(40000), translate(40148), 1,addonpath+"/icon.png"))
	else:
		if "sop://" in url:
			tipo = "sopcast"
			if not iconimage: iconimage = os.path.join(addonpath,'resources','art','sopcast_logo.jpg')
		elif "acestream://" in url:
			tipo = "acestream"
			if not iconimage: iconimage = os.path.join(addonpath,'resources','art','acelogofull.jpg')
		elif ".torrent" in url:
			tipo = "acestream"
			if not iconimage: iconimage = os.path.join(addonpath,'resources','art','acelogofull.jpg')
		elif ".acelive" in url:
			tipo = "acestream"
			if not iconimage: iconimage = os.path.join(addonpath,'resources','art','acelogofull.jpg')		
		else:
			if len(url) < 30: tipo = "sopcast"
			else: tipo = "acestream"
		if tipo == "sopcast":
			favourite_text = str(name) + " (" + str(url) + ")|" + str(2) + "|" + str(url) + '|' + str(iconimage)
		elif tipo == "acestream":
			favourite_text = str(name) + " (" + str(url) + ")|" + str(1) + "|" + str(url) + '|' + str(iconimage) 
		favouritetxt = os.path.join(pastaperfil,"Favourites",url.replace(":","").replace("/","") + ".txt")
		if not xbmcvfs.exists(os.path.join(pastaperfil,"Favourites")): xbmcvfs.mkdir(os.path.join(pastaperfil,"Favourites"))
		save(favouritetxt, favourite_text)
		xbmc.executebuiltin("Notification(%s,%s,%i,%s)" % (translate(40000), translate(40148), 1,addonpath+"/icon.png"))
		xbmc.executebuiltin("Container.Refresh")
开发者ID:Alsocogi,项目名称:repository.catoal,代码行数:35,代码来源:favourites.py

示例2: addSeriesToLibrary

def addSeriesToLibrary(seriesID, seriesTitle, season, singleUpdate=True):
    seriesFolderName = (''.join(c for c in unicode(seriesTitle, 'utf-8') if c not in '/\\:?"*|<>')).strip(' .')
    seriesDir = os.path.join(libraryFolderTV, seriesFolderName)
    if not os.path.isdir(seriesDir):
        xbmcvfs.mkdir(seriesDir)
    content = getSeriesInfo(seriesID)
    content = json.loads(content)
    for test in content["episodes"]:
        for item in test:
            episodeSeason = str(item["season"])
            seasonCheck = True
            if season:
                seasonCheck = episodeSeason == season
            if seasonCheck:
                seasonDir = os.path.join(seriesDir, "Season "+episodeSeason)
                if not os.path.isdir(seasonDir):
                    xbmcvfs.mkdir(seasonDir)
                episodeID = str(item["episodeId"])
                episodeNr = str(item["episode"])
                episodeTitle = item["title"].encode('utf-8')
                if len(episodeNr) == 1:
                    episodeNr = "0"+episodeNr
                seasonNr = episodeSeason
                if len(seasonNr) == 1:
                    seasonNr = "0"+seasonNr
                filename = "S"+seasonNr+"E"+episodeNr+" - "+episodeTitle+".strm"
                filename = (''.join(c for c in unicode(filename, 'utf-8') if c not in '/\\:?"*|<>')).strip(' .')
                fh = xbmcvfs.File(os.path.join(seasonDir, filename), 'w')
                fh.write("plugin://plugin.video.netflixbmc/?mode=playVideo&url="+episodeID)
                fh.close()
    if updateDB and singleUpdate:
        xbmc.executebuiltin('UpdateLibrary(video)')
开发者ID:DayVeeBoi,项目名称:addonscriptorde-beta-repo,代码行数:32,代码来源:default.py

示例3: traverse

    def traverse(self, path, cacheType, folderID, savePublic, level):
        import os
        import xbmcvfs

        xbmcvfs.mkdir(path)

        folders = self.getFolderList(folderID)
        files = self.getMediaList(folderID,cacheType)

        if files:
            for media in files:
                filename = xbmc.translatePath(os.path.join(path, media.title+'.strm'))
                strmFile = open(filename, "w")

                strmFile.write(self.PLUGIN_URL+'?mode=streamURL&url=' + self.FILE_URL+ media.id +'\n')
                strmFile.close()

        if folders and level == 1:
            count = 1
            progress = xbmcgui.DialogProgress()
            progress.create(self.addon.getLocalizedString(30000),self.addon.getLocalizedString(30036),'\n','\n')

            for folder in folders:
                max = len(folders)
                progress.update(count/max*100,self.addon.getLocalizedString(30036),folder.title,'\n')
                self.traverse( path+'/'+folder.title + '/',cacheType,folder.id,savePublic,0)
                count = count + 1

        if folders and level == 0:
            for folder in folders:
                self.traverse( path+'/'+folder.title + '/',cacheType,folder.id,savePublic,0)
开发者ID:JoKeRzBoX,项目名称:KODI-Hive,代码行数:31,代码来源:cloudservice.py

示例4: blur

def blur(input_img, radius=25):
    if not input_img:
        return {}
    if not xbmcvfs.exists(IMAGE_PATH):
        xbmcvfs.mkdir(IMAGE_PATH)
    input_img = utils.translate_path(urllib.unquote(input_img.encode("utf-8")))
    input_img = input_img.replace("image://", "").rstrip("/")
    cachedthumb = xbmc.getCacheThumbName(input_img)
    filename = "%s-radius_%i.png" % (cachedthumb, radius)
    targetfile = os.path.join(IMAGE_PATH, filename)
    vid_cache_file = os.path.join("special://profile/Thumbnails/Video", cachedthumb[0], cachedthumb)
    cache_file = os.path.join("special://profile/Thumbnails", cachedthumb[0], cachedthumb[:-4] + ".jpg")
    if xbmcvfs.exists(targetfile):
        img = PIL.Image.open(targetfile)
        return {"ImageFilter": targetfile,
                "ImageColor": get_colors(img)}
    try:
        if xbmcvfs.exists(cache_file):
            utils.log("image already in xbmc cache: " + cache_file)
            img = PIL.Image.open(utils.translate_path(cache_file))
        elif xbmcvfs.exists(vid_cache_file):
            utils.log("image already in xbmc video cache: " + vid_cache_file)
            img = PIL.Image.open(utils.translate_path(vid_cache_file))
        else:
            xbmcvfs.copy(input_img, targetfile)
            img = PIL.Image.open(targetfile)
        img.thumbnail((200, 200), PIL.Image.ANTIALIAS)
        imgfilter = MyGaussianBlur(radius=radius)
        img = img.convert('RGB').filter(imgfilter)
        img.save(targetfile)
    except Exception:
        utils.log("Could not get image for %s" % input_img)
        return {}
    return {"ImageFilter": targetfile,
            "ImageColor": get_colors(img)}
开发者ID:phil65,项目名称:script.module.kodi65,代码行数:35,代码来源:imagetools.py

示例5: series

def series(series_id, series_title, season, single_update=True):
    filename = utility.clean_filename(series_title, ' .')
    series_file = xbmc.translatePath(utility.tv_dir() + filename)
    if not xbmcvfs.exists(series_file):
        xbmcvfs.mkdir(series_file)
    content = get.series_info(series_id)
    content = json.loads(content)['video']['seasons']
    for test in content:
        episode_season = unicode(test['seq'])
        if episode_season == season or season == '':
            season_dir = utility.create_pathname(series_file, test['title'])
            if not xbmcvfs.exists(season_dir):
                xbmcvfs.mkdir(season_dir)
            for item in test['episodes']:
                episode_id = unicode(item['episodeId'])
                episode_nr = unicode(item['seq'])
                episode_title = item['title']
                if len(episode_nr) == 1:
                    episode_nr = '0' + episode_nr
                season_nr = episode_season
                if len(season_nr) == 1:
                    season_nr = '0' + season_nr
                filename = 'S' + season_nr + 'E' + episode_nr + ' - ' + episode_title + '.strm'
                filename = utility.clean_filename(filename, ' .')
                file_handler = xbmcvfs.File(utility.create_pathname(season_dir, filename), 'w')
                file_handler.write(
                    utility.encode('plugin://%s/?mode=play_video&url=%s' % (utility.addon_id, episode_id)))
                file_handler.close()
    if utility.get_setting('update_db') and single_update:
        xbmc.executebuiltin('UpdateLibrary(video)')
开发者ID:hennroja,项目名称:plugin.video.netflix,代码行数:30,代码来源:library.py

示例6: download

def download(name, url):
            my_addon = xbmcaddon.Addon()
            desty= my_addon.getSetting('downloads_folder')
            if not xbmcvfs.exists(desty):
                xbmcvfs.mkdir(desty)

            title=name
            name=re.sub('[^-a-zA-Z0-9_.() ]+', '', name)
            name=name.rstrip('.')
            ext = os.path.splitext(urlparse.urlparse(url).path)[1][1:]
            if not ext in ['mp4', 'mkv', 'flv', 'avi', 'mpg', 'mp3']: ext = 'mp4'
            filename = name + '.' + ext
      
            

            dest = os.path.join(desty, filename)
            new=my_addon.getSetting('new_downloader')
            if  new=='false':
                from lib.modules import commondownloader
                commondownloader.download(url, dest, 'Croatia On Demand')
            else:
                content = int(urllib.urlopen(url).info()['Content-Length'])
                size = 1024 * 1024
                mb   = content / (1024 * 1024)
                if xbmcgui.Dialog().yesno('Croatia On Demand - Potvrda preuzimanja', filename, 'Veličina datoteke je %dMB' % mb, 'Nastaviti s preuzimanjem?', 'Nastavi',  'Prekini') == 1:
                  return
                import SimpleDownloader as downloader
                downloader = downloader.SimpleDownloader()
                params = { "url": url, "download_path": desty, "Title": title }
                downloader.download(filename, params)
开发者ID:corpusculus,项目名称:kodi_serije,代码行数:30,代码来源:utils.py

示例7: write_strm

def write_strm(name, fold, videoid, show=None, season=None, episode=None, startpoint = None, endpoint = None, artist='', album='', song='', year='', type=''):
    #dev.log('strm('+name+', '+fold+', '+videoid+')')
    movieLibrary = vars.tv_folder #The path we should save in is the vars.tv_folder setting from the addon settings
    if type=='musicvideo':
        movieLibrary = vars.musicvideo_folder
    sysname = urllib.quote_plus(videoid) #Escape strings in the videoid if needed
    enc_name = dev.legal_filename(name) #Encode the filename to a legal filename
    
    if vars.__settings__.getSetting("strm_link") == "Youtube Library":
        if type == 'musicvideo':
            content = 'plugin://plugin.video.youtubelibrary/?mode=playmusicvideo'
            if startpoint != None:
                content += '&startpoint='+startpoint
            if endpoint != None:
                content += '&endpoint='+endpoint
            content += '&id=%s&artist=%s&song=%s&album=%s&year=%s&filename=%s' % (sysname, artist, song, album, year, enc_name) #Set the content of the strm file with a link back to this addon for playing the video 
        else:
            content = 'plugin://plugin.video.youtubelibrary/?mode=play&id=%s&show=%s&season=%s&episode=%s&filename=%s' % (sysname, show, season, episode, enc_name) #Set the content of the strm file with a link back to this addon for playing the video
    else:
        content = vars.KODI_ADDONLINK+'%s' % ( sysname) #Set the content of the strm file with a link to the official Kodi Youtube Addon

    xbmcvfs.mkdir(movieLibrary) #Create the maindirectory if it does not exists yet
    
    folder = os.path.join(movieLibrary, fold) #Set the folder to the maindir/dir
    xbmcvfs.mkdir(folder) #Create this subfolder if it does not exist yet

    stream = os.path.join(folder, enc_name + '.strm') #Set the file to maindir/name/name.strm
    file = xbmcvfs.File(stream, 'w') #Open / create this file for writing
    file.write(str(content.encode('UTF-8'))) #Write the content in the file
    file.close() #Close the file
    dev.log('write_strm: Written strm file: '+fold+'/'+enc_name+'.strm')
    return enc_name
开发者ID:c0ns0le,项目名称:YCBuilds,代码行数:32,代码来源:generators.py

示例8: _readHosts

    def _readHosts(self):
        data_dir = utils.data_dir()

        if(not xbmcvfs.exists(data_dir)):
            xbmcvfs.mkdir(data_dir)

        try:
            doc = xml.dom.minidom.parse(xbmc.translatePath(data_dir + "hosts.xml"))

            for node in doc.getElementsByTagName("host"):
                self.hosts.append(XbmcHost(str(node.getAttribute("name")),str(node.getAttribute("address")),int(node.getAttribute("port"))))

            #sort the lists
            self._sort()
            
        except IOError:
            #the file doesn't exist, create it
            doc = xml.dom.minidom.Document()
            rootNode = doc.createElement("hosts")
            doc.appendChild(rootNode)

            #write the file
            f = open(xbmc.translatePath(data_dir + "hosts.xml"),'w')
            doc.writexml(f,"   ")
            f.close()
开发者ID:bstrdsmkr,项目名称:script.sendto,代码行数:25,代码来源:hostmanager.py

示例9: makeM3U

def makeM3U(links):
    log("makeM3U")
    STRM_CACHE_LOC = xbmc.translatePath(get_setting("write_folder"))
    if not xbmcvfs.exists(STRM_CACHE_LOC):
        xbmcvfs.mkdir(STRM_CACHE_LOC)
    flepath = os.path.join(STRM_CACHE_LOC, "ustvnow.m3u")
    if xbmcvfs.exists(flepath):
        xbmcvfs.delete(flepath)
    playlist = open(flepath, "w")
    # Extended M3U format used here
    playlist.write("#EXTM3U" + "\n")
    if links:
        for l in links:
            # Add name based filename
            if int(get_setting("write_type")) == 3:
                playlist.write(
                    '#EXTINF:-1, tvg-id="'
                    + l["name"]
                    + '" tvg-logo="'
                    + l["name"]
                    + '" tvg-name="'
                    + l["name"]
                    + '"  group-title="USTVnow",'
                    + l["name"]
                    + "\n"
                )
            else:
                playlist.write("#EXTINF:" + l["name"] + "\n")
            # Write relative location of file
            playlist.write(l["url"] + "\n")
    playlist.close()
开发者ID:bialagary,项目名称:mw,代码行数:31,代码来源:Addon.py

示例10: __handleCompressedFile

	def __handleCompressedFile(self, gui, filext, rom, emuParams):

		log.info("__handleCompressedFile")

		# Note: Trying to delete temporary files (from zip or 7z extraction) from last run
		# Do this before launching a new game. Otherwise game could be deleted before launch
		tempDir = os.path.join(util.getTempDir(), 'extracted', self.romCollection.name)
		# check if folder exists
		if not xbmcvfs.exists(tempDir +'\\'):
			log.info("Create temporary folder: " +tempDir)
			xbmcvfs.mkdir(tempDir)

		try:
			if xbmcvfs.exists(tempDir +'\\'):
				log.info("Trying to delete temporary rom files")
				#can't use xbmcvfs.listdir here as it seems to cache the file list and RetroPlayer won't find newly created files anymore
				files = os.listdir(tempDir)
				for f in files:
					#RetroPlayer places savestate files next to the roms. Don't delete these files.
					fname, ext = os.path.splitext(f)
					if(ext not in ('.sav', '.xml', '.png')):
						xbmcvfs.delete(os.path.join(tempDir, f))
		except Exception, (exc):
			log.error("Error deleting files after launch emu: " + str(exc))
			gui.writeMsg(util.localize(32036) + ": " + str(exc))
开发者ID:bruny,项目名称:romcollectionbrowser,代码行数:25,代码来源:launcher.py

示例11: setThumbnail

    def setThumbnail(self, service, url=''):
        if self.cachePath == '':
            cachePath = service.settings.cachePath
        else:
            cachePath = self.cachePath

        if cachePath == '':
            cachePath = xbmcgui.Dialog().browse(0,service.addon.getLocalizedString(30136), 'files','',False,False,'')
            service.addon.setSetting('cache_folder', cachePath)
            self.cachePath = cachePath

        if url == '':
            url = self.package.file.thumbnail

        #simply no thumbnail
        if url == '':
            return ""

        cachePath = str(cachePath) + str(self.package.file.id) + '/'
        if not xbmcvfs.exists(cachePath):
            xbmcvfs.mkdir(cachePath)
        if not xbmcvfs.exists(cachePath + str(self.package.file.id) + '.jpg'):
            service.downloadPicture(url, cachePath + str(self.package.file.id) + '.jpg')
            print url
        return cachePath + str(self.package.file.id) + '.jpg'
开发者ID:azumimuo,项目名称:family-xbmc-addon,代码行数:25,代码来源:cache.py

示例12: __init__

	def __init__(self):
		self.folder = xbmc.translatePath(xbmcaddon.Addon().getAddonInfo('profile')).decode("utf-8")
		if not xbmcvfs.exists(self.folder):
			xbmcvfs.mkdir(self.folder)
		self.file_path = self.folder + "shared_data.json"
		with open(self.file_path, "w") as file:
			file.write("{}")
开发者ID:maxgalbu,项目名称:xbmc.plugin.video.nba,代码行数:7,代码来源:shareddata.py

示例13: addToLibrary

def addToLibrary(url):
    if mysettings.getSetting("cust_Lib_path") == "true":
        newlibraryFolderMovies = custLibFolder
    else:
        newlibraryFolderMovies = libraryFolderMovies
    movieFolderName = ("".join(c for c in unicode(gname, "utf-8") if c not in '/\\:?"*|<>')).strip(" .")
    newMovieFolderName = ""
    finalName = ""
    keyb = xbmc.Keyboard(name, "[COLOR ffffd700]Enter Title[/COLOR]")
    keyb.doModal()
    if keyb.isConfirmed():
        newMovieFolderName = keyb.getText()
    if newMovieFolderName != "":
        dir = os.path.join(newlibraryFolderMovies, newMovieFolderName)
        finalName = newMovieFolderName
    else:
        dir = os.path.join(newlibraryFolderMovies, movieFolderName)
        finalName = movieFolderName

    if not os.path.isdir(dir):
        xbmcvfs.mkdir(dir)
        fh = xbmcvfs.File(os.path.join(dir, finalName + ".strm"), "w")
        fh.write(
            "plugin://" + addonID + "/?mode=3&url=" + urllib.quote_plus(url) + "&name=" + urllib.quote_plus(finalName)
        )
        fh.close()
开发者ID:quyletran,项目名称:traitravinh.repository.xbmc,代码行数:26,代码来源:movihd.py

示例14: _moveToThemeFolder

    def _moveToThemeFolder(self, directory):
        log("moveToThemeFolder: path = %s" % directory)

        # Handle the case where we have a disk image
        if (os_path_split(directory)[1] == 'VIDEO_TS') or (os_path_split(directory)[1] == 'BDMV'):
            directory = os_path_split(directory)[0]

        dirs, files = list_dir(directory)
        for aFile in files:
            m = re.search(Settings.getThemeFileRegEx(directory), aFile, re.IGNORECASE)
            if m:
                srcpath = os_path_join(directory, aFile)
                log("fetchAllMissingThemes: Found match: %s" % srcpath)
                targetpath = os_path_join(directory, Settings.getThemeDirectory())
                # Make sure the theme directory exists
                if not dir_exists(targetpath):
                    try:
                        xbmcvfs.mkdir(targetpath)
                    except:
                        log("fetchAllMissingThemes: Failed to create directory: %s" % targetpath, True, xbmc.LOGERROR)
                        break
                else:
                    log("moveToThemeFolder: directory already exists %s" % targetpath)
                # Add the filename to the path
                targetpath = os_path_join(targetpath, aFile)
                if not xbmcvfs.rename(srcpath, targetpath):
                    log("moveToThemeFolder: Failed to move file from %s to %s" % (srcpath, targetpath))
开发者ID:angelblue05,项目名称:script.tvtunes,代码行数:27,代码来源:plugin.py

示例15: installPy7ForAndroid

def installPy7ForAndroid():
    if not os.path.exists(pastaperfil): xbmcvfs.mkdir(pastaperfil)
    #Hack to get xbmc app id
    xbmcfolder=xbmc.translatePath(addonpath).split("/")
    found = False
    if 1==1:#settings.getSetting('auto_appid') == 'true':
        i = 0
        for folder in xbmcfolder:
            if folder.count('.') >= 2 and folder != addon_id :
                found = True
                break
            else:
                i+=1
        if found == True:
            uid = os.getuid()
            app_id = xbmcfolder[i]
    else:
        if settings.getSetting('custom_appid') != '':
            uid = os.getuid()
            app_id = settings.getSetting('custom_appid')
            found = True

    if found == True:
        settings.setSetting('app_id',app_id)
        if "arm" in os.uname()[4]:
            python7bundle = os.path.join(pastaperfil,python7_apk_arm.split("/")[-1])
            download_tools().Downloader(python7_apk_arm,python7bundle,"downloading python7 for Android Arm","pycrypto")
        else:
            python7bundle = os.path.join(pastaperfil,python7_apk_x86.split("/")[-1])
            download_tools().Downloader(python7_apk_x86,python7bundle,"downloading python7 for Android x86","pycrypto")
        if tarfile.is_tarfile(python7bundle):
            download_tools().extract(python7bundle,pastaperfil)
            download_tools().remove(python7bundle)
        python7folder = os.path.join(pastaperfil,"python7")
        xbmc_data_path = os.path.join("/data", "data", app_id)
        if os.path.exists(xbmc_data_path) and uid == os.stat(xbmc_data_path).st_uid:
            android_binary_dir = os.path.join(xbmc_data_path, "files", app_id)
            if not os.path.exists(android_binary_dir): os.makedirs(android_binary_dir)
                android_exec_folder = os.path.join(android_binary_dir,"python7")
                if not os.path.exists(android_exec_folder): os.makedirs(android_exec_folder)
                else:
                    #clean install for android - delete old folder
                    print android_exec_folder
                    try:
                        os.system("chmod -R 777 "+android_exec_folder+"/*")
                        os.system("rm -r '"+android_exec_folder+"'")
                    except: pass
                    try: os.makedirs(android_exec_folder)
                    except: pass
                xbmc.sleep(200)
        recursive_overwrite(python7folder, android_exec_folder, ignore=None)
        pythonbin = os.path.join(android_exec_folder,"python","bin","python")
        st = os.stat(pythonbin)
        import stat
        os.chmod(pythonbin, st.st_mode | stat.S_IEXEC)
        if os.path.exists(python7folder):
        try:
            os.system("chmod -R 777 "+python7folder+"/*")
            os.system("rm -r '"+python7folder+"'")
        except: pass                
开发者ID:Amoktaube,项目名称:ShaniXBMCWork2,代码行数:60,代码来源:python7Android.py


注:本文中的xbmcvfs.mkdir函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。