def edit_Opener_BackVideo(tree): nodes_Alias = xmlUtils.find_nodes(tree, ".//CaptionArray/CaptionResource/Alias") nodes_TemplateStyle = xmlUtils.find_nodes(tree, ".//CaptionArray/CaptionResource/TemplateStyle") nodes_BackVideo = xmlUtils.find_nodes(tree, ".//CaptionArray/CaptionResource/BackVideo") for node_tuple in zip(nodes_Alias, nodes_TemplateStyle, nodes_BackVideo): alias = node_tuple[0].text if "Opener" in alias: # print alias node_tuple[1].text = "3" node_tuple[2].text = "$CaptionPath$" + alias + ".mp4"
def get_guid2(xmlPath): # 1. 读取xml文件 tree = xmlUtils.read_xml(xmlPath) # A. 找到节点 nodes = xmlUtils.find_nodes(tree, ".//GUID") if len(nodes) > 0: return nodes[0].text
def edit_Texture(tree, resName): nodes_Texture_Enable = xmlUtils.find_nodes(tree, ".//CaptionArray/CaptionResource/NLETitleArray/NLETitleItem/TextParam/Texture/Enable") nodes_Texture_TextureImagePath = xmlUtils.find_nodes(tree, ".//CaptionArray/CaptionResource/NLETitleArray/NLETitleItem/TextParam/Texture/TextureImagePath") nodes_Texture_TextureTempImagePath = xmlUtils.find_nodes(tree, ".//CaptionArray/CaptionResource/NLETitleArray/NLETitleItem/TextParam/Texture/TextureTempImagePath") for node_tuple in zip(nodes_Texture_Enable, nodes_Texture_TextureImagePath, nodes_Texture_TextureTempImagePath): # print node_tuple if node_tuple[0].text == "1": textureImagePath = node_tuple[1].text pngName = textureImagePath.split("\\")[-1] # print pngName PNG_NAME.append(pngName) new_textureImagePath = "$CaptionPath$" + resName + "/" + pngName node_tuple[1].text = new_textureImagePath node_tuple[2].text = ""
def edit_temp(tree, resName, type): if type.lower() == "transitions": # 修改MergeVideoFileName节点 mergeVideoFileName_nodes = xmlUtils.find_nodes(tree, ".//TransInfo/MergeVideoFileName") for node in mergeVideoFileName_nodes: node.text = resName + "/" + node.text.split("/")[-1] # 修改ResourceTag节点 resourceTag_nodes = xmlUtils.find_nodes(tree, ".//TransInfo/ResourceTag") xmlUtils.change_node_text(resourceTag_nodes, resName) # 修改ThumbFileName节点 thumbFileName_nodes = xmlUtils.find_nodes(tree, ".//TransInfo/ThumbFileName") for node in thumbFileName_nodes: node.text = resName + "/" + node.text.split("/")[-1] if type.lower() == "effect": # 修改MergeVideoFileName节点 mergeVideoFileName_nodes = xmlUtils.find_nodes(tree, ".//EffectInfo/MergeVideoFileName") for node in mergeVideoFileName_nodes: node.text = resName + "/" + node.text.split("/")[-1] # 修改ResourceTag节点 resourceTag_nodes = xmlUtils.find_nodes(tree, ".//EffectInfo/ResourceTag") xmlUtils.change_node_text(resourceTag_nodes, resName) if type.lower() == "contents": # 修改File节点text file_nodes = xmlUtils.find_nodes(tree, ".//File") for node in file_nodes: node.text = resName + "\\" + node.text.split("\\")[-1] # 修改File节点的Tag属性的值 xmlUtils.change_node_properties(file_nodes, {"Tag": resName})
def edit_VideoParam(tree, resName): nodes_VideoParam = xmlUtils.find_nodes(tree, ".//CaptionArray/CaptionResource/NLETitleArray/NLETitleItem/VideoParam") # print nodes_VideoParam if len(nodes_VideoParam) > 0: nodes_VideoPath = xmlUtils.find_nodes(tree, ".//CaptionArray/CaptionResource/NLETitleArray/NLETitleItem/VideoParam/VideoPath") nodes_VideoDataPath = xmlUtils.find_nodes(tree, ".//CaptionArray/CaptionResource/NLETitleArray/NLETitleItem/VideoParam/VideoDataPath") nodes_ImagePath = xmlUtils.find_nodes(tree, ".//CaptionArray/CaptionResource/NLETitleArray/NLETitleItem/VideoParam/ImagePath") for node_tuple in zip(nodes_VideoPath, nodes_VideoDataPath, nodes_ImagePath): videoPath = node_tuple[0].text # print videoPath videoDataPath = node_tuple[1].text imagePath = node_tuple[2].text new_videoPath = "$CaptionPath$" + resName + "/" + videoPath.split("/")[-1] new_videoDataPath = "$CaptionPath$" + resName + "/" + videoDataPath.split("/")[-1] new_imagePath = "$CaptionPath$" + resName + "/" + imagePath.split("/")[-1] node_tuple[0].text = new_videoPath node_tuple[1].text = new_videoDataPath node_tuple[2].text = new_imagePath
def get_guid(xmlPath): # 1. 读取xml文件 tree = xmlUtils.read_xml(xmlPath) # A. 找到节点 nodes = xmlUtils.find_nodes(tree, ".//Properties/Property") print nodes # B. 通过属性准确定位子节点 result_nodes = xmlUtils.get_node_by_keyvalue(nodes, {"key": "z.FilterID"}) if len(result_nodes) == 0: return print result_nodes GUID = result_nodes[0].get("value") if GUID is not None: return GUID else: print "GUID 不存在"
def edit_ResourceTag(tree, resName): nodes = xmlUtils.find_nodes(tree, ".//CaptionArray/CaptionResource/ResourceTag") xmlUtils.change_node_text(nodes, resName)
def edit_ResourceType(tree): nodes = xmlUtils.find_nodes(tree, ".//CaptionArray/CaptionResource/ResourceType") xmlUtils.change_node_text(nodes, "0")