Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The code seems to be geared towards one specific use case, so I spent some time generalizing the code so it could be used across many Visual Novels.
In the example below, the code will only run if the character's name is a single character. But if the character is for example Twilight Sparkle, and I used "ts" to represent her, the code will fail.
I've also replaced usage of os.system with subprocess as os.system has been deprecated.
Also, I have replaced the below-hardcoded number with a variable dependent on the number of rows in the dialogue.tab
Lastly, I have replaced all line[0], line[1], line[2] references with a single variable to speed up processing as you have admitted, it will take a long time since the code makes one API call per row