本文整理汇总了Python中xbmcvfs.mkdirs函数的典型用法代码示例。如果您正苦于以下问题:Python mkdirs函数的具体用法?Python mkdirs怎么用?Python mkdirs使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mkdirs函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self):
run = Prop("run")
if (run) and (time.time() < float(run) + 3):
return
Prop("run", str(time.time()))
Prop("stamp", _stamp)
self.once = True
self.abort = False
self.mesg = None
self.station = None
self.stations = None
self.songs = {}
self.pithos = mypithos.Pithos()
self.player = xbmc.Player()
self.playlist = xbmc.PlayList(xbmc.PLAYLIST_MUSIC)
self.ahead = {}
self.queue = collections.deque()
self.prof = Val("prof")
self.wait = {"auth": 0, "stations": 0, "flush": 0, "scan": 0, "next": 0}
self.silent = xbmc.translatePath("special://home/addons/%s/resources/media/silent.m4a" % _id)
musicbrainzngs.set_useragent("kodi.%s" % _id, Val("version"))
xbmcvfs.mkdirs(xbmc.translatePath(Val("cache")).decode("utf-8"))
xbmcvfs.mkdirs(xbmc.translatePath(Val("library")).decode("utf-8"))
开发者ID:ClashTheBunny,项目名称:gominoa-xbmc-addons,代码行数:26,代码来源:pandoki.py
示例2: download_subtitle
def download_subtitle(self, url):
url = BASE_URL + url
(response, srt) = self.__get_url(url)
if not hasattr(response, 'info') or 'Content-Disposition' not in response.info():
return
cd = response.info()['Content-Disposition']
r = re.search('filename="(.*)"', cd)
if r:
filename = r.group(1)
else:
filename = 'addic7ed_subtitle.srt'
filename = re.sub('[^\x00-\x7F]', '', filename)
final_path = os.path.join(kodi.get_setting('subtitle-folder'), filename)
final_path = kodi.translate_path(final_path)
if not xbmcvfs.exists(os.path.dirname(final_path)):
try:
try: xbmcvfs.mkdirs(os.path.dirname(final_path))
except: os.mkdir(os.path.dirname(final_path))
except:
log_utils.log('Failed to create directory %s' % os.path.dirname(final_path), log_utils.LOGERROR)
raise
with open(final_path, 'w') as f:
f.write(srt)
return final_path
开发者ID:AMOboxTV,项目名称:AMOBox.LegoBuild,代码行数:27,代码来源:srt_scraper.py
示例3: mkdirs
def mkdirs(fle):
FileAccess.log('mkdirs ' + fle)
try:
xbmcvfs.mkdirs(fle)
return True
except:
return False
开发者ID:PseudoTV,项目名称:PseudoTV_Live,代码行数:7,代码来源:FileAccess.py
示例4: add2lib
def add2lib( url, name, infol, img, fanart, year ):
img = 'http://oi62.tinypic.com/dvgj1t.jpg'
addon.log('Add To Library %s , %s, %s' % (name,year,url))
path = xbmc.translatePath( addon.get_setting('movie-folder') )
string = 'plugin://plugin.video.mutttsnutz/?mode=playstream&url='+url+'&name='+name+'&infol='
filename = '%s.strm' % name
path = xbmc.makeLegalFilename( xbmc.translatePath(os.path.join( path, name, filename )))
if not xbmcvfs.exists(os.path.dirname(path)):
try:
try: xbmcvfs.mkdirs(os.path.dirname(path))
except: os.mkdir(os.path.dirname(path))
except:
addon.log('FAILED to create directory')
if xbmcvfs.exists(path):
addon.log( name+' Already in the library' )
notification( addon.get_name()+' allready added', name, img)
return
notification( addon.get_name()+' adding to library', name+' adding to library', img)
strm = xbmcvfs.File(path, 'w')
strm.write(string)
strm.close()
xbmc.executebuiltin("UpdateLibrary(video)")
开发者ID:jas0npc,项目名称:kodi,代码行数:27,代码来源:default.py
示例5: writeConfig
def writeConfig(cfile, value=''):
cfgfile = os.path.join(configpath, cfile)
cfglockfile = os.path.join(configpath, cfile + '.lock')
if not xbmcvfs.exists(configpath):
xbmcvfs.mkdirs(configpath)
while True:
if not xbmcvfs.exists(cfglockfile):
l = xbmcvfs.File(cfglockfile, 'w')
l.write(str(time.time()))
l.close()
if value == '':
xbmcvfs.delete(cfgfile)
else:
f = xbmcvfs.File(cfgfile, 'w')
f.write(value.__str__())
f.close()
xbmcvfs.delete(cfglockfile)
xbmcvfs.delete(cfglockfile)
return True
else:
l = xbmcvfs.File(cfglockfile)
modified = float(l.read())
l.close()
if time.time() - modified > 0.1:
xbmcvfs.delete(cfglockfile)
开发者ID:Sandmann79,项目名称:xbmc,代码行数:27,代码来源:common.py
示例6: Download
def Download(ID,lang,filename,key):
URLBASE=__addon__.getSetting("BASEURL")
url=URLBASE+"/he/api/subtitle/download/"+lang+"/?sub_id="+ID+"&v="+ urllib.quote(filename, safe='')+"&key="+key
subtitle_list = []
if xbmcvfs.exists(__temp__):
shutil.rmtree(__temp__)
xbmcvfs.mkdirs(__temp__)
the_page=get_token()
values = {'token' : the_page['token'], 'user': the_page['user'] }
data = urllib.urlencode(values)
req = urllib2.Request(url, data)
response = urllib2.urlopen(req)
zipdata= response.read()
zipfilename=os.path.join(__temp__,filename)
output = open(zipfilename,'wb')
output.write(zipdata)
output.close()
zfobj = zipfile.ZipFile(zipfilename)
for subname in zfobj.namelist():
if subname.find(".srt") >0:
zfobj.extract(subname,__temp__)
subtitle_list.append(os.path.join(__temp__,subname))
return subtitle_list
开发者ID:lidormalicb,项目名称:service.subtitles.subcenterorg,代码行数:26,代码来源:subcenter.py
示例7: playlist_path
def playlist_path(pcs_file_path, stream):
user_info = get_user_info()
user_name = user_info['username']
user_cookie = user_info['cookie']
user_tokens = user_info['tokens']
if stream:
playlist_data = pcs.get_streaming_playlist(user_cookie, pcs_file_path, stream)
if playlist_data:
raw_dir = os.path.dirname(pcs_file_path)
m = re.search('\/(.*)', raw_dir)
dirname = m.group(1)
basename = os.path.basename(pcs_file_path)
r = re.search('(.*)\.(.*)$', basename)
filename = ''.join([r.group(1), stream, '.m3u8'])
dirpath = os.path.join(utils.data_dir(), user_name, dirname)
if not xbmcvfs.exists(dirpath):
xbmcvfs.mkdirs(dirpath)
filepath = os.path.join(dirpath, filename)
tmpFile = xbmcvfs.File(filepath, 'w')
tmpFile.write(bytearray(playlist_data, 'utf-8'))
return filepath
else:
dialog.notification('', u'无法打开视频,请尝试其他清晰度', xbmcgui.NOTIFICATION_INFO, 6000)
return None
else:
url = pcs.get_download_link(user_cookie, user_tokens, pcs_file_path)
return url
开发者ID:fanxiaoliang,项目名称:xbmc-addons-chinese,代码行数:28,代码来源:default.py
示例8: setThumbnail
def setThumbnail(self, service, url=''):
#load cachePath if not already loaded
if self.cachePath == '':
self.cachePath = service.settings.cachePath
# there is no cache path setting or the setting is unset -- we should assume user does not want to use caching
if not service.settings.cacheThumbnails or self.cachePath == '':
if url == '':
return self.package.file.thumbnail
else:
return url
if url == '':
url = self.package.file.thumbnail
#simply no thumbnail
if url == '':
return ""
#user doesn't want to cache thumbnails
if not service.settings.cacheThumbnails:
return url
cachePath = str(self.cachePath) + str(self.package.file.id) + '/'
cacheFile = str(self.cachePath) + str(self.package.file.id) + '.jpg'
if not xbmcvfs.exists(cachePath):
xbmcvfs.mkdirs(cachePath)
if not xbmcvfs.exists(cacheFile):
cacheFile = service.downloadGeneralFile(url, cacheFile)
if cacheFile is None:
return url
return cacheFile
开发者ID:azumimuo,项目名称:family-xbmc-addon,代码行数:35,代码来源:cache.py
示例9: sync
def sync(self):
if self._state == self.OBJECT_SKIP:
return
try:
self._state = self.inSync()
if self._state == self.OBJECT_2_DOWNLOAD:
log_debug('Create folder: %s'%self._localPath)
xbmcvfs.mkdirs( self._localPath.encode("utf-8") )
self.updateTimeStamp()
elif self._state == self.OBJECT_2_UPLOAD:
log_error('Can\'t upload folder: %s'%self._localPath)
#TODO Add files if new files found local
#TODO: modify timestamp of dir...
elif self._state == self.OBJECT_2_REMOVE:
log_debug('Remove folder: %s'%self._localPath)
shutil.rmtree(self._localPath)
elif self._state == self.OBJECT_ADD_CHILD:
#TODO
pass
elif self._state == self.OBJECT_IN_SYNC:
pass
else:
log_error('Unknown folder status(%s) for : %s!'%(self._state, self.path))
except Exception, e:
log_error('Exception occurred for folder %s' % self._localPath)
log_error( traceback.format_exc() )
if(self._failure):
#failure happened before... So skip this item in all the next syncs!
self._state = self.OBJECT_SKIP
log_error('Skipping folder in next syncs: %s'% self._localPath)
self._failure = True
开发者ID:kodiline,项目名称:repository.Play-Mix-EVO,代码行数:31,代码来源:syncfolder.py
示例10: ensure_workdir
def ensure_workdir(workdir):
# Cleanup temp dir, we recommend you download/unzip your subs in temp
# folder and pass that to XBMC to copy and activate
if xbmcvfs.exists(workdir):
removeAll(workdir)
xbmcvfs.mkdirs(workdir)
return xbmcvfs.exists(workdir)
开发者ID:yoyano,项目名称:service.subtitles.subdivx,代码行数:7,代码来源:service.py
示例11: add_to_library
def add_to_library(video_type, url, title, img, year, imdbnum, movie_num=''):
try: IW_addon.log('Creating .strm for %s %s %s %s %s %s' % (video_type, title, imdbnum, url, img, year))
except: pass
if video_type == 'tvshow':
save_path = IW_addon.get_setting('tvshow-folder')
save_path = xbmc.translatePath(save_path)
strm_string = IW_addon.build_plugin_url(
{'mode': 'NightlyNewsSubMenu','dialog': '1'})
if year: title = '%s (%s)' % (title, year)
filename = filename_from_title(title + ' s1e1', 'movie')
title = re.sub(r'[^\w\-_\. ]', '_', title)
titles = title
final_path = os.path.join(save_path, title, filename)
final_path = xbmc.makeLegalFilename(final_path)
if not xbmcvfs.exists(os.path.dirname(final_path)):
try:
try: xbmcvfs.mkdirs(os.path.dirname(final_path))
except: os.path.mkdir(os.path.dirname(final_path))
except Exception, e:
try: IW_addon.log('Failed to create directory %s' % final_path)
except: pass
try:
file_desc = xbmcvfs.File(final_path, 'w')
file_desc.write(strm_string)
file_desc.close()
except Exception, e:
IW_addon.log('Failed to create .strm file: %s\n%s' % (final_path, e))
开发者ID:Spinalcracker,项目名称:infowars,代码行数:27,代码来源:default.py
示例12: _make_dir
def _make_dir(self, path, dir):
subpath = os.path.join(path, dir)
try:
if not xbmcvfs.exists(subpath): xbmcvfs.mkdirs(subpath)
except:
if not os.path.exists(subpath): os.makedirs(subpath)
return subpath
开发者ID:floooooWi,项目名称:Drawers,代码行数:7,代码来源:drawers.py
示例13: setSRT
def setSRT(self, service):
if not constants.CONST.SRT:
return
#load cachePath if not already loaded
if not service.settings.cacheSRT and self.cachePath == '':
self.cachePath = service.settings.cachePath
#only makes sense to cache SRT if the cachePath exists
if service.settings.cacheSRT and self.cachePath != '':
cachePath = str(self.cachePath) + '/' + str(self.package.file.id)+'/'
if not xbmcvfs.exists(cachePath):
xbmcvfs.mkdirs(cachePath)
srt = service.getSRT(self.package)
if srt:
for file in srt:
if not xbmcvfs.exists(str(cachePath) + str(file[0])):
service.downloadGeneralFile(file[1], str(cachePath) + str(file[0]))
self.srt.append(str(cachePath) + str(file[0]))
#fetch SRT URLs but we won't cache the files
else:
srt = service.getSRT(self.package)
if srt:
for file in srt:
self.srt.append(str(file[1]) + '|' + service.getHeadersEncoded())
开发者ID:ddurdle,项目名称:GDrive-for-KODI,代码行数:28,代码来源:cache.py
示例14: saveTorrent
def saveTorrent(self, torrentUrl):
#if not xbmcvfs.exists(torrentUrl) or re.match("^http.+$", torrentUrl):
if re.match("^magnet\:.+$", torrentUrl):
self.magnetLink = torrentUrl
self.magnetToTorrent(torrentUrl)
self.magnetLink = None
return self.torrentFile
else:
if not xbmcvfs.exists(self.torrentFilesPath): xbmcvfs.mkdirs(self.torrentFilesPath)
torrentFile = os.path.join(self.torrentFilesPath, self.md5(torrentUrl) + '.torrent')
try:
if not re.match("^[htps]+?://.+$|^://.+$", torrentUrl):
log('xbmcvfs.File for %s' % torrentUrl)
content = xbmcvfs.File(torrentUrl, "rb").read()
else:
log('request for %s' % torrentUrl)
content = self.makeRequest(torrentUrl)
localFile = xbmcvfs.File(torrentFile, "w+b")
localFile.write(content)
localFile.close()
except Exception, e:
log('Unable to rename torrent file from %s to %s in AnteoLoader::saveTorrent. Exception: %s' %
(torrentUrl, torrentFile, str(e)))
return
开发者ID:inpos,项目名称:plugin.video.torrenter,代码行数:25,代码来源:Anteoloader.py
示例15: setCC
def setCC(self, service):
if not constants.CONST.CC:
return
#load cachePath if not already loaded
if self.cachePath == '':
self.cachePath = service.settings.cachePath
# there is no cache path setting or the setting is unset -- we should assume user does not want to use caching
# CC files need to be cached (so they can be converted to SRT) -- don't do anything if we don't have the cachePath
if self.cachePath == '':
return
else:
cachePath = str(self.cachePath) + '/' + str(self.package.file.id)+'/'
if not xbmcvfs.exists(cachePath):
xbmcvfs.mkdirs(cachePath)
cachePath = str(cachePath) + str(self.package.file.id)
cc = service.getTTS(self.package.file.srtURL)
if cc:
for file in cc:
if not xbmcvfs.exists(cachePath + str(file[0])):
service.downloadTTS(file[1], str(cachePath) + str(file[0]))
self.srt.append(str(cachePath) + str(file[0]))
开发者ID:ddurdle,项目名称:GDrive-for-KODI,代码行数:25,代码来源:cache.py
示例16: mkdirs
def mkdirs(path):
# Will create all folders in path if needed
try:
xbmcvfs.mkdirs(path)
except:
os.makedirs(path)
return
开发者ID:TsUPeR,项目名称:xbmc-pneumatic,代码行数:7,代码来源:utils.py
示例17: saveTorrent
def saveTorrent(self, torrentUrl):
if not xbmcvfs.exists(torrentUrl) or re.match("^http.+$", torrentUrl):
if re.match("^magnet\:.+$", torrentUrl):
self.magnetLink = torrentUrl
self.magnetToTorrent(torrentUrl)
self.magnetLink = None
return self.torrentFile
else:
if not xbmcvfs.exists(self.torrentFilesPath): xbmcvfs.mkdirs(self.torrentFilesPath)
torrentFile = os.path.join(self.torrentFilesPath, self.md5(torrentUrl) + '.torrent')
try:
if not re.match("^http\:.+$", torrentUrl):
content = xbmcvfs.File(torrentUrl, "rb").read()
else:
request = urllib2.Request(torrentUrl)
request.add_header('Referer', torrentUrl)
request.add_header('Accept-encoding', 'gzip')
result = urllib2.urlopen(request)
if result.info().get('Content-Encoding') == 'gzip':
buf = StringIO(result.read())
f = gzip.GzipFile(fileobj=buf)
content = f.read()
else:
content = result.read()
localFile = xbmcvfs.File(torrentFile, "w+b")
localFile.write(content)
localFile.close()
except Exception, e:
print 'Unable to save torrent file from "' + torrentUrl + '" to "' + torrentFile + '" in Torrent::saveTorrent' + '. Exception: ' + str(
e)
return
开发者ID:sonics007,项目名称:plugin.video.torrenter,代码行数:32,代码来源:Anteoloader.py
示例18: writeMediaList
def writeMediaList(url, name, cType='Other'):
utils.addon_log('writeMediaList')
existInList = False
thelist = []
thefile = xbmc.translatePath(os.path.join(profile, 'MediaList.xml'))
theentry = '|'.join([cType, name.decode("utf-8"), url]) + '\n'
if not xbmcvfs.exists(profile):
xbmcvfs.mkdirs(profile)
if not xbmcvfs.exists(thefile):
open(thefile, 'a').close()
fle = codecs.open(thefile, "r", 'UTF-8')
thelist = fle.readlines()
fle.close()
del fle
if len(thelist) > 0:
for i in thelist:
if i.split('|',2)[1] == name:
thelist = stringUtils.replaceStringElem(thelist, theentry, theentry)
existInList = True
if existInList != True:
thelist.append(theentry)
with open(thefile.decode("utf-8"), 'w') as output_file:
for linje in thelist:
if not linje.startswith('\n'):
output_file.write(linje.strip().encode('utf-8') + '\n')
else:
output_file.write(linje.strip())
开发者ID:kodinerds,项目名称:repo,代码行数:31,代码来源:fileSys.py
示例19: resolve
def resolve(url):
actions = [
("plugin://plugin.video.yatp/?action=play&torrent=%s", "plugin.video.yatp", "YATP-Yet Another Torrent Player"),
("plugin://plugin.video.quasar/play?uri=%s", "plugin.video.quasar", "Quasar"),
]
if not xbmcvfs.exists(os.path.dirname(torrent_path)):
try:
xbmcvfs.mkdirs(os.path.dirname(torrent_path))
except:
os.mkdir(os.path.dirname(torrent_path))
file = urllib2.urlopen(url)
output = open(torrent_path, "wb")
output.write(file.read())
output.close()
choice = int(control.setting("torrentPlayer"))
action = actions[choice]
if choice == 0:
url = torrent_path
if addonInstaller.isInstalled(action[1]):
return action[0] % url
else:
control.infoDialog(
"Torrent player not installed. Install it or select a different torrent player.",
heading=action[2],
time=6000,
)
return ""
开发者ID:hieuhienvn,项目名称:hieuhien.vn,代码行数:30,代码来源:torrent.py
示例20: makeSTRM
def makeSTRM(filepath, filename, url):
filepath = stringUtils.multiRstrip(filepath.decode("utf-8"))
filename = filename.decode("utf-8")
utils.addon_log('makeSTRM')
filepath = os.path.join(STRM_LOC, filepath)
if not xbmcvfs.exists(filepath):
xbmcvfs.mkdirs(filepath)
fullpath = xbmc.translatePath(os.path.join(filepath, filename + '.strm'))
if xbmcvfs.exists(fullpath):
if addon.getSetting('Clear_Strms') == 'true':
x = 0 #xbmcvfs.delete(fullpath)
else:
return fullpath
else:
try:
fle = open(fullpath.encode("utf-8"), "w")
except:
fle = open(fullpath.decode("utf-8"), "w")
pass
fle.write("%s" % url)
fle.close()
del fle
return fullpath
开发者ID:kodinerds,项目名称:repo,代码行数:26,代码来源:fileSys.py
注:本文中的xbmcvfs.mkdirs函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论