[FIX] Used min instead of max to delete last element of the parsed subtitles, so the bot wouldn't import the first opensubtitle ad, and the first line of the film, but would import the last of the film, which is the second ad

Signed-off-by: Louis Vallat <louis@louis-vallat.xyz>
This commit is contained in:
Louis Vallat 2020-11-16 14:23:24 +01:00
parent 5b5f42c123
commit 7e0a62bbfa
2 changed files with 5 additions and 3 deletions

View File

@ -56,7 +56,7 @@ public class Quote extends Command {
.replaceAll("<b>|</b>", "**") .replaceAll("<b>|</b>", "**")
.replaceAll("<u>|</u>", "__"), .replaceAll("<u>|</u>", "__"),
Whitelist.none())); Whitelist.none()));
embed.setFooter(quote.getMovie().toString(), null); embed.setFooter(quote.getMovie().toString(), quote.getMovie().getPoster());
embed.setColor(Color.MEDIUM_SEA_GREEN); embed.setColor(Color.MEDIUM_SEA_GREEN);
} }
} }

View File

@ -20,8 +20,10 @@ public class SubtitleParser {
subtitleBlocks.add(new SubtitleBlock(splitBlock.get(0), subtitleBlocks.add(new SubtitleBlock(splitBlock.get(0),
splitBlock.get(1), String.join("\n", splitBlock.subList(2, splitBlock.size())))); splitBlock.get(1), String.join("\n", splitBlock.subList(2, splitBlock.size()))));
} }
subtitleBlocks.remove(0); if (!subtitleBlocks.isEmpty()) {
subtitleBlocks.remove(Math.min(0, subtitleBlocks.size() - 1)); subtitleBlocks.remove(0);
subtitleBlocks.remove(Math.max(0, subtitleBlocks.size() - 1));
}
return subtitleBlocks; return subtitleBlocks;
} }