本文整理汇总了Python中xbmcvfs.listdir函数的典型用法代码示例。如果您正苦于以下问题:Python listdir函数的具体用法?Python listdir怎么用?Python listdir使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了listdir函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: getOfflineFileList
def getOfflineFileList(cachePath):
localFiles = []
#workaround for this issue: https://github.com/xbmc/xbmc/pull/8531
if xbmcvfs.exists(cachePath) or os.path.exists(cachePath):
dirs,files = xbmcvfs.listdir(cachePath)
for dir in dirs:
subdir,subfiles = xbmcvfs.listdir(str(cachePath) + '/' + str(dir))
for file in subfiles:
if bool(re.search('\.stream\.mp4', file)):
try:
nameFile = xbmcvfs.File(str(cachePath) + '/' + str(dir) + '/' + str(dir) + '.name')
filename = nameFile.read()
nameFile.close()
except:
filename = file
try:
nameFile = xbmcvfs.File(str(cachePath) + '/' + str(dir) + '/' + str(os.path.splitext(file)[0]) + '.resolution')
resolution = nameFile.read()
nameFile.close()
except:
resolution = file
offlineFile = offlinefile.offlinefile(filename, str(cachePath) + '/' + str(dir) +'.jpg', resolution.rstrip(), str(cachePath) + '/' + str(dir) + '/' + str(os.path.splitext(file)[0]) + '.mp4')
localFiles.append(offlineFile)
return localFiles
开发者ID:azumimuo,项目名称:family-xbmc-addon,代码行数:28,代码来源:kodi_common.py
示例2: parser_check
def parser_check():
dirs,files = xbmcvfs.listdir(base_dir)
if not dirs:
dirpackages,filespackages = xbmcvfs.listdir(parser_packages_folder)
if filespackages:
for fich in filespackages:
shutil.copyfile(os.path.join(parser_packages_folder,fich), os.path.join(parser_core_folder,fich))
xbmc.sleep(100)
import tarfile
if tarfile.is_tarfile(os.path.join(parser_core_folder,fich)):
download_tools().extract(os.path.join(parser_core_folder,fich),parser_core_folder)
download_tools().remove(os.path.join(parser_core_folder,fich))
else:
dirsuserdata,files = xbmcvfs.listdir(parser_folder)
for fich in files:
dictionary_module = eval(readfile(os.path.join(parser_folder,fich)))
if "url" in dictionary_module.keys():
add_new_parser(dictionary_module["url"])
else:
xbmcvfs.copy(os.path.join(parser_packages_folder,fich.replace('.txt','.tar.gz')),os.path.join(parser_core_folder,fich.replace('.txt','.tar.gz')))
import tarfile
if tarfile.is_tarfile(os.path.join(parser_core_folder,fich.replace('.txt','.tar.gz'))):
download_tools().extract(os.path.join(parser_core_folder,fich.replace('.txt','.tar.gz')),parser_core_folder)
download_tools().remove(os.path.join(parser_core_folder,fich.replace('.txt','.tar.gz')))
else: pass
return
开发者ID:Antimoni,项目名称:P2P-Streams-XBMC,代码行数:26,代码来源:parsers.py
示例3: delete_cache
def delete_cache(cls):
# Remove all existing textures first
path = xbmc.translatePath('special://thumbnails/').decode('utf-8')
if xbmcvfs.exists(path):
dirs, ignore_files = xbmcvfs.listdir(path)
for directory in dirs:
ignore_dirs, files = xbmcvfs.listdir(path + directory)
for file_ in files:
if os.path.supports_unicode_filenames:
filename = os.path.join(path + directory.decode('utf-8'),
file_.decode('utf-8'))
else:
filename = os.path.join(path.encode('utf-8') + directory, file_)
xbmcvfs.delete(filename)
log.debug("deleted: %s", filename)
# remove all existing data from texture DB
with DatabaseConn('texture') as cursor_texture:
cursor_texture.execute('SELECT tbl_name FROM sqlite_master WHERE type="table"')
rows = cursor_texture.fetchall()
for row in rows:
table_name = row[0]
if table_name != "version":
cursor_texture.execute("DELETE FROM " + table_name)
开发者ID:kravone,项目名称:plugin.video.emby,代码行数:26,代码来源:artwork.py
示例4: CleanExpired
def CleanExpired(self):
#delete files more than an hour old
self.Notification('Hulu Library','Removing Expired Content')
#delete old tv show files
dir = xbmc.makeLegalFilename(TV_SHOWS_PATH)
dirs, trash = xbmcvfs.listdir(dir)
for show in dirs:
show = xbmc.makeLegalFilename(os.path.join(dir, show))
trash, files = xbmcvfs.listdir(show)
for file in files:
path = xbmc.makeLegalFilename(os.path.join(show,file))
if (sys.platform == 'win32'): path = path.replace('smb:','')
if (time.mktime(time.strptime(time.ctime(os.path.getmtime(path)))) < (time.mktime(time.localtime()) - 3600)): xbmcvfs.delete(path)
#delete old movie files
dir = xbmc.makeLegalFilename(MOVIE_PATH)
trash, movies = xbmcvfs.listdir(dir)
for movie in movies:
path = xbmc.makeLegalFilename(os.path.join(dir, movie))
if (sys.platform == 'win32'): path = path.replace('smb:','')
if time.mktime(time.strptime(time.ctime(os.path.getmtime(path)))) < (time.mktime(time.localtime()) - 3600): xbmcvfs.delete(path)
xbmc.log(path)
self.Notification('Hulu Library','Expired Content Removed')
开发者ID:DuperMan,项目名称:plugin.video.hulu-beta,代码行数:25,代码来源:xbmclibrary.py
示例5: Download
def Download(url,lang):
try: rmtree(__temp__)
except: pass
try: os.makedirs(__temp__)
except: pass
subtitle_list = []
exts = [".srt", ".sub", ".smi", ".ssa", ".ass" ]
log( sys._getframe().f_code.co_name ,"Download page: %s" % (url))
try:
req = urllib2.Request(url)
req.add_header('User-Agent', UserAgent)
socket = urllib2.urlopen(req)
data = socket.read()
soup = BeautifulSoup(data, 'html.parser')
url = soup.find("li", class_="dlsub").a.get('href').encode('utf-8')
if url[:4] != 'http':
url = ZIMUKU_BASE + url
log( sys._getframe().f_code.co_name ,"Download links: %s" % (url))
req = urllib2.Request(url)
req.add_header('User-Agent', UserAgent)
socket = urllib2.urlopen(req)
data = socket.read()
socket.close()
soup = BeautifulSoup(data, 'html.parser')
links = soup.find("div", {"class":"clearfix"}).find_all('a')
except:
log( sys.exc_info()[2].tb_frame.f_code.co_name, "(%d) [%s]" % (
sys.exc_info()[2].tb_lineno,
sys.exc_info()[1]
))
return []
filename, data = DownloadLinks(links, url)
if len(data) < 1024:
return []
tempfile = os.path.join(__temp__, "subtitles%s" % os.path.splitext(filename)[1])
with open(tempfile, "wb") as subFile:
subFile.write(data)
subFile.close()
xbmc.sleep(500)
if data[:4] == 'Rar!' or data[:2] == 'PK':
xbmc.executebuiltin(('XBMC.Extract("%s","%s")' % (tempfile,__temp__,)).encode('utf-8'), True)
path = __temp__
dirs, files = xbmcvfs.listdir(path)
if len(dirs) > 0:
path = os.path.join(__temp__, dirs[0].decode('utf-8'))
dirs, files = xbmcvfs.listdir(path)
list = []
for subfile in files:
if (os.path.splitext( subfile )[1] in exts):
list.append(subfile.decode('utf-8'))
if len(list) == 1:
subtitle_list.append(os.path.join(path, list[0]))
else:
sel = xbmcgui.Dialog().select('请选择压缩包中的字幕', list)
if sel == -1:
sel = 0
subtitle_list.append(os.path.join(path, list[sel]))
return subtitle_list
开发者ID:taxigps,项目名称:xbmc-addons-chinese,代码行数:60,代码来源:service.py
示例6: listFilesInPath
def listFilesInPath(path, allFilesList=None):
#used for easy matching of studio logos
if not allFilesList:
allFilesList = {}
dirs, files = xbmcvfs.listdir(path)
for file in files:
file = file.decode("utf-8")
name = file.split(".png")[0].lower()
if not allFilesList.has_key(name):
allFilesList[name] = path + file
for dir in dirs:
dirs2, files2 = xbmcvfs.listdir(os.path.join(path,dir)+os.sep)
for file in files2:
file = file.decode("utf-8")
dir = dir.decode("utf-8")
name = dir + "/" + file.split(".png")[0].lower()
if not allFilesList.has_key(name):
if "/" in path:
sep = "/"
else:
sep = "\\"
allFilesList[name] = path + dir + sep + file
#return the list
return allFilesList
开发者ID:aioff,项目名称:script.skin.helper.service,代码行数:25,代码来源:Utils.py
示例7: merge_epg
def merge_epg():
# code from enen92. thank you
print '[Rytec EPG Downloader]: merge epg'
xml_path = get_xml_path()
temp = os.path.join(xml_path,'temp')
if not os.path.isdir(temp):
os.mkdir(temp)
out = os.path.join(xml_path,'merged_epg.xml')
if xbmcvfs.exists(out): os.remove(out)
print '[Rytec EPG Downloader]: start extracting files'
dirs, files = xbmcvfs.listdir(os.path.join(xml_path))
for f in files:
if f.endswith('.gz'):
inF = gzip.GzipFile(os.path.join(xml_path,f), 'rb')
s = inF.read()
inF.close()
outF = file(os.path.join(temp,f.replace('.gz','.xml')),'wb')
outF.write(s)
outF.close()
print '[Rytec EPG Downloader]: extracting files done'
print '[Rytec EPG Downloader]: start merging files'
dirs, xmltv_list = xbmcvfs.listdir(os.path.join(temp))
i=1
total = len(xmltv_list)
for xmltv in xmltv_list:
if xmltv.endswith('.xml'):
if i==1:
f = open(os.path.join(temp,xmltv), "r")
text = f.read()
f.close()
with open(out, "a") as myfile:
myfile.write(text.replace('</tv>',''))
elif i==total:
o = open(out,"a")
f = open(os.path.join(temp,xmltv),"r")
lines = f.readlines()
f.close()
li = 0
for line in lines:
if li == 0 or li == 1: pass
else: o.write(line)
li += 1
o.close()
else:
o = open(out,"a")
f = open(os.path.join(temp,xmltv),"r")
lines = f.readlines()
total_lines = len(lines)
f.close()
li = 0
for line in lines:
if li == 0 or li == 1: pass
elif li == (total_lines -1): pass
else: o.write(line)
li += 1
o.close()
os.remove(os.path.join(temp,xmltv))
i += 1
print '[Rytec EPG Downloader]: merging files done'
开发者ID:noba3,项目名称:KoTos,代码行数:59,代码来源:common.py
示例8: Download
def Download(url,lang):
try: shutil.rmtree(__temp__)
except: pass
try: os.makedirs(__temp__)
except: pass
subtitle_list = []
exts = [".srt", ".sub", ".txt", ".smi", ".ssa", ".ass" ]
try:
socket = urllib.request.urlopen( url )
data = socket.read()
soup = BeautifulSoup(data)
id = soup.find("button", class_="btn btn-danger btn-sm").get("sid").encode('utf-8')
url = "http://www.subhd.com/ajax/down_ajax"
values = {'sub_id':id}
data = urllib.parse.urlencode(values)
req = urllib.request.Request(url, data)
response = urllib.request.urlopen(req)
data = response.read()
match = re.compile('"url":"([^"]+)"').search(data)
url = SUBHD_BASE + match.group(1).replace(r'\/','/').decode("unicode-escape").encode('utf-8')
socket = urllib.request.urlopen( url )
data = socket.read()
socket.close()
except:
return []
if len(data) < 1024:
return []
if data[:4] == 'Rar!':
zip = os.path.join(__temp__,"subtitles.rar")
elif data[:2] == 'PK':
zip = os.path.join(__temp__,"subtitles.zip")
else:
zip = os.path.join(__temp__,"subtitles.srt")
with open(zip, "wb") as subFile:
subFile.write(data)
subFile.close()
xbmc.sleep(500)
if not zip.endswith('.srt'):
xbmc.executebuiltin(('XBMC.Extract("%s","%s")' % (zip,__temp__,)).encode('utf-8'), True)
path = __temp__
dirs, files = xbmcvfs.listdir(path)
if len(dirs) > 0:
path = os.path.join(__temp__, dirs[0].decode('utf-8'))
dirs, files = xbmcvfs.listdir(path)
list = []
for subfile in files:
if (os.path.splitext( subfile )[1] in exts):
list.append(subfile.decode('utf-8'))
if len(list) == 1:
subtitle_list.append(os.path.join(path, list[0]))
else:
sel = xbmcgui.Dialog().select('请选择压缩包中的字幕', list)
if sel == -1:
sel = 0
subtitle_list.append(os.path.join(path, list[sel]))
return subtitle_list
开发者ID:nomadyun,项目名称:StudyPython,代码行数:58,代码来源:service.py
示例9: delete_files
def delete_files(source, match, del_empty=False):
# delete files from source if match
dirs, files = xbmcvfs.listdir(source)
for f in files:
if match in f:
f = os.path.join(source, f)
xbmcvfs.delete(f)
# delete source directory if empty
if del_empty and len(xbmcvfs.listdir(source)) == 0:
xbmcvfs.rmdir(source)
开发者ID:jerimiah797,项目名称:script.audio.rhapsody,代码行数:10,代码来源:skincheck.py
示例10: __delete_files_alt
def __delete_files_alt(source, match, del_empty):
# delete files from source if match
dirs, files = xbmcvfs.listdir(source)
for f in files:
if match == os.path.splitext(f)[0]:
f = os.path.join(source, f)
xbmcvfs.delete(f)
# delete source directory if empty
if del_empty and len(xbmcvfs.listdir(source)) == 0:
xbmcvfs.rmdir(source)
开发者ID:bellreplace,项目名称:hautopc,代码行数:10,代码来源:utilfile.py
示例11: Download
def Download(id,lang):
try: rmtree(__temp__)
except: pass
try: os.makedirs(__temp__)
except: pass
subtitle_list = []
exts = [".srt", ".sub", ".smi", ".ssa", ".ass" ]
url = DOWNLOAD_API % (id)
try:
socket = urllib.urlopen( url )
data = socket.read()
socket.close()
soup = BeautifulSoup(data)
url = soup.find("a", class_="down_ink download_link").get('href').encode('utf-8')
socket = urllib.urlopen( url )
#filename = socket.headers['Content-Disposition'].split('filename=')[1]
#if filename[0] == '"' or filename[0] == "'":
# filename = filename[1:-1]
filename = os.path.basename(url)
data = socket.read()
socket.close()
except:
return []
if len(data) < 1024:
return []
tempfile = os.path.join(__temp__, "subtitles%s" % os.path.splitext(filename)[1])
with open(tempfile, "wb") as subFile:
subFile.write(data)
subFile.close()
xbmc.sleep(500)
if data[:4] == 'Rar!' or data[:2] == 'PK':
xbmc.executebuiltin(('XBMC.Extract("%s","%s")' % (tempfile,__temp__,)).encode('utf-8'), True)
path = __temp__
dirs, files = xbmcvfs.listdir(path)
if ('__MACOSX') in dirs:
dirs.remove('__MACOSX')
if len(dirs) > 0:
path = os.path.join(__temp__, dirs[0].decode('utf-8'))
dirs, files = xbmcvfs.listdir(path)
list = []
for subfile in files:
if (os.path.splitext( subfile )[1] in exts):
list.append(subfile.decode('utf-8'))
if len(list) == 1:
subtitle_list.append(os.path.join(path, list[0]))
elif len(list) > 1:
sel = xbmcgui.Dialog().select('请选择压缩包中的字幕', list)
if sel == -1:
sel = 0
subtitle_list.append(os.path.join(path, list[sel]))
return subtitle_list
开发者ID:brmnh,项目名称:xbmc-addons-chinese,代码行数:53,代码来源:service.py
示例12: clear_parser_trace
def clear_parser_trace():
dirs,files = xbmcvfs.listdir(parser_core_folder)
import shutil
for directory in dirs:
shutil.rmtree(os.path.join(parser_core_folder,directory))
dirs,files = xbmcvfs.listdir(parser_packages_folder)
for fich in files:
xbmcvfs.delete(os.path.join(parser_packages_folder,fich))
dirs,files = xbmcvfs.listdir(parser_folder)
for fich in files:
xbmcvfs.delete(os.path.join(parser_folder,fich))
xbmc.executebuiltin("Notification(%s,%s,%i,%s)" % (translate(40000),translate(70007),1,addonpath+"/icon.png"))
开发者ID:HIGHWAY99,项目名称:P2P-Streams-XBMC,代码行数:12,代码来源:parsers.py
示例13: __delete_files_alt
def __delete_files_alt(source, match, del_empty):
# delete files from source if match
dirs, files = xbmcvfs.listdir(source)
for f in files:
if os.path.splitext(f)[0].startswith(match):
f = os.path.join(source, f)
if not xbmcvfs.delete(f):
raise ValueError('xbmcvfs.delete', f)
# delete source directory if empty
if del_empty and len(xbmcvfs.listdir(source)) == 0:
if not xbmcvfs.rmdir(source):
raise ValueError('xbmcvfs.rmdir', source)
开发者ID:jvandenbroek,项目名称:script.service.afterwatch,代码行数:12,代码来源:utilfile.py
示例14: DownloadID
def DownloadID(id):
if xbmcvfs.exists(__temp__):
rmtree(__temp__)
xbmc.sleep(50)
xbmcvfs.mkdirs(__temp__)
subtitle_list = []
if id.startswith('999999'):
url = 'http://sub.makedie.me/download/%06d/%s' %(int(id[6:]), 'XBMC.SUBTITLE')
else:
url = 'http://shooter.cn/files/file3.php?hash=duei7chy7gj59fjew73hdwh213f&fileid=%s' % (id)
socket = urllib.urlopen( url )
data = socket.read()
url = 'http://file0.shooter.cn%s' % (CalcFileHash(data))
#log(sys._getframe().f_code.co_name ,"url is %s" % (url))
socket = urllib.urlopen( url )
data = socket.read()
socket.close()
header = data[:4]
if header == 'Rar!':
zipext = ".rar"
else: # header == 'PK':
zipext = ".zip"
zipname = 'SUBPACK%s' % (zipext)
zip = os.path.join( __temp__, zipname)
with open(zip, "wb") as subFile:
subFile.write(data)
subFile.close()
xbmc.sleep(500)
dirs, files = xbmcvfs.listdir(__temp__) # refresh xbmc folder cache
xbmc.executebuiltin(('XBMC.Extract("%s","%s")' % (zip,__temp__,)).encode('utf-8'), True)
path = __temp__
dirs, files = xbmcvfs.listdir(path)
list = CheckSubList(files)
if not list and len(dirs) > 0:
path = os.path.join(__temp__, dirs[0].decode('utf-8'))
dirs, files = xbmcvfs.listdir(path)
list = CheckSubList(files)
if list:
filename = list[0].decode('utf-8')
else:
filename = ''
if len(list) > 1:
dialog = xbmcgui.Dialog()
sel = dialog.select(__language__(32006), list)
if sel != -1:
filename = list[sel].decode('utf-8')
if filename:
filepath = os.path.join(path, filename)
ChangeFileEndcoding(filepath)
subtitle_list.append(filepath)
return subtitle_list
开发者ID:CyberBaby,项目名称:xbmc-addons-chinese,代码行数:53,代码来源:service.py
示例15: updatedb_from_exported
def updatedb_from_exported(self):
"""Adds movies and shows from exported media to the local db
Returns
-------
bool
Process finished
"""
tv_show_path = self.tvshow_path
db_filepath = self.db_filepath
if xbmcvfs.exists(self.nx_common.check_folder_path(self.movie_path)):
movies = xbmcvfs.listdir(self.movie_path)
for video in movies[0]:
folder = os.path.join(self.movie_path, video)
file = xbmcvfs.listdir(folder)
year = int(str(file[1]).split("(", 1)[1].split(")", 1)[0])
alt_title = unicode(video.decode('utf-8'))
title = unicode(video.decode('utf-8'))
movie_meta = '%s (%d)' % (title, year)
if self.movie_exists(title=title, year=year) is False:
self.db[self.movies_label][movie_meta] = {
'alt_title': alt_title}
self._update_local_db(filename=db_filepath, db=self.db)
if xbmcvfs.exists(self.nx_common.check_folder_path(tv_show_path)):
shows = xbmcvfs.listdir(tv_show_path)
for video in shows[0]:
show_dir = os.path.join(tv_show_path, video)
title = unicode(video.decode('utf-8'))
alt_title = unicode(video.decode('utf-8'))
show_meta = '%s' % (title)
if self.show_exists(title) is False:
self.db[self.series_label][show_meta] = {
'seasons': [],
'episodes': [],
'alt_title': alt_title}
episodes = xbmcvfs.listdir(show_dir)
for episode in episodes[1]:
file = str(episode).split(".")[0]
season = int(str(file).split("S")[1].split("E")[0])
episode = int(str(file).split("E")[1])
episode_meta = 'S%02dE%02d' % (season, episode)
episode_exists = self.episode_exists(
title=title,
season=season,
episode=episode)
if episode_exists is False:
self.db[self.series_label][title]['episodes'].append(episode_meta)
self._update_local_db(
filename=self.db_filepath,
db=self.db)
return True
开发者ID:dumpster-of-things,项目名称:plugin.video.netflix,代码行数:52,代码来源:Library.py
示例16: DownloadID
def DownloadID(url):
try: shutil.rmtree(__temp__)
except: pass
try: os.makedirs(__temp__)
except: pass
subtitle_list = []
url = urllib.unquote(url)
socket = urllib2.urlopen( url )
data = socket.read()
socket.close()
soup = BeautifulSoup(data)
href = soup.find(id="btn_download")['href']
url= ('http://sub.makedie.me%s' % href)
socket = urllib.urlopen( url )
data = socket.read()
socket.close()
zipname = urllib.unquote(os.path.basename(url))
zip = os.path.join( __temp__, zipname)
with open(zip, "wb") as subFile:
subFile.write(data)
subFile.close()
xbmc.sleep(500)
if data[:4] == 'Rar!' or data[:2] == 'PK':
xbmc.executebuiltin(('XBMC.Extract("%s","%s")' % (zip,__temp__,)).encode('utf-8'), True)
path = __temp__
dirs, files = xbmcvfs.listdir(path)
list = CheckSubList(files)
if not list and len(dirs) > 0:
path = os.path.join(__temp__, dirs[0].decode('utf-8'))
dirs, files = xbmcvfs.listdir(path)
list = CheckSubList(files)
if list:
filename = list[0].decode('utf-8')
else:
filename = ''
if len(list) > 1:
dialog = xbmcgui.Dialog()
sel = dialog.select(__language__(32006), list)
if sel != -1:
filename = list[sel].decode('utf-8')
if filename:
filepath = os.path.join(path, filename)
ChangeFileEndcoding(filepath)
subtitle_list.append(filepath)
return subtitle_list
开发者ID:sheldongriffin,项目名称:xbmc-addons-chinese,代码行数:52,代码来源:service.py
示例17: Download
def Download(url,lang):
try: shutil.rmtree(__temp__)
except: pass
try: os.makedirs(__temp__)
except: pass
subtitle_list = []
exts = [".srt", ".sub", ".txt", ".smi", ".ssa", ".ass" ]
try:
socket = urllib.urlopen( url )
data = socket.read()
soup = BeautifulSoup(data)
results = soup.find("a", class_="down_ink download_link").get("onclick").encode('utf-8')
id = results.split("'")
url = "http://www.subom.net/index.php?m=down&a=sub&id=%s&s_id=%s" % (id[1], id[3])
socket = urllib.urlopen( url )
data = socket.read()
socket.close()
except:
return []
if len(data) < 1024:
return []
if data[:4] == 'Rar!':
zip = os.path.join(__temp__,"subtitles.rar")
elif data[:2] == 'PK':
zip = os.path.join(__temp__,"subtitles.zip")
else:
zip = os.path.join(__temp__,"subtitles.srt")
with open(zip, "wb") as subFile:
subFile.write(data)
subFile.close()
xbmc.sleep(500)
if not zip.endswith('.srt'):
xbmc.executebuiltin(('XBMC.Extract("%s","%s")' % (zip,__temp__,)).encode('utf-8'), True)
path = __temp__
dirs, files = xbmcvfs.listdir(path)
if len(dirs) > 0:
path = os.path.join(__temp__, dirs[0].decode('utf-8'))
dirs, files = xbmcvfs.listdir(path)
list = []
for subfile in files:
if (os.path.splitext( subfile )[1] in exts):
list.append(subfile.decode('utf-8'))
if len(list) == 1:
subtitle_list.append(os.path.join(path, list[0]))
else:
sel = xbmcgui.Dialog().select('请选择压缩包中的字幕', list)
if sel == -1:
sel = 0
subtitle_list.append(os.path.join(path, list[sel]))
return subtitle_list
开发者ID:13917547121,项目名称:xbmc-addons-chinese,代码行数:52,代码来源:service.py
示例18: addon_parsers_menu
def addon_parsers_menu():
if settings.getSetting('parser_disclaimer') == "true":
opcao= xbmcgui.Dialog().yesno(translate(40000),translate(70004),translate(70005),translate(70006))
if opcao: settings.setSetting('parser_disclaimer',"false")
dirs,files = xbmcvfs.listdir(base_dir)
if not dirs:
dirsuserdata,files = xbmcvfs.listdir(parser_folder)
for fich in files:
dictionary_module = eval(readfile(os.path.join(parser_folder,fich)))
if "url" in dictionary_module.keys():
add_new_parser(dictionary_module["url"])
else:
xbmcvfs.copy(os.path.join(parser_packages_folder,fich.replace('.txt','.tar.gz')),os.path.join(parser_core_folder,fich.replace('.txt','.tar.gz')))
import tarfile
if tarfile.is_tarfile(os.path.join(parser_core_folder,fich.replace('.txt','.tar.gz'))):
download_tools().extract(os.path.join(parser_core_folder,fich.replace('.txt','.tar.gz')),parser_core_folder)
download_tools().remove(os.path.join(parser_core_folder,fich.replace('.txt','.tar.gz')))
dirs,files = xbmcvfs.listdir(base_dir)
parser_dict = {}
for module in dirs:
module_dir = os.path.join(base_dir,module)
module_cfg = os.path.join(module_dir,"module.cfg")
module_icon = os.path.join(module_dir,"icon.png")
module_fanart = os.path.join(module_dir,"fanart.jpg")
if xbmcvfs.exists(module_icon): thumbnail = module_icon
else: thumbnail = 'os.path.join(module_dir,"")'
if xbmcvfs.exists(module_fanart): fanart = module_fanart
else: fanart = ''
if xbmcvfs.exists(module_cfg):
cfg = readfile(module_cfg)
try:
cfg = eval(cfg)
module_name = cfg['name']
except: module_name = None
if module_name:
parser_dict[module_name] = [module,thumbnail,fanart]
total_parsers = len(parser_dict.keys())
if settings.getSetting('parser_sync') == "true":
try:t1 = datetime.datetime.strptime(settings.getSetting("parsers_last_sync"), "%Y-%m-%d %H:%M:%S.%f")
except:t1 = datetime.datetime.fromtimestamp(time.mktime(time.strptime(settings.getSetting("parsers_last_sync"), "%Y-%m-%d %H:%M:%S.%f")))
t2 = datetime.datetime.now()
hoursList = [10, 15, 20, 24]
interval = int(settings.getSetting("parser_sync_cron"))
update = abs(t2 - t1) > datetime.timedelta(hours=hoursList[interval])
if update:
sync_parser()
settings.setSetting('parsers_last_sync',value=datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f"))
for key in sorted(parser_dict.keys()):
addDir(key,MainURL,401,parser_dict[key][1],total_parsers,True,parser=parser_dict[key][0])
addDir(translate(400011),MainURL,402,addonpath + art + 'plus-menu.png',2,False)
开发者ID:Commanche2,项目名称:P2P-Streams-XBMC,代码行数:51,代码来源:parsers.py
示例19: walk_dir
def walk_dir(dir):
exts = [".srt", ".sub", ".smi", ".ssa", ".ass" ]
files_list = []
print ('dir: %s' % dir)
for subdir in xbmcvfs.listdir(dir)[0]:
print ('scanning: %s' % subdir)
files_list.extend(walk_dir(os.path.join(dir,subdir)))
for file in xbmcvfs.listdir(dir)[1]:
if (os.path.splitext(file)[1] in exts):
print ('appending %s' % file)
files_list.append(os.path.join(dir,file))
return files_list
开发者ID:kgkolev,项目名称:service.subtitles.subsunacs,代码行数:14,代码来源:service.py
示例20: addVideos
def addVideos():
entries = []
fileTypes = (
".mkv",
".avi",
".mp4",
".wmv",
".flv",
".mpg",
".mpeg",
".mov",
".ts",
".m2ts",
".m4v",
".m2v",
".rm",
".3gp",
".asf",
".asx",
".amv",
".divx",
".pls",
".strm",
".m3u",
".mp3",
".aac",
".flac",
".ogg",
".wma",
".wav",
)
if videoDir.startswith(("smb://", "nfs://", "upnp://", "ftp://")):
dirs, files = xbmcvfs.listdir(videoDir)
for file in files:
if file.lower().endswith(fileTypes):
entries.append(os.path.join(videoDir, file))
for dir in dirs:
dirs2, files = xbmcvfs.listdir(os.path.join(videoDir, dir))
for file in files:
if file.lower().endswith(fileTypes):
entries.append(os.path.join(videoDir, os.path.join(dir, file)))
else:
for root, dirs, files in os.walk(videoDir):
for filename in files:
if filename.lower().endswith(fileTypes):
entries.append(os.path.join(root, filename))
random.shuffle(entries)
for file in entries:
playlist.add(file)
开发者ID:Luisangonzalez,项目名称:repository.addonscriptorde,代码行数:49,代码来源:screensaver.py
注:本文中的xbmcvfs.listdir函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论