From 7e0a62bbfaca7f4d93f4993077920b292e92e335 Mon Sep 17 00:00:00 2001 From: Louis Vallat Date: Mon, 16 Nov 2020 14:23:24 +0100 Subject: [PATCH] [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 --- src/main/java/xyz/vallat/louis/commands/Quote.java | 2 +- .../xyz/vallat/louis/subtitles/parser/SubtitleParser.java | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/xyz/vallat/louis/commands/Quote.java b/src/main/java/xyz/vallat/louis/commands/Quote.java index 9c3630f..f0c81e2 100644 --- a/src/main/java/xyz/vallat/louis/commands/Quote.java +++ b/src/main/java/xyz/vallat/louis/commands/Quote.java @@ -56,7 +56,7 @@ public class Quote extends Command { .replaceAll("|", "**") .replaceAll("|", "__"), Whitelist.none())); - embed.setFooter(quote.getMovie().toString(), null); + embed.setFooter(quote.getMovie().toString(), quote.getMovie().getPoster()); embed.setColor(Color.MEDIUM_SEA_GREEN); } } diff --git a/src/main/java/xyz/vallat/louis/subtitles/parser/SubtitleParser.java b/src/main/java/xyz/vallat/louis/subtitles/parser/SubtitleParser.java index 6398760..9550394 100644 --- a/src/main/java/xyz/vallat/louis/subtitles/parser/SubtitleParser.java +++ b/src/main/java/xyz/vallat/louis/subtitles/parser/SubtitleParser.java @@ -20,8 +20,10 @@ public class SubtitleParser { subtitleBlocks.add(new SubtitleBlock(splitBlock.get(0), splitBlock.get(1), String.join("\n", splitBlock.subList(2, splitBlock.size())))); } - subtitleBlocks.remove(0); - subtitleBlocks.remove(Math.min(0, subtitleBlocks.size() - 1)); + if (!subtitleBlocks.isEmpty()) { + subtitleBlocks.remove(0); + subtitleBlocks.remove(Math.max(0, subtitleBlocks.size() - 1)); + } return subtitleBlocks; }