本文整理汇总了Python中xbmcvfs.mkdirs方法的典型用法代码示例。如果您正苦于以下问题:Python xbmcvfs.mkdirs方法的具体用法?Python xbmcvfs.mkdirs怎么用?Python xbmcvfs.mkdirs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xbmcvfs
的用法示例。
在下文中一共展示了xbmcvfs.mkdirs方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: copytree
# 需要导入模块: import xbmcvfs [as 别名]
# 或者: from xbmcvfs import mkdirs [as 别名]
def copytree(path, dest):
''' Copy folder content from one to another.
'''
dirs, files = xbmcvfs.listdir(path)
if not xbmcvfs.exists(dest):
xbmcvfs.mkdirs(dest)
if dirs:
copy_recursive(path, dirs, dest)
for file in files:
copy_file(os.path.join(path, file.decode('utf-8')), os.path.join(dest, file.decode('utf-8')))
LOG.info("Copied %s", path)
示例2: get_sync
# 需要导入模块: import xbmcvfs [as 别名]
# 或者: from xbmcvfs import mkdirs [as 别名]
def get_sync():
path = xbmc.translatePath("special://profile/addon_data/plugin.video.emby/").decode('utf-8')
if not xbmcvfs.exists(path):
xbmcvfs.mkdirs(path)
try:
with open(os.path.join(path, 'sync.json')) as infile:
sync = json.load(infile)
except Exception:
sync = {}
sync['Libraries'] = sync.get('Libraries', [])
sync['RestorePoint'] = sync.get('RestorePoint', {})
sync['Whitelist'] = list(set(sync.get('Whitelist', [])))
sync['SortedViews'] = sync.get('SortedViews', [])
return sync
示例3: get_credentials
# 需要导入模块: import xbmcvfs [as 别名]
# 或者: from xbmcvfs import mkdirs [as 别名]
def get_credentials():
path = xbmc.translatePath("special://profile/addon_data/plugin.video.emby/").decode('utf-8')
if not xbmcvfs.exists(path):
xbmcvfs.mkdirs(path)
try:
with open(os.path.join(path, 'data.json')) as infile:
credentials = json.load(infile)
except Exception:
try:
with open(os.path.join(path, 'data.txt')) as infile:
credentials = json.load(infile)
save_credentials(credentials)
xbmcvfs.delete(os.path.join(path, 'data.txt'))
except Exception:
credentials = {}
credentials['Servers'] = credentials.get('Servers', [])
return credentials
示例4: add_item_to_library
# 需要导入模块: import xbmcvfs [as 别名]
# 或者: from xbmcvfs import mkdirs [as 别名]
def add_item_to_library(self, item_path, item_url):
error = False
new = False
if item_path:
item_path = xbmc.translatePath(item_path)
dir = os.path.dirname(item_path)
if not xbmcvfs.exists(dir):
try:
xbmcvfs.mkdirs(dir)
except Exception, e:
error = True
util.error('Failed to create directory 1: ' + dir)
if not xbmcvfs.exists(item_path):
try:
file_desc = xbmcvfs.File(item_path, 'w')
file_desc.write(item_url)
file_desc.close()
new = True
except Exception, e:
util.error('Failed to create .strm file: ' +
item_path + " | " + str(e))
error = True
示例5: createFilename
# 需要导入模块: import xbmcvfs [as 别名]
# 或者: from xbmcvfs import mkdirs [as 别名]
def createFilename(title, artist, album, url):
if ADDON.getSetting('keep_downloads')=='false':
return os.path.join(TEMP, createMD5(url))
title = clean(title)
artist = clean(artist)
album = clean(album)
customdir = ADDON.getSetting('custom_directory')
folder = ADDON.getSetting('music_dir')
if customdir=='false':
folder = TEMP
if ADDON.getSetting('folder_structure')=="0":
filename = os.path.join(folder, artist, album)
else:
filename = os.path.join(folder, artist + ' - ' + album)
try:
xbmcvfs.mkdirs(filename)
except Exception, e:
log('Error creating folder %s - %s' % (filename, str(e)))
示例6: download
# 需要导入模块: import xbmcvfs [as 别名]
# 或者: from xbmcvfs import mkdirs [as 别名]
def download(link):
subtitle_list = []
if xbmcvfs.exists(__temp__):
shutil.rmtree(__temp__)
xbmcvfs.mkdirs(__temp__)
file = os.path.join(__temp__, "addic7ed.srt")
f = get_url(link)
local_file_handle = open(file, "wb")
local_file_handle.write(f)
local_file_handle.close()
subtitle_list.append(file)
if len(subtitle_list) == 0:
if search_string:
xbmc.executebuiltin((u'Notification(%s,%s)' % (__scriptname__ , __language__(32002))).encode('utf-8'))
else:
xbmc.executebuiltin((u'Notification(%s,%s)' % (__scriptname__ , __language__(32003))).encode('utf-8'))
return subtitle_list
示例7: mkdir
# 需要导入模块: import xbmcvfs [as 别名]
# 或者: from xbmcvfs import mkdirs [as 别名]
def mkdir(path, recursive=False):
if exists(path):
if debug:
xbmc.log('******** VFS mkdir notice: %s exists' % path)
return False
if recursive:
try:
return xbmcvfs.mkdirs(path)
except Exception as e:
xbmc.log('******** VFS error: %s' % e)
return False
else:
try:
return xbmcvfs.mkdir(path)
except Exception as e:
xbmc.log('******** VFS error: %s' % e)
return False
示例8: make_dir
# 需要导入模块: import xbmcvfs [as 别名]
# 或者: from xbmcvfs import mkdirs [as 别名]
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
# -----------------------------------------------------------------------------------------------------------------
示例9: mkdirs
# 需要导入模块: import xbmcvfs [as 别名]
# 或者: from xbmcvfs import mkdirs [as 别名]
def mkdirs(path):
"""Create directory including parents (using xbmcvfs)"""
from xbmcvfs import mkdirs as vfsmkdirs
log(2, "Recursively create directory '{path}'.", path=path)
return vfsmkdirs(from_unicode(path))
示例10: verify_kodi_defaults
# 需要导入模块: import xbmcvfs [as 别名]
# 或者: from xbmcvfs import mkdirs [as 别名]
def verify_kodi_defaults():
''' Make sure we have the kodi default folder in place.
'''
node_path = xbmc.translatePath("special://profile/library/video").decode('utf-8')
if not xbmcvfs.exists(node_path):
try:
shutil.copytree(
src=xbmc.translatePath("special://xbmc/system/library/video").decode('utf-8'),
dst=xbmc.translatePath("special://profile/library/video").decode('utf-8'))
except Exception as error:
xbmcvfs.mkdir(node_path)
for index, node in enumerate(['movies', 'tvshows', 'musicvideos']):
file = os.path.join(node_path, node, "index.xml")
if xbmcvfs.exists(file):
try:
xml = etree.parse(file).getroot()
except Exception as error:
LOG.error(error)
continue
xml.set('order', str(17 + index))
indent(xml)
write_xml(etree.tostring(xml, 'UTF-8'), file)
playlist_path = xbmc.translatePath("special://profile/playlists/video").decode('utf-8')
if not xbmcvfs.exists(playlist_path):
xbmcvfs.mkdirs(playlist_path)
示例11: save_sync
# 需要导入模块: import xbmcvfs [as 别名]
# 或者: from xbmcvfs import mkdirs [as 别名]
def save_sync(sync):
path = xbmc.translatePath("special://profile/addon_data/plugin.video.emby/").decode('utf-8')
if not xbmcvfs.exists(path):
xbmcvfs.mkdirs(path)
sync['Date'] = datetime.datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%SZ')
with open(os.path.join(path, 'sync.json'), 'w') as outfile:
json.dump(sync, outfile, sort_keys=True, indent=4, ensure_ascii=False)
示例12: CreateDirectory
# 需要导入模块: import xbmcvfs [as 别名]
# 或者: from xbmcvfs import mkdirs [as 别名]
def CreateDirectory(self, dir_path):
os.path.join(dir_path, '') # ensure the path terminates in a '/'
if not xbmcvfs.exists(dir_path):
xbmcvfs.mkdirs(dir_path)
示例13: getLogo
# 需要导入模块: import xbmcvfs [as 别名]
# 或者: from xbmcvfs import mkdirs [as 别名]
def getLogo(title,ask=False,force=True):
infile = xbmc.translatePath("special://profile/addon_data/script.tvguide.fullscreen/logos/temp.png")
outfile = xbmc.translatePath("special://profile/addon_data/script.tvguide.fullscreen/logos/%s.png" % title)
if not force and xbmcvfs.exists(outfile):
return outfile
xbmcvfs.mkdirs("special://profile/addon_data/script.tvguide.fullscreen/logos")
db_url = "http://www.thelogodb.com/api/json/v1/4423/tvchannel.php?s=%s" % re.sub(' ','+',title)
try: json = requests.get(db_url).json()
except: return None
if json and "channels" in json:
channels = json["channels"]
if channels:
if ask:
names = ["%s [%s]" % (c["strChannel"],c["strCountry"]) for c in channels]
d = xbmcgui.Dialog()
selected = d.select("Logo Source: %s" % title,names)
else:
selected = 0
if selected > -1:
logo = channels[selected]["strLogoWide"]
if not logo:
return None
logo = re.sub('^https','http',logo)
data = requests.get(logo).content
f = xbmcvfs.File("special://profile/addon_data/script.tvguide.fullscreen/logos/temp.png","wb")
f.write(data)
f.close()
from PIL import Image, ImageOps
image = Image.open(infile)
border = 0
image = autocrop_image(image, border)
image.save(outfile)
logo = outfile
return logo
示例14: onInitialized
# 需要导入模块: import xbmcvfs [as 别名]
# 或者: from xbmcvfs import mkdirs [as 别名]
def onInitialized(success):
if success:
channelList = database.getChannelList(onlyVisible=False)
xbmcvfs.mkdirs("special://profile/addon_data/script.tvguide.fullscreen/channel_logos/")
for channel in channelList:
from_file = channel.logo
regex = '[%s]' % re.escape('[]/\:')
xbmc.log(regex)
ext = from_file.rsplit('.',1)[-1]
to_file = "special://profile/addon_data/script.tvguide.fullscreen/channel_logos/%s.%s" % (re.sub(regex,' ',channel.title),ext)
xbmcvfs.copy(from_file,to_file)
database.close(onAutoplaysCleared)
else:
database.close()
示例15: resetCache
# 需要导入模块: import xbmcvfs [as 别名]
# 或者: from xbmcvfs import mkdirs [as 别名]
def resetCache():
log('in RESETCACHE')
if not xbmcvfs.exists(TEMP):
try: xbmcvfs.mkdirs(TEMP)
except: pass
return
dirs, files = xbmcvfs.listdir(TEMP)
for file in files:
filename = os.path.join(TEMP, file)
deleteFile(filename)