本文整理汇总了Python中settings.Settings.getCoverCacheLocation方法的典型用法代码示例。如果您正苦于以下问题:Python Settings.getCoverCacheLocation方法的具体用法?Python Settings.getCoverCacheLocation怎么用?Python Settings.getCoverCacheLocation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类settings.Settings
的用法示例。
在下文中一共展示了Settings.getCoverCacheLocation方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _getCachedCover
# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import getCoverCacheLocation [as 别名]
def _getCachedCover(self, fileName):
cachedCover = None
# check if the directory exists before searching
dirs, files = xbmcvfs.listdir(Settings.getCoverCacheLocation())
for aFile in files:
# Get the filename without extension
coverSrc, ext = os.path.splitext(aFile)
# Get the name that the cached cover will have been stored as
targetSrc, bookExt = os.path.splitext(fileName)
# Make sure both are utf-8 when comparing
try:
coverSrc = coverSrc.encode("utf-8")
except:
pass
try:
targetSrc = targetSrc.encode("utf-8")
except:
pass
if targetSrc == coverSrc:
cachedCover = os_path_join(Settings.getCoverCacheLocation(), aFile)
log("AudioBookHandler: Cached cover found: %s" % cachedCover)
return cachedCover
示例2: _getMainCoverLocation
# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import getCoverCacheLocation [as 别名]
def _getMainCoverLocation(self):
coverFileName, oldExt = os.path.splitext(self.fileName)
targetCoverName = "%s.jpg" % coverFileName
coverTargetName = os_path_join(Settings.getCoverCacheLocation(), targetCoverName)
log("AudioBookHandler: Cached cover target location is %s" % coverTargetName)
return coverTargetName
示例3: getCachedCover
# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import getCoverCacheLocation [as 别名]
def getCachedCover(fileName):
cachedCover = None
# check if the directory exists before searching
dirs, files = xbmcvfs.listdir(Settings.getCoverCacheLocation())
for aFile in files:
# Get the filename without extension
coverSrc, ext = os.path.splitext(aFile)
# Get the name that the cached cover will have been stored as
targetSrc, bookExt = os.path.splitext(fileName)
if targetSrc == coverSrc:
cachedCover = os_path_join(Settings.getCoverCacheLocation(), aFile)
log("EBookBase: Cached cover found: %s" % cachedCover)
# There is a special case for PDF files that we have a default image
if (cachedCover is None) and fileName.endswith('.pdf'):
cachedCover = os.path.join(MEDIA_DIR, 'pdf_icon.png')
return cachedCover
示例4: extractCoverImage
# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import getCoverCacheLocation [as 别名]
def extractCoverImage(self):
log("MobiEBook: Extracting cover for %s" % self.filePath)
# Get the location that the book is to be extracted to
extractDir = os_path_join(Settings.getTempLocation(), 'mobi_extracted')
# Check if the mobi extract directory already exists
if dir_exists(extractDir):
try:
shutil.rmtree(extractDir, True)
except:
log("MobiEBook: Failed to delete directory %s" % extractDir)
# Extract the contents of the book so we can get the cover image
try:
kindleunpack.unpackBook(self.filePath, extractDir, None, '2', True)
except:
log("MobiEBook: Failed to extract cover for %s with error: %s" % (self.filePath, traceback.format_exc()), xbmc.LOGERROR)
coverTargetName = None
if dir_exists(extractDir):
coverImages = self._findCoverImage(extractDir)
if len(coverImages) > 0:
coverImageSrc = coverImages[0]
log("MobiEBook: Found cover file %s" % coverImageSrc)
coverFileName, oldExt = os.path.splitext(self.fileName)
cacheCoverName = "%s.jpg" % coverFileName
coverTargetName = os_path_join(Settings.getCoverCacheLocation(), cacheCoverName)
# Now move the file to the covers cache directory
copy = xbmcvfs.copy(coverImageSrc, coverTargetName)
if copy:
log("MobiEBook: copy successful for %s" % coverTargetName)
else:
log("MobiEBook: copy failed from %s to %s" % (coverImageSrc, coverTargetName))
else:
log("MobiEBook: No cover image found for %s" % self.filePath)
# Now tidy up the extracted data
try:
shutil.rmtree(extractDir, True)
except:
log("MobiEBook: Failed to tidy up directory %s" % extractDir)
else:
log("MobiEBook: Failed to extract Mobi file %s" % self.filePath)
return coverTargetName
示例5: __init__
# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import getCoverCacheLocation [as 别名]
def __init__(self, base_url, addon_handle):
self.base_url = base_url
self.addon_handle = addon_handle
self.tmpdestination = Settings.getTempLocation()
self.coverCache = Settings.getCoverCacheLocation()
示例6: log
# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import getCoverCacheLocation [as 别名]
sys.path.append(__lib__)
# Import the common settings
from settings import Settings
from settings import log
from settings import dir_exists
from settings import os_path_join
#########################
# Main
#########################
if __name__ == '__main__':
log("AudioBookCoverCleanup: Cover cache cleanup called (version %s)" % __version__)
coverCache = Settings.getCoverCacheLocation()
if dir_exists(coverCache):
try:
log("AudioBookCoverCleanup: Checking cache files %s" % coverCache)
# Remove the jpg and png files in the directory first
dirs, files = xbmcvfs.listdir(coverCache)
for aFile in files:
log("AudioBookCoverCleanup: Removing file %s" % aFile)
if aFile.endswith('.jpg') or aFile.endswith('.jpeg') or aFile.endswith('.png'):
coverFile = os_path_join(coverCache, aFile)
xbmcvfs.delete(coverFile)
# Now remove the actual directory
xbmcvfs.rmdir(coverCache)