From f1f6d4ed6303c2d4a2c23f447533d40d6fe72cf9 Mon Sep 17 00:00:00 2001 From: cyklon73 Date: Wed, 28 Aug 2024 10:35:46 +0200 Subject: [PATCH] Implements after a failed api key to try the next one --- .../slimeball/features/alerts/youtube/Youtube.java | 14 ++++++++------ .../alerts/youtube/YoutubeApiErrorEvent.java | 3 +++ .../features/alerts/youtube/YoutubeListener.java | 9 +++++---- .../features/alerts/youtube/YoutubeVideoEvent.java | 3 ++- 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/main/java/de/slimecloud/slimeball/features/alerts/youtube/Youtube.java b/src/main/java/de/slimecloud/slimeball/features/alerts/youtube/Youtube.java index 42e2c1ad..be64bc61 100644 --- a/src/main/java/de/slimecloud/slimeball/features/alerts/youtube/Youtube.java +++ b/src/main/java/de/slimecloud/slimeball/features/alerts/youtube/Youtube.java @@ -11,6 +11,7 @@ import de.slimecloud.slimeball.main.SlimeBot; import de.slimecloud.slimeball.util.MathUtil; import lombok.Cleanup; +import lombok.Getter; import lombok.extern.slf4j.Slf4j; import okhttp3.OkHttpClient; import okhttp3.Request; @@ -27,6 +28,7 @@ public class Youtube { private final OkHttpClient client = new OkHttpClient().newBuilder().build(); + @Getter private final String[] keys; private final SlimeBot bot; private final YoutubeConfig config; @@ -46,7 +48,7 @@ public void startListener() { channels.forEach((channel, delay) -> { bot.getExecutor().scheduleAtFixedRate(() -> { try { - check(channel); + check(channel, currentKey); } catch (Exception e) { logger.error("Failed to check for new video for channel " + channel, e); } @@ -54,15 +56,15 @@ public void startListener() { }); } - private void check(String youtubeChannelId) throws IOException { - Set