|
| 1 | +package dev.lavalink.youtube.clients; |
| 2 | + |
| 3 | +import com.sedmelluq.discord.lavaplayer.tools.FriendlyException; |
| 4 | +import com.sedmelluq.discord.lavaplayer.tools.FriendlyException.Severity; |
| 5 | +import com.sedmelluq.discord.lavaplayer.tools.io.HttpInterface; |
| 6 | +import com.sedmelluq.discord.lavaplayer.track.AudioItem; |
| 7 | +import dev.lavalink.youtube.CannotBeLoaded; |
| 8 | +import dev.lavalink.youtube.YoutubeAudioSourceManager; |
| 9 | +import dev.lavalink.youtube.clients.skeleton.StreamingNonMusicClient; |
| 10 | +import org.jetbrains.annotations.NotNull; |
| 11 | +import org.jetbrains.annotations.Nullable; |
| 12 | + |
| 13 | +import java.io.IOException; |
| 14 | + |
| 15 | +public class TvDowngraded extends StreamingNonMusicClient { |
| 16 | + public static ClientConfig BASE_CONFIG = new ClientConfig() |
| 17 | + .withClientName("TVHTML5") |
| 18 | + .withUserAgent("Mozilla/5.0 (ChromiumStylePlatform) Cobalt/Version") |
| 19 | + .withClientField("clientVersion", "5.20260114"); |
| 20 | + |
| 21 | + protected ClientOptions options; |
| 22 | + |
| 23 | + public TvDowngraded() { |
| 24 | + this(ClientOptions.DEFAULT); |
| 25 | + } |
| 26 | + |
| 27 | + public TvDowngraded(@NotNull ClientOptions options) { |
| 28 | + this.options = options; |
| 29 | + } |
| 30 | + |
| 31 | + @Override |
| 32 | + @NotNull |
| 33 | + protected ClientConfig getBaseClientConfig(@NotNull HttpInterface httpInterface) { |
| 34 | + return BASE_CONFIG.copy(); |
| 35 | + } |
| 36 | + |
| 37 | + @Override |
| 38 | + @NotNull |
| 39 | + public String getPlayerParams() { |
| 40 | + return WEB_PLAYER_PARAMS; |
| 41 | + } |
| 42 | + |
| 43 | + @Override |
| 44 | + @NotNull |
| 45 | + public ClientOptions getOptions() { |
| 46 | + return this.options; |
| 47 | + } |
| 48 | + |
| 49 | + @Override |
| 50 | + public boolean canHandleRequest(@NotNull String identifier) { |
| 51 | + return false; |
| 52 | + } |
| 53 | + |
| 54 | + @Override |
| 55 | + public boolean supportsOAuth() { |
| 56 | + return true; |
| 57 | + } |
| 58 | + |
| 59 | + @Override |
| 60 | + @NotNull |
| 61 | + public String getIdentifier() { |
| 62 | + return BASE_CONFIG.getName(); |
| 63 | + } |
| 64 | + |
| 65 | + @Override |
| 66 | + public AudioItem loadPlaylist(@NotNull YoutubeAudioSourceManager source, |
| 67 | + @NotNull HttpInterface httpInterface, |
| 68 | + @NotNull String playlistId, |
| 69 | + @Nullable String selectedVideoId) { |
| 70 | + throw new FriendlyException("This client cannot load playlists", Severity.COMMON, |
| 71 | + new RuntimeException("TVHTML5 cannot be used to load playlists")); |
| 72 | + } |
| 73 | + |
| 74 | + @Override |
| 75 | + public AudioItem loadVideo(@NotNull YoutubeAudioSourceManager source, @NotNull HttpInterface httpInterface, @NotNull String videoId) throws CannotBeLoaded, IOException { |
| 76 | + throw new FriendlyException("This client cannot load videos", Severity.COMMON, |
| 77 | + new RuntimeException("TVHTML5 cannot be used to load videos")); |
| 78 | + } |
| 79 | + |
| 80 | + @Override |
| 81 | + public AudioItem loadMix(@NotNull YoutubeAudioSourceManager source, @NotNull HttpInterface httpInterface, @NotNull String mixId, @Nullable String selectedVideoId) { |
| 82 | + throw new FriendlyException("This client cannot load mixes", Severity.COMMON, |
| 83 | + new RuntimeException("TVHTML5 cannot be used to load mixes")); |
| 84 | + } |
| 85 | + |
| 86 | + @Override |
| 87 | + public AudioItem loadSearch(@NotNull YoutubeAudioSourceManager source, @NotNull HttpInterface httpInterface, @NotNull String searchQuery) { |
| 88 | + throw new FriendlyException("This client cannot search", Severity.COMMON, |
| 89 | + new RuntimeException("TVHTML5 cannot be used to search")); |
| 90 | + } |
| 91 | +} |
0 commit comments