Parsing returns the parsed list
Signed-off-by: Louis Vallat <louis@louis-vallat.xyz>
This commit is contained in:
parent
4c30f55f29
commit
bcac5c325f
@ -52,6 +52,7 @@ public class MovieQuoteBot {
|
||||
args[0] :
|
||||
System.getenv(DISCORD_TOKEN_ENVIRONMENT);
|
||||
|
||||
// TODO: FIX CRASH ON LOGIN IF OS IS IN MAINTENANCE OR BROKEN
|
||||
OpenSubtitles.login(
|
||||
System.getenv(OS_USERNAME_ENVIRONMENT) == null ?
|
||||
args[1] :
|
||||
|
@ -10,17 +10,16 @@ public class SubtitleParser {
|
||||
private final List<String> subtitleText = new ArrayList<>();
|
||||
|
||||
// TODO: FIND A WAY TO DO THIS THAT HAS A BETTER COMPLEXITY
|
||||
public void parseSRT(String s) {
|
||||
public List<String> parseSRT(String s) {
|
||||
s = s.replace("\r\n", "\n");
|
||||
String[] blocks = s.split("\n\n");
|
||||
for (String block : blocks) {
|
||||
List<String> splittedBlock = Arrays.stream(block.split("\n")).collect(Collectors.toList());
|
||||
subtitleText.add(splittedBlock.subList(2, splittedBlock.size()).stream().collect(Collectors.joining("\n")));
|
||||
}
|
||||
|
||||
for(String st : subtitleText) {
|
||||
System.out.println("TEXT:\n" + st + "\n\n");
|
||||
List<String> splitBlock = Arrays.stream(block.split("\n")).collect(Collectors.toList());
|
||||
subtitleText.add(String.join("\n", splitBlock.subList(2, splitBlock.size())));
|
||||
}
|
||||
subtitleText.remove(0);
|
||||
subtitleText.remove(subtitleText.size() - 1);
|
||||
return subtitleText;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user