def get_customfolder_path(self, customfolder, foldername, sublevel=False):
'''search recursively (max 2 levels) for a specific folder'''
cachestr = "customfolder_path.%s.%s" % (customfolder, foldername)
folder_path = self.cache.get(cachestr)
if not folder_path:
if "\\" in customfolder:
delim = "\\"
else:
delim = "/"
dirs = xbmcvfs.listdir(customfolder)[0]
for strictness in [1, 0.95, 0.9, 0.85]:
for directory in dirs:
directory = directory.decode("utf-8")
curpath = os.path.join(customfolder, directory) + delim
match = SM(None, foldername.lower(), directory.lower()).ratio()
if match >= strictness:
folder_path = curpath
elif not sublevel:
# check if our requested path is in a sublevel of the current path
# restrict the number of sublevels to just one for now for performance reasons
folder_path = self.get_customfolder_path(curpath, foldername, True)
if folder_path:
break
if folder_path:
break
if not sublevel:
if not folder_path and self._mutils.addon.getSetting("music_art_download_custom") == "true":
# allow creation of folder if downloading is enabled
folder_path = os.path.join(customfolder, foldername) + delim
self.cache.set(cachestr, folder_path)
return folder_path
musicartwork.py 文件源码
python
阅读 17
收藏 0
点赞 0
评论 0
评论列表
文章目录