diff --git a/common/src/main/java/dev/lavalink/youtube/OptionDisabledException.java b/common/src/main/java/dev/lavalink/youtube/OptionDisabledException.java new file mode 100644 index 0000000..9a30236 --- /dev/null +++ b/common/src/main/java/dev/lavalink/youtube/OptionDisabledException.java @@ -0,0 +1,7 @@ +package dev.lavalink.youtube; + +public class OptionDisabledException extends RuntimeException { + public OptionDisabledException(String message) { + super(message, null, true, false); + } +} diff --git a/common/src/main/java/dev/lavalink/youtube/clients/skeleton/MusicClient.java b/common/src/main/java/dev/lavalink/youtube/clients/skeleton/MusicClient.java index aa13061..d23599e 100644 --- a/common/src/main/java/dev/lavalink/youtube/clients/skeleton/MusicClient.java +++ b/common/src/main/java/dev/lavalink/youtube/clients/skeleton/MusicClient.java @@ -6,6 +6,7 @@ import com.sedmelluq.discord.lavaplayer.tools.io.HttpClientTools; import com.sedmelluq.discord.lavaplayer.tools.io.HttpInterface; import com.sedmelluq.discord.lavaplayer.track.*; +import dev.lavalink.youtube.OptionDisabledException; import dev.lavalink.youtube.YoutubeAudioSourceManager; import dev.lavalink.youtube.clients.ClientConfig; import dev.lavalink.youtube.track.format.TrackFormats; @@ -141,7 +142,7 @@ public AudioItem loadSearchMusic(@NotNull YoutubeAudioSourceManager source, @NotNull String searchQuery) { if (!getOptions().getSearching()) { // why would you even disable searching for this client lol - throw new RuntimeException("Searching is disabled for this client"); + throw new OptionDisabledException("Searching is disabled for this client"); } JsonBrowser json = getMusicSearchResult(httpInterface, searchQuery); diff --git a/common/src/main/java/dev/lavalink/youtube/clients/skeleton/NonMusicClient.java b/common/src/main/java/dev/lavalink/youtube/clients/skeleton/NonMusicClient.java index b301ab4..146a349 100644 --- a/common/src/main/java/dev/lavalink/youtube/clients/skeleton/NonMusicClient.java +++ b/common/src/main/java/dev/lavalink/youtube/clients/skeleton/NonMusicClient.java @@ -6,13 +6,13 @@ import com.sedmelluq.discord.lavaplayer.tools.io.HttpInterface; import com.sedmelluq.discord.lavaplayer.track.*; import dev.lavalink.youtube.CannotBeLoaded; +import dev.lavalink.youtube.OptionDisabledException; import dev.lavalink.youtube.YoutubeAudioSourceManager; import dev.lavalink.youtube.cipher.SignatureCipher; import dev.lavalink.youtube.cipher.SignatureCipherManager; import dev.lavalink.youtube.cipher.SignatureCipherManager.CachedPlayerScript; import dev.lavalink.youtube.clients.ClientConfig; import dev.lavalink.youtube.track.TemporalInfo; -import org.apache.http.HttpEntity; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.StringEntity; @@ -335,7 +335,7 @@ public AudioItem loadVideo(@NotNull YoutubeAudioSourceManager source, @NotNull HttpInterface httpInterface, @NotNull String videoId) throws CannotBeLoaded, IOException { if (!getOptions().getVideoLoading()) { - throw new RuntimeException("Video loading is disabled for this client"); + throw new OptionDisabledException("Video loading is disabled for this client"); } JsonBrowser json = loadTrackInfoFromInnertube(source, httpInterface, videoId, null); @@ -359,7 +359,7 @@ public AudioItem loadSearch(@NotNull YoutubeAudioSourceManager source, @NotNull HttpInterface httpInterface, @NotNull String searchQuery) { if (!getOptions().getSearching()) { - throw new RuntimeException("Searching is disabled for this client"); + throw new OptionDisabledException("Searching is disabled for this client"); } JsonBrowser json = loadSearchResults(httpInterface, searchQuery); @@ -378,7 +378,7 @@ public AudioItem loadMix(@NotNull YoutubeAudioSourceManager source, @NotNull String mixId, @Nullable String selectedVideoId) { if (!getOptions().getPlaylistLoading()) { - throw new RuntimeException("Mix loading is disabled for this client"); + throw new OptionDisabledException("Mix loading is disabled for this client"); } JsonBrowser json = loadMixResult(httpInterface, mixId, selectedVideoId); @@ -407,7 +407,7 @@ public AudioItem loadPlaylist(@NotNull YoutubeAudioSourceManager source, @NotNull String playlistId, @Nullable String selectedVideoId) { if (!getOptions().getPlaylistLoading()) { - throw new RuntimeException("Playlist loading is disabled for this client"); + throw new OptionDisabledException("Playlist loading is disabled for this client"); } JsonBrowser json = loadPlaylistResult(httpInterface, playlistId); diff --git a/v2/src/main/java/dev/lavalink/youtube/clients/skeleton/ThumbnailNonMusicClient.java b/v2/src/main/java/dev/lavalink/youtube/clients/skeleton/ThumbnailNonMusicClient.java index 059aef5..d3fb99e 100644 --- a/v2/src/main/java/dev/lavalink/youtube/clients/skeleton/ThumbnailNonMusicClient.java +++ b/v2/src/main/java/dev/lavalink/youtube/clients/skeleton/ThumbnailNonMusicClient.java @@ -9,6 +9,7 @@ import com.sedmelluq.discord.lavaplayer.track.AudioTrack; import com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo; import dev.lavalink.youtube.CannotBeLoaded; +import dev.lavalink.youtube.OptionDisabledException; import dev.lavalink.youtube.YoutubeAudioSourceManager; import dev.lavalink.youtube.track.TemporalInfo; import org.jetbrains.annotations.NotNull; @@ -89,6 +90,10 @@ protected AudioTrack extractAudioTrack(@NotNull JsonBrowser json, public AudioItem loadVideo(@NotNull YoutubeAudioSourceManager source, @NotNull HttpInterface httpInterface, @NotNull String videoId) throws CannotBeLoaded, IOException { + if (!getOptions().getVideoLoading()) { + throw new OptionDisabledException("Video loading is disabled for this client"); + } + JsonBrowser json = loadTrackInfoFromInnertube(source, httpInterface, videoId, null); JsonBrowser playabilityStatus = json.get("playabilityStatus"); JsonBrowser videoDetails = json.get("videoDetails");