def backup_skinshortcuts_properties(propertiesfile, dest_path):
'''parse skinshortcuts properties file and translate images'''
# look for any backgrounds and translate them
propfile = xbmcvfs.File(propertiesfile)
data = propfile.read()
propfile.close()
allprops = eval(data) if data else []
for count, prop in enumerate(allprops):
if prop[2] == "background":
background = prop[3] if prop[3] else ""
defaultid = prop[1]
if background.endswith(".jpg") or background.endswith(".png") or background.endswith(".gif"):
background = get_clean_image(background)
extension = background.split(".")[-1]
newthumb = os.path.join(dest_path, "%s-background-%s.%s" %
(xbmc.getSkinDir(), normalize_string(defaultid), extension))
newthumb_vfs = "special://profile/addon_data/script.skinshortcuts/%s-background-%s.%s" % (
xbmc.getSkinDir(), normalize_string(defaultid), extension)
if xbmcvfs.exists(background):
copy_file(background, newthumb)
allprops[count] = [prop[0], prop[1], prop[2], newthumb_vfs]
# write updated properties file
propfile = xbmcvfs.File(propertiesfile, "w")
propfile.write(repr(allprops))
propfile.close()
backuprestore.py 文件源码
python
阅读 18
收藏 0
点赞 0
评论 0
评论列表
文章目录