Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- dialog_script_path = input()
- dialog_script = open(dialog_script_path, encoding="utf8").readlines()
- translation_file = open("english.xml", encoding="utf8").readlines()
- w_file_name = dialog_script_path.split("\\")[-1].split(".")[0]
- f = open(str(w_file_name) + ".txt", "w")
- actors_id = {"e0d1ff71-04a8-4340-ae64-9684d846eb83": "PC", "c7c13742-bacd-460a-8f65-f864fe41f255": "Astarion",
- "ad9af97d-75da-406a-ae13-7071c563f604": "Gale", "98b9a4da-d3af-494e-890b-c8ec85d3146d": "Helia",
- "0de603c5-42e2-4811-9dad-f652de080eba": "Minsc", "3ed74f06-3c60-42dc-83f6-f034cb47c679": "ShadowHeart",
- "58a69333-40bf-8358-1d17-fff240d7fb12": "Laezel", "c774d764-4a17-48dc-b470-32ace9ce447d": "Wyll",
- "2c76687d-93a2-477b-8b18-8a14b549304c": "Karlach"}
- final_lines = []
- def get_actors():
- actors_dict = {}
- index = int
- for line in dialog_script:
- if '"index"' in line:
- index = line.split(":")[-1][2]
- if '"list"' in line:
- temp_actor_id = line.split(":")[-1].split('"')[1]
- if temp_actor_id in actors_id:
- actor_id = actors_id.get(temp_actor_id)
- else:
- actor_id = "NPC"
- actors_dict[index] = actor_id
- return actors_dict
- def get_synopsis():
- temp_line = str
- for line in dialog_script:
- if "synopsis" in line:
- temp_line = line.split(":")[-1][1:-3]
- return temp_line
- def get_lines():
- actors = get_actors()
- lines = []
- dialog_line = str
- for line in dialog_script:
- if "handle" in line:
- temp_line_id = line.split('"')[-2]
- for line in translation_file:
- if temp_line_id in line:
- dialog_line = re.findall(u'>(.+?)<', line)[0]
- if '"speaker"' in line:
- if line.split(":")[-1][1].isdigit():
- actor = actors[line.split(":")[-1][1]]
- lines.append(actor + ': ' + str(dialog_line))
- synopsis = get_synopsis()
- lines.append("\nSynopsis: " + synopsis)
- f.write("\n".join(lines))
- get_lines()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement