本文整理匯總了Python中xbmcvfs.mkdir方法的典型用法代碼示例。如果您正苦於以下問題:Python xbmcvfs.mkdir方法的具體用法?Python xbmcvfs.mkdir怎麽用?Python xbmcvfs.mkdir使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類xbmcvfs
的用法示例。
在下文中一共展示了xbmcvfs.mkdir方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: unzip
# 需要導入模塊: import xbmcvfs [as 別名]
# 或者: from xbmcvfs import mkdir [as 別名]
def unzip(path, dest, folder=None):
''' Unzip file. zipfile module seems to fail on android with badziperror.
'''
path = urllib.quote_plus(path)
root = "zip://" + path + '/'
if folder:
xbmcvfs.mkdir(os.path.join(dest, folder))
dest = os.path.join(dest, folder)
root = get_zip_directory(root, folder)
dirs, files = xbmcvfs.listdir(root)
if dirs:
unzip_recursive(root, dirs, dest)
for file in files:
unzip_file(os.path.join(root, file.decode('utf-8')), os.path.join(dest, file.decode('utf-8')))
LOG.warn("Unzipped %s", path)
示例2: download_external_subs
# 需要導入模塊: import xbmcvfs [as 別名]
# 或者: from xbmcvfs import mkdir [as 別名]
def download_external_subs(cls, src, filename):
''' Download external subtitles to temp folder
to be able to have proper names to streams.
'''
temp = xbmc.translatePath("special://profile/addon_data/plugin.video.emby/temp/").decode('utf-8')
if not xbmcvfs.exists(temp):
xbmcvfs.mkdir(temp)
path = os.path.join(temp, filename)
try:
response = requests.get(src, stream=True, verify=False)
response.raise_for_status()
except Exception as e:
raise
else:
response.encoding = 'utf-8'
with open(path, 'wb') as f:
f.write(response.content)
del response
return path
示例3: my_streams_menu
# 需要導入模塊: import xbmcvfs [as 別名]
# 或者: from xbmcvfs import mkdir [as 別名]
def my_streams_menu():
if not os.path.exists(mystrm_folder): xbmcvfs.mkdir(mystrm_folder)
files = os.listdir(mystrm_folder)
if files:
for fic in files:
content = readfile(os.path.join(mystrm_folder,fic)).split('|')
if content:
if 'acestream://' in content[1] or '.acelive' in content[1] or '.torrent' in content[1]:
addDir(content[0],content[1],1,content[2],1,False)
elif 'sop://' in content[1]:
addDir(content[0],content[1],2,content[2],1,False)
else:
pass
xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_UNSORTED)
xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_LABEL)
addDir('[B][COLOR maroon]'+translate(30009)+'[/COLOR][/B]',MainURL,11,os.path.join(addonpath,art,'plus-menu.png'),1,False)
示例4: batch_add_tvshows_to_library
# 需要導入模塊: import xbmcvfs [as 別名]
# 或者: from xbmcvfs import mkdir [as 別名]
def batch_add_tvshows_to_library(library_folder, show):
id = show['id']
showname = text.to_utf8(show['seriesname'])
show_folder = os.path.join(library_folder, str(id) + '/')
if not xbmcvfs.exists(show_folder):
try:
xbmcvfs.mkdir(show_folder)
except:
pass
nfo_filepath = os.path.join(show_folder, 'tvshow.nfo')
if not xbmcvfs.exists(nfo_filepath):
nfo_file = xbmcvfs.File(nfo_filepath, 'w')
content = 'https://thetvdb.com/?tab=series&id=%s' % str(id)
nfo_file.write(content)
nfo_file.close()
clean_needed = True
return clean_needed
示例5: mkdir
# 需要導入模塊: import xbmcvfs [as 別名]
# 或者: from xbmcvfs import mkdir [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
示例6: make_dir
# 需要導入模塊: import xbmcvfs [as 別名]
# 或者: from xbmcvfs import mkdir [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
# -----------------------------------------------------------------------------------------------------------------
示例7: mkdir
# 需要導入模塊: import xbmcvfs [as 別名]
# 或者: from xbmcvfs import mkdir [as 別名]
def mkdir(path):
"""Create a directory (using xbmcvfs)"""
from xbmcvfs import mkdir as vfsmkdir
log(2, "Create directory '{path}'.", path=path)
return vfsmkdir(from_unicode(path))
示例8: unzip_recursive
# 需要導入模塊: import xbmcvfs [as 別名]
# 或者: from xbmcvfs import mkdir [as 別名]
def unzip_recursive(path, dirs, dest):
for directory in dirs:
dirs_dir = os.path.join(path, directory.decode('utf-8'))
dest_dir = os.path.join(dest, directory.decode('utf-8'))
xbmcvfs.mkdir(dest_dir)
dirs2, files = xbmcvfs.listdir(dirs_dir)
if dirs2:
unzip_recursive(dirs_dir, dirs2, dest_dir)
for file in files:
unzip_file(os.path.join(dirs_dir, file.decode('utf-8')), os.path.join(dest_dir, file.decode('utf-8')))
示例9: copy_recursive
# 需要導入模塊: import xbmcvfs [as 別名]
# 或者: from xbmcvfs import mkdir [as 別名]
def copy_recursive(path, dirs, dest):
for directory in dirs:
dirs_dir = os.path.join(path, directory.decode('utf-8'))
dest_dir = os.path.join(dest, directory.decode('utf-8'))
xbmcvfs.mkdir(dest_dir)
dirs2, files = xbmcvfs.listdir(dirs_dir)
if dirs2:
copy_recursive(dirs_dir, dirs2, dest_dir)
for file in files:
copy_file(os.path.join(dirs_dir, file.decode('utf-8')), os.path.join(dest_dir, file.decode('utf-8')))
示例10: verify_kodi_defaults
# 需要導入模塊: import xbmcvfs [as 別名]
# 或者: from xbmcvfs import mkdir [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: get_device_id
# 需要導入模塊: import xbmcvfs [as 別名]
# 或者: from xbmcvfs import mkdir [as 別名]
def get_device_id(reset=False):
''' Return the device_id if already loaded.
It will load from emby_guid file. If it's a fresh
setup, it will generate a new GUID to uniquely
identify the setup for all users.
window prop: emby_deviceId
'''
client_id = window('emby_deviceId')
if client_id:
return client_id
directory = xbmc.translatePath('special://profile/addon_data/plugin.video.emby/').decode('utf-8')
if not xbmcvfs.exists(directory):
xbmcvfs.mkdir(directory)
emby_guid = os.path.join(directory, "emby_guid")
file_guid = xbmcvfs.File(emby_guid)
client_id = file_guid.read()
if not client_id or reset:
LOG.info("Generating a new GUID.")
client_id = str("%012X" % create_id())
file_guid = xbmcvfs.File(emby_guid, 'w')
file_guid.write(client_id)
file_guid.close()
LOG.info("DeviceId loaded: %s", client_id)
window('emby_deviceId', value=client_id)
return client_id
示例12: timeout
# 需要導入模塊: import xbmcvfs [as 別名]
# 或者: from xbmcvfs import mkdir [as 別名]
def timeout(function, *args, **table):
try:
response = None
f = repr(function)
f = re.sub('.+\smethod\s|.+function\s|\sat\s.+|\sof\s.+', '', f)
a = hashlib.md5()
for i in args: a.update(str(i))
a = str(a.hexdigest())
except:
pass
try:
table = table['table']
except:
table = 'rel_list'
try:
xbmcvfs.mkdir(dataPath)
dbcon = database.connect(os.path.join(dataPath, 'cache.db'))
dbcur = dbcon.cursor()
dbcur.execute("SELECT * FROM %s WHERE func = '%s' AND args = '%s'" % (table, f, a))
match = dbcur.fetchone()
return int(match[3])
except:
return
示例13: traverse
# 需要導入模塊: import xbmcvfs [as 別名]
# 或者: from xbmcvfs import mkdir [as 別名]
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)
示例14: my_streams_menu
# 需要導入模塊: import xbmcvfs [as 別名]
# 或者: from xbmcvfs import mkdir [as 別名]
def my_streams_menu():
if not os.path.exists(mystrm_folder): xbmcvfs.mkdir(mystrm_folder)
files = os.listdir(mystrm_folder)
if files:
for fic in files:
content = readfile(os.path.join(mystrm_folder,fic)).split('|')
if content:
if 'acestream://' in content[1] or '.acelive' in content[1] or '.torrent' in content[1]:
addDir(content[0],content[1],1,content[2],1,False)
elif 'sop://' in content[1]:
addDir(content[0],content[1],2,content[2],1,False)
else:
pass
addDir('[B][COLOR maroon]'+translate(30009)+'[/COLOR][/B]',MainURL,11,os.path.join(addonpath,art,'plus-menu.png'),1,False)
示例15: __init__
# 需要導入模塊: import xbmcvfs [as 別名]
# 或者: from xbmcvfs import mkdir [as 別名]
def __init__(self):
# Initialize the subreddits db file if doesn't exist
if not os.path.exists(_subreddits_file):
xbmcvfs.mkdir(_dataPath)
self.conn = self.initialize_db()
else:
self.conn = database.connect(_subreddits_file)