change: reformat code

This commit is contained in:
ZtereoHYPE 2022-02-03 23:12:17 +01:00
parent 9471fc67e0
commit 880fd0bd9b
21 changed files with 199 additions and 198 deletions

View file

@ -46,21 +46,19 @@ public class ZtereoMUSIC {
return ZtereoMUSIC.INSTANCE;
}
@SneakyThrows({ FileNotFoundException.class, LoginException.class,
InterruptedException.class, IOException.class })
@SneakyThrows({ FileNotFoundException.class, LoginException.class, InterruptedException.class, IOException.class })
public static void main(String[] args) {
ZtereoMUSIC ztereoMUSIC = ZtereoMUSIC.getInstance();
EnumSet<GatewayIntent> intents = EnumSet.of(
GatewayIntent.GUILD_MESSAGES,
EnumSet<GatewayIntent> intents = EnumSet.of(GatewayIntent.GUILD_MESSAGES,
GatewayIntent.GUILD_VOICE_STATES,
GatewayIntent.GUILD_EMOJIS
);
GatewayIntent.GUILD_EMOJIS);
ztereoMUSIC.setConfig(Config.loadFrom("./config.json5"));
ztereoMUSIC.setJda(JDABuilder.createDefault(ztereoMUSIC.getConfig().getPropreties().get("token"), intents)
.enableCache(CacheFlag.VOICE_STATE)
.build().awaitReady());
.build()
.awaitReady());
ztereoMUSIC.setupAudio();
ztereoMUSIC.setCommands();

View file

@ -14,19 +14,16 @@ public class AudioPlayerSendHandler implements AudioSendHandler {
this.audioPlayer = audioPlayer;
}
@Override
public boolean canProvide() {
@Override public boolean canProvide() {
lastFrame = audioPlayer.provide();
return lastFrame != null;
}
@Override
public ByteBuffer provide20MsAudio() {
@Override public ByteBuffer provide20MsAudio() {
return ByteBuffer.wrap(lastFrame.getData());
}
@Override
public boolean isOpus() {
@Override public boolean isOpus() {
return true;
}
}

View file

@ -16,26 +16,23 @@ public class CustomAudioLoadResultHandler implements AudioLoadResultHandler {
trackManager.setInfoChannel(messageChannel);
}
@Override
public void trackLoaded(AudioTrack track) {
@Override public void trackLoaded(AudioTrack track) {
this.trackManager.queue(track);
}
@Override
public void playlistLoaded(AudioPlaylist playlist) {
@Override public void playlistLoaded(AudioPlaylist playlist) {
for (AudioTrack track : playlist.getTracks()) {
this.trackManager.queue(track);
}
}
@Override
public void noMatches() {
@Override public void noMatches() {
this.messageChannel.sendMessage("I found no matches for that song!").queue();
}
@Override
public void loadFailed(FriendlyException throwable) {
this.messageChannel.sendMessage("Failed loading that audio. Try with a different source (eg. YouTube URL)").queue();
@Override public void loadFailed(FriendlyException throwable) {
this.messageChannel.sendMessage("Failed loading that audio. Try with a different source (eg. YouTube URL)")
.queue();
}
}

View file

@ -82,21 +82,15 @@ public class TrackManager extends AudioEventAdapter {
infoChannel.sendMessage("Playing next track: " + nextTrack.getInfo().title).queue();
}
@Override
public void onPlayerPause(AudioPlayer player) {}
@Override public void onPlayerPause(AudioPlayer player) {}
@Override
public void onPlayerResume(AudioPlayer player) {}
@Override public void onPlayerResume(AudioPlayer player) {}
@Override
public void onTrackStart(AudioPlayer player, AudioTrack track) {}
@Override public void onTrackStart(AudioPlayer player, AudioTrack track) {}
@Override
public void onTrackEnd(AudioPlayer player, AudioTrack track, AudioTrackEndReason endReason) {
@Override public void onTrackEnd(AudioPlayer player, AudioTrack track, AudioTrackEndReason endReason) {
switch (endReason) {
case FINISHED -> {
playNext();
}
case FINISHED -> playNext();
//todo: warning: this will create an infinite loop if a specific video has issues...
case LOAD_FAILED -> {
infoChannel.sendMessage("Loading failed, retrying...").queue();
@ -111,7 +105,9 @@ public class TrackManager extends AudioEventAdapter {
return;
}
ZtereoMUSIC.getInstance().getPlayerManager().loadItem(identifier, new CustomAudioLoadResultHandler(this, infoChannel));
ZtereoMUSIC.getInstance()
.getPlayerManager()
.loadItem(identifier, new CustomAudioLoadResultHandler(this, infoChannel));
}
}
@ -122,14 +118,13 @@ public class TrackManager extends AudioEventAdapter {
// endReason == CLEANUP: Player hasn't been queried for a while, if you want you can put a clone of this back to your queue
}
@Override
public void onTrackException(AudioPlayer player, AudioTrack track, FriendlyException exception) {
infoChannel.sendMessage("Uh oh, a track did something strange. Ask the owner to check for errors in console. Skpping...").queue();
@Override public void onTrackException(AudioPlayer player, AudioTrack track, FriendlyException exception) {
infoChannel.sendMessage(
"Uh oh, a track did something strange. Ask the owner to check for errors in console. Skpping...").queue();
System.out.println(exception.getCause().getMessage());
}
@Override
public void onTrackStuck(AudioPlayer player, AudioTrack track, long thresholdMs) {
@Override public void onTrackStuck(AudioPlayer player, AudioTrack track, long thresholdMs) {
infoChannel.sendMessage("Unable to play track " + track.getInfo().title + ". Skipping...").queue();
trackQueue.remove(track);
playNext();

View file

@ -10,8 +10,7 @@ import javax.annotation.Nullable;
public class TrackManagers {
//note: maybe make infoChannel an optional? not sure how to make this better, ask rep
@Nullable
public static TrackManager getGuildTrackManager(Guild guild, @Nullable MessageChannel infoChannel) {
@Nullable public static TrackManager getGuildTrackManager(Guild guild, @Nullable MessageChannel infoChannel) {
long guildId = guild.getIdLong();
TrackManager trackManager = ZtereoMUSIC.getInstance().getGuildTrackManagerMap().get(guildId);
@ -27,7 +26,9 @@ public class TrackManagers {
return trackManager;
}
public static TrackManager getOrCreateGuildTrackManager(Guild guild, MessageChannel infoChannel, VoiceChannel requestedChannel) {
public static TrackManager getOrCreateGuildTrackManager(Guild guild,
MessageChannel infoChannel,
VoiceChannel requestedChannel) {
long guildId = guild.getIdLong();
TrackManager trackManager = ZtereoMUSIC.getInstance().getGuildTrackManagerMap().get(guildId);

View file

@ -5,5 +5,6 @@ import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
// TODO: add categories/groups and perms but in a smart way pls
public interface Command {
CommandMeta getMeta();
void execute(MessageReceivedEvent messageRecievedEvent, String[] args);
}

View file

@ -4,7 +4,8 @@ import codes.ztereohype.ztereomusic.command.permissions.VoiceChecks;
import lombok.Builder;
import lombok.Getter;
@Getter @Builder
@Getter
@Builder
public class CommandMeta {
private final String name;
private final String description;

View file

@ -16,7 +16,7 @@ public class Clear implements Command {
public Clear() {
this.meta = CommandMeta.builder()
.name("clear")
.aliases(new String[] {"deleteall"})
.aliases(new String[] { "deleteall" })
.description("Clears the queue and stops playing.")
.isNsfw(false)
.isHidden(false)
@ -27,8 +27,7 @@ public class Clear implements Command {
.build();
}
@Override
public void execute(MessageReceivedEvent messageEvent, String[] args) {
@Override public void execute(MessageReceivedEvent messageEvent, String[] args) {
Guild guild = messageEvent.getGuild();
MessageChannel messageChannel = messageEvent.getChannel();
TrackManager trackManager = TrackManagers.getGuildTrackManager(guild, messageChannel);

View file

@ -23,8 +23,7 @@ public class Disconnect implements Command {
.build();
}
@Override
public CommandMeta getMeta() {
@Override public CommandMeta getMeta() {
return this.meta;
}

View file

@ -26,13 +26,11 @@ public class Pause implements Command {
.build();
}
@Override
public CommandMeta getMeta() {
@Override public CommandMeta getMeta() {
return this.meta;
}
@Override
public void execute(MessageReceivedEvent messageEvent, String[] args) {
@Override public void execute(MessageReceivedEvent messageEvent, String[] args) {
Guild guild = messageEvent.getGuild();
MessageChannel messageChannel = messageEvent.getChannel();
TrackManager trackManager = TrackManagers.getGuildTrackManager(guild, messageChannel);

View file

@ -19,8 +19,7 @@ public class Ping implements Command {
.build();
}
@Override
public CommandMeta getMeta() {
@Override public CommandMeta getMeta() {
return this.meta;
}

View file

@ -9,8 +9,10 @@ import codes.ztereohype.ztereomusic.command.CommandMeta;
import codes.ztereohype.ztereomusic.command.permissions.VoiceChecks;
import codes.ztereohype.ztereomusic.networking.SpotifyApiHelper;
import codes.ztereohype.ztereomusic.networking.YoutubeSearch;
import com.sedmelluq.discord.lavaplayer.player.AudioPlayerManager;
import net.dv8tion.jda.api.entities.*;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.MessageChannel;
import net.dv8tion.jda.api.entities.VoiceChannel;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
import net.shadew.util.data.Pair;
@ -19,8 +21,10 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Play implements Command {
private static final Pattern URL_PATTERN = Pattern.compile("^(http|https)://([a-z]+\\.[a-z]+)+/\\S+$", Pattern.CASE_INSENSITIVE);
private static final Pattern SPOTIFY_URL_PATTERN = Pattern.compile("^(?:https://open\\.spotify\\.com/(track|playlist)/)(\\S+(?:\\?si=\\S+))$");
private static final Pattern URL_PATTERN = Pattern.compile("^(http|https)://([a-z]+\\.[a-z]+)+/\\S+$",
Pattern.CASE_INSENSITIVE);
private static final Pattern SPOTIFY_URL_PATTERN = Pattern.compile(
"^(?:https://open\\.spotify\\.com/(track|playlist)/)(\\S+(?:\\?si=\\S+))$");
private final CommandMeta meta;
@ -31,13 +35,11 @@ public class Play implements Command {
.aliases(new String[] { "p" })
.isNsfw(false)
.isHidden(false)
.checks(new VoiceChecks[] { VoiceChecks.USER_CONNECTED,
VoiceChecks.SAME_VC_IF_CONNECTED })
.checks(new VoiceChecks[] { VoiceChecks.USER_CONNECTED, VoiceChecks.SAME_VC_IF_CONNECTED })
.build();
}
@Override
public CommandMeta getMeta() {
@Override public CommandMeta getMeta() {
return this.meta;
}
@ -47,14 +49,14 @@ public class Play implements Command {
Guild guild = messageEvent.getGuild();
VoiceChannel voiceChannel = Objects.requireNonNull(author.getVoiceState()).getChannel();
MessageChannel messageChannel = messageEvent.getChannel();
AudioPlayerManager playerManager = ZtereoMUSIC.getInstance().getPlayerManager();
// if there are no args use as play/pause
if (args.length == 0) {
TrackManager trackManager = TrackManagers.getGuildTrackManager(guild, messageChannel);
if (trackManager == null || !trackManager.getPlayer().isPaused()) {
messageChannel.sendMessage("What should I play? Type the name of the song after the command or use a YouTube link!").queue();
messageChannel.sendMessage(
"What should I play? Type the name of the song after the command or use a YouTube link!").queue();
return;
}
@ -96,6 +98,8 @@ public class Play implements Command {
TrackManager trackManager = TrackManagers.getOrCreateGuildTrackManager(guild, messageChannel, voiceChannel);
playerManager.loadItem(identifier, new CustomAudioLoadResultHandler(trackManager, messageChannel));
ZtereoMUSIC.getInstance()
.getPlayerManager()
.loadItem(identifier, new CustomAudioLoadResultHandler(trackManager, messageChannel));
}
}

View file

@ -30,21 +30,21 @@ public class Queue implements Command {
.build();
}
@Override
public CommandMeta getMeta() {
@Override public CommandMeta getMeta() {
return this.meta;
}
public void execute(MessageReceivedEvent messageEvent, String[] args) {
Guild guild = messageEvent.getGuild();
VoiceChannel voiceChannel = Objects.requireNonNull(Objects.requireNonNull(messageEvent.getMember()).getVoiceState()).getChannel();
VoiceChannel voiceChannel = Objects.requireNonNull(Objects.requireNonNull(messageEvent.getMember())
.getVoiceState()).getChannel();
MessageChannel messageChannel = messageEvent.getChannel();
TrackManager trackManager = TrackManagers.getOrCreateGuildTrackManager(guild, messageChannel, voiceChannel);
StringBuilder messageBuilder = new StringBuilder();
List<AudioTrack> trackList = trackManager.trackQueue;
for (AudioTrack track: trackList) {
for (AudioTrack track : trackList) {
messageBuilder.append(trackList.indexOf(track) + 1).append(". ");
messageBuilder.append(track.getInfo().title);
messageBuilder.append(System.getProperty("line.separator"));

View file

@ -20,7 +20,7 @@ public class Remove implements Command {
public Remove() {
this.meta = CommandMeta.builder()
.name("remove")
.aliases(new String[] {"delete"})
.aliases(new String[] { "delete" })
.description("Remove the chosen item.")
.isNsfw(false)
.isHidden(false)
@ -31,14 +31,15 @@ public class Remove implements Command {
.build();
}
@Override
public void execute(MessageReceivedEvent messageEvent, String[] args) {
@Override public void execute(MessageReceivedEvent messageEvent, String[] args) {
Guild guild = messageEvent.getGuild();
MessageChannel messageChannel = messageEvent.getChannel();
// if there's the wrong amount of arguments send the usage
if (args.length != 1) {
messageChannel.sendMessage("Usage: `remove [index of song to remove]/first/last`. Use the `queue` command to find the index.").queue();
messageChannel.sendMessage(
"Usage: `remove [index of song to remove]/first/last`. Use the `queue` command to find the index.")
.queue();
return;
}
@ -63,7 +64,9 @@ public class Remove implements Command {
} else if (indexAliases.containsKey(index.toLowerCase(Locale.ROOT))) {
parsedIndex = indexAliases.get(index);
} else {
messageChannel.sendMessage("Usage: `remove [index of song to remove]/first/last`. Use the `queue` command to find the index.").queue();
messageChannel.sendMessage(
"Usage: `remove [index of song to remove]/first/last`. Use the `queue` command to find the index.")
.queue();
return;
}

View file

@ -27,8 +27,7 @@ public class Skip implements Command {
.build();
}
@Override
public CommandMeta getMeta() {
@Override public CommandMeta getMeta() {
return this.meta;
}

View file

@ -6,5 +6,6 @@ import net.dv8tion.jda.api.entities.VoiceChannel;
public interface Check {
boolean getResult(Member messageAuthor, VoiceChannel connectedChannel, TrackManager trackManager);
String getErrorCode();
}

View file

@ -15,20 +15,20 @@ public enum VoiceChecks {
return connectedChannel != null;
}
@Override
public String getErrorCode() {
@Override public String getErrorCode() {
return "I am not playing anything.";
}
}),
BOT_PLAYING(new Check() {
@Override
public boolean getResult(Member messageAuthor, VoiceChannel connectedChannel, @Nullable TrackManager trackManager) {
public boolean getResult(Member messageAuthor,
VoiceChannel connectedChannel,
@Nullable TrackManager trackManager) {
return trackManager != null && trackManager.getPlayer().getPlayingTrack() != null;
}
@Override
public String getErrorCode() {
@Override public String getErrorCode() {
return "I am not playing anything.";
}
}),
@ -40,8 +40,7 @@ public enum VoiceChecks {
return messageAuthor.getVoiceState().inVoiceChannel();
}
@Override
public String getErrorCode() {
@Override public String getErrorCode() {
return "You are not connected to a voice channel.";
}
}),
@ -54,8 +53,7 @@ public enum VoiceChecks {
return Objects.equals(messageAuthor.getVoiceState().getChannel(), connectedChannel);
}
@Override
public String getErrorCode() {
@Override public String getErrorCode() {
return "We are not in the same voice channel.";
}
}),
@ -67,8 +65,7 @@ public enum VoiceChecks {
return false;
}
@Override
public String getErrorCode() {
@Override public String getErrorCode() {
return "You don't have the *DJ role*.";
}
});

View file

@ -9,7 +9,10 @@ import net.dv8tion.jda.api.events.guild.voice.GuildVoiceLeaveEvent;
import net.dv8tion.jda.api.hooks.ListenerAdapter;
import javax.annotation.Nonnull;
import java.util.*;
import java.util.HashMap;
import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;
public class AloneDisconnectListener extends ListenerAdapter {
//sorry reperak, i tried using a list of pairs but iterating over it to find it in onGuildVoiceLeave is too much effort
@ -18,15 +21,13 @@ public class AloneDisconnectListener extends ListenerAdapter {
public AloneDisconnectListener() {
Timer timer = new Timer();
timer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
@Override public void run() {
checkIfAloneAfterThreshold();
}
}, 5000, 5000);
}
@Override
public void onGuildVoiceLeave(@Nonnull GuildVoiceLeaveEvent event) {
@Override public void onGuildVoiceLeave(@Nonnull GuildVoiceLeaveEvent event) {
Guild guild = event.getGuild();
Member leavingMember = event.getMember();
Member ztereoBotMember = event.getGuild().getMember(ZtereoMUSIC.getInstance().getJda().getSelfUser());
@ -47,8 +48,7 @@ public class AloneDisconnectListener extends ListenerAdapter {
}
}
@Override
public void onGuildVoiceJoin(@Nonnull GuildVoiceJoinEvent event) {
@Override public void onGuildVoiceJoin(@Nonnull GuildVoiceJoinEvent event) {
Guild guild = event.getGuild();
if (guild.getAudioManager().getConnectedChannel() == null) return; // if we're not connected ignore

View file

@ -4,7 +4,9 @@ import codes.ztereohype.ztereomusic.ZtereoMUSIC;
import codes.ztereohype.ztereomusic.audio.TrackManagers;
import codes.ztereohype.ztereomusic.command.Command;
import codes.ztereohype.ztereomusic.command.permissions.VoiceChecks;
import net.dv8tion.jda.api.entities.*;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.api.entities.MessageChannel;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
import net.dv8tion.jda.api.hooks.ListenerAdapter;
@ -18,8 +20,7 @@ public class CommandListener extends ListenerAdapter {
private static final Map<String, Command> COMMAND_MAP = ZtereoMUSIC.getInstance().getCommandMap();
private static final Map<String, String> COMMAND_ALIASES = ZtereoMUSIC.getInstance().getCommandAliases();
@Override
public void onMessageReceived(@Nonnull MessageReceivedEvent event) {
@Override public void onMessageReceived(@Nonnull MessageReceivedEvent event) {
Message message = event.getMessage();
MessageChannel messageChannel = event.getChannel();
String content = message.getContentRaw();
@ -47,7 +48,10 @@ public class CommandListener extends ListenerAdapter {
// check if the command is allowed and stop at first failure (order is important)
for (VoiceChecks checkEnum : command.getMeta().getChecks()) {
if (!checkEnum.getCheck().getResult(message.getMember(), guild.getAudioManager().getConnectedChannel(), TrackManagers.getGuildTrackManager(guild, messageChannel))) {
if (!checkEnum.getCheck()
.getResult(message.getMember(),
guild.getAudioManager().getConnectedChannel(),
TrackManagers.getGuildTrackManager(guild, messageChannel))) {
message.reply(checkEnum.getCheck().getErrorCode()).queue();
return;
}
@ -58,7 +62,10 @@ public class CommandListener extends ListenerAdapter {
command.execute(event, args);
} catch (Exception e) {
//todo: nicer embed with error pls
message.getChannel().sendMessage("uh oh something really bad happened and yeah so yeah everything is aborted and cancelled i give up this is too hard kthxbye").queue();
message.getChannel()
.sendMessage(
"uh oh something really bad happened and yeah so yeah everything is aborted and cancelled i give up this is too hard kthxbye")
.queue();
throw e;
}
}

View file

@ -20,9 +20,16 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class SpotifyApiHelper {
private static final String CLIENT_ID = ZtereoMUSIC.getInstance().getConfig().getPropreties().get("spotify_client_id");
private static final String CLIENT_SECRET = ZtereoMUSIC.getInstance().getConfig().getPropreties().get("spotify_client_secret");
private static final Pattern IDENTIFIER_PATTERN = Pattern.compile("(?:(?<=https://open\\.spotify\\.com/track/)|(?<=https://open\\.spotify\\.com/playlist/))(\\S+(?=\\?si=\\S))");
private static final String CLIENT_ID = ZtereoMUSIC.getInstance()
.getConfig()
.getPropreties()
.get("spotify_client_id");
private static final String CLIENT_SECRET = ZtereoMUSIC.getInstance()
.getConfig()
.getPropreties()
.get("spotify_client_secret");
private static final Pattern IDENTIFIER_PATTERN = Pattern.compile(
"(?:(?<=https://open\\.spotify\\.com/track/)|(?<=https://open\\.spotify\\.com/playlist/))(\\S+(?=\\?si=\\S))");
private static String spotifyToken;
@ -31,8 +38,7 @@ public class SpotifyApiHelper {
public static void startTokenTimer() {
Timer timer = new Timer();
timer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
@Override public void run() {
spotifyToken = null; //remove old outdated token
Optional<String> parsedToken = getToken();
@ -43,16 +49,17 @@ public class SpotifyApiHelper {
spotifyToken = parsedToken.get();
}
}, 0, 3599*1000);
}, 0, 3599 * 1000);
}
@SneakyThrows
private static Optional<String> getToken() {
@SneakyThrows private static Optional<String> getToken() {
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder(
URI.create("https://accounts.spotify.com/api/token?grant_type=client_credentials"))
HttpRequest request = HttpRequest.newBuilder(URI.create(
"https://accounts.spotify.com/api/token?grant_type=client_credentials"))
.POST(HttpRequest.BodyPublishers.ofString(""))
.header("Authorization", "Basic " + Base64.getEncoder().encodeToString((CLIENT_ID + ":" + CLIENT_SECRET).getBytes(StandardCharsets.UTF_8.toString())))
.header("Authorization",
"Basic " + Base64.getEncoder()
.encodeToString((CLIENT_ID + ":" + CLIENT_SECRET).getBytes(StandardCharsets.UTF_8.toString())))
.header("Content-Type", "application/x-www-form-urlencoded")
.build();
@ -86,30 +93,28 @@ public class SpotifyApiHelper {
return Pair.of(false, "Could not parse Spotify link. Try entering the song title directly.");
}
String query = "https://api.spotify.com/v1/tracks?ids="
+ spotifyIdentifier + "&market=ES"; //españaaaa
String query = "https://api.spotify.com/v1/tracks?ids=" + spotifyIdentifier + "&market=ES"; //españaaaa
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder(
URI.create(query))
HttpRequest request = HttpRequest.newBuilder(URI.create(query))
.GET()
.header("Authorization", "Bearer " + spotifyToken)
.header("Content-Type", "application/json")
.build();
JsonPath titlePath = JsonPath.parse("tracks[0].name");
// JsonPath authorPath = JsonPath.parse("tracks[0].artists[0].name");
// JsonPath authorPath = JsonPath.parse("tracks[0].artists[0].name");
try {
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
String title = JSON.parse(response.body()).query(titlePath).asString();
// String author = JSON.parse(response.body()).query(authorPath).asString();
// String author = JSON.parse(response.body()).query(authorPath).asString();
return Pair.of(true, title);
} catch (IOException | InterruptedException e) {
e.printStackTrace();
return Pair.of(false,"Something wrong happened with the spotify request.");
return Pair.of(false, "Something wrong happened with the spotify request.");
}
}
}

View file

@ -14,8 +14,8 @@ public class YoutubeSearch {
private static final Json JSON = Json.json();
public static Pair<Boolean, String> query(String title) {
String query = "https://www.googleapis.com/youtube/v3/search?part=snippet&q=%22"
+ title.replace(' ', '+') + "%22&type=video&key=" + API_KEY;
String query = "https://www.googleapis.com/youtube/v3/search?part=snippet&q=%22" + title.replace(' ',
'+') + "%22&type=video&key=" + API_KEY;
String jsonResponse;
try {