Python for copying script into format for objection.lol save files.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from enum import Enum, auto | |
frame = '''{{ | |
"id": -1, | |
"iid": {iid}, | |
"text": "{text}", | |
"poseId": {poseId}, | |
"pairPoseId": null, | |
"bubbleType": 0, | |
"username": "{name}", | |
"mergeNext": false, | |
"doNotTalk": false, | |
"goNext": false, | |
"poseAnimation": true, | |
"flipped": null, | |
"frameActions": [ | |
{{ | |
"actionId": 1, | |
"actionParam": "0" | |
}} | |
], | |
"frameFades": [], | |
"characterId": null, | |
"popupId": null, | |
"pairId": null, | |
"transition": null, | |
"filter": null | |
}}''' | |
class State(Enum): | |
TITLE = auto(), | |
TEXT = auto() | |
## Example transcript.txt: | |
# | |
# Mark Bankston | |
# One of the things you talked about yesterday is you complied with discovery, right? | |
# You said that on the witness stand. | |
# | |
# Alex Jones | |
# That's one of the things I talked about. | |
# | |
# Mark Bankston | |
# One of the things that you were ordered to do in this lawsuit, you were ordered to turn over any text messages mentioning Sandy Hook. | |
# Right? | |
with open('transcript.txt', 'r') as fd: | |
iid = 1 | |
state = State.TITLE | |
frames = [] | |
pose_map = { | |
'Alex Jones': 211, | |
'Mark Bankston': 4, | |
'Judge': 186, | |
} | |
name = None | |
text = [] | |
for line in fd.readlines(): | |
line = line.strip() | |
if len(line) == 0: | |
state = State.TITLE | |
frames.append(frame.format(iid=iid, text='\\n'.join(text), name=name, poseId=pose_map[name])) | |
iid += 1 | |
text = [] | |
elif state == State.TITLE: | |
name = line | |
state = State.TEXT | |
else: | |
text.append(line.replace('"', "'")) | |
with open('out.txt', 'w') as fd: | |
fd.write(',\n'.join(frames)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment