use of com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo in project MantaroBot by Mantaro.
the class AudioRequester method loadSingle.
private void loadSingle(AudioTrack audioTrack, boolean silent) {
AudioTrackInfo trackInfo = audioTrack.getInfo();
DBGuild dbGuild = MantaroData.db().getGuild(event.getGuild());
GuildData guildData = dbGuild.getData();
String title = trackInfo.title;
long length = trackInfo.length;
long queueLimit = !Optional.ofNullable(dbGuild.getData().getMusicQueueSizeLimit()).isPresent() ? MAX_QUEUE_LENGTH : dbGuild.getData().getMusicQueueSizeLimit();
int fqSize = guildData.getMaxFairQueue();
if (getMusicManager().getTrackScheduler().getQueue().size() > queueLimit && !MantaroData.db().getUser(event.getMember()).isPremium() && !dbGuild.isPremium()) {
if (!silent)
event.getChannel().sendMessage(String.format(":warning: Could not queue %s: Surpassed queue song limit!", title)).queue(message -> message.delete().queueAfter(30, TimeUnit.SECONDS));
if (musicManager.getTrackScheduler().isStopped())
event.getGuild().getAudioManager().closeAudioConnection();
return;
}
if (audioTrack.getInfo().length > MAX_SONG_LENGTH && !MantaroData.db().getUser(event.getMember()).isPremium() && !dbGuild.isPremium()) {
event.getChannel().sendMessage(String.format(":warning: Could not queue %s: Track is longer than 21 minutes! (%s)", title, AudioUtils.getLength(length))).queue();
if (musicManager.getTrackScheduler().isStopped())
//do you?
event.getGuild().getAudioManager().closeAudioConnection();
return;
}
//Comparing if the URLs are the same to be 100% sure they're just not spamming the same url over and over again.
if (musicManager.getTrackScheduler().getQueue().stream().filter(track -> track.getInfo().uri.equals(audioTrack.getInfo().uri)).count() > fqSize) {
event.getChannel().sendMessage(EmoteReference.ERROR + String.format("**Surpassed fair queue level of %d (Too many songs which are exactly equal)**", fqSize + 1)).queue();
return;
}
musicManager.getTrackScheduler().queue(new AudioTrackContext(event.getAuthor(), event.getChannel(), audioTrack.getSourceManager() instanceof YoutubeAudioSourceManager ? "https://www.youtube.com/watch?v=" + audioTrack.getIdentifier() : trackUrl, audioTrack));
if (!silent) {
event.getChannel().sendMessage(String.format("📣 Added to queue -> **%s** **!(%s)**", title, AudioUtils.getLength(length))).queue();
}
}
use of com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo in project c0debaseBot by Biospheere.
the class SkipCommand method execute.
@Override
public void execute(String[] args, Message msg) {
EmbedBuilder embedBuilder = getEmbed(msg.getGuild(), msg.getAuthor());
if (msg.getMember().getVoiceState().inVoiceChannel() && msg.getMember().getVoiceState().getChannel().getMembers().contains(msg.getGuild().getSelfMember())) {
CodebaseBot.getInstance().getMusicManager().skip(msg.getGuild());
if (CodebaseBot.getInstance().getMusicManager().getPlayingTrack(msg.getGuild()) != null) {
AudioTrackInfo trackInfo = CodebaseBot.getInstance().getMusicManager().getPlayingTrack(msg.getGuild()).getInfo();
String length;
if (TimeUnit.MILLISECONDS.toHours(trackInfo.length) >= 24) {
length = String.format("%dd %02d:%02d:%02d", TimeUnit.MILLISECONDS.toDays(trackInfo.length), TimeUnit.MILLISECONDS.toHours(trackInfo.length) % 24, TimeUnit.MILLISECONDS.toMinutes(trackInfo.length) % 60, TimeUnit.MILLISECONDS.toSeconds(trackInfo.length) % 60);
} else {
length = String.format("%02d:%02d:%02d", TimeUnit.MILLISECONDS.toHours(trackInfo.length) % 24, TimeUnit.MILLISECONDS.toMinutes(trackInfo.length) % 60, TimeUnit.MILLISECONDS.toSeconds(trackInfo.length) % 60);
}
embedBuilder.addField(trackInfo.title, "`" + trackInfo.author + " - " + (trackInfo.isStream ? "STREAM" : length) + "`", false);
} else {
embedBuilder.setDescription("Es gibt kein weiteres Lied in der Warteschlange");
}
} else {
embedBuilder.setDescription("Du bist in keinem Voicechannel mit dem Bot");
}
msg.getTextChannel().sendMessage(embedBuilder.build()).queue();
}
use of com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo in project lavaplayer by sedmelluq.
the class SoundCloudAudioSourceManager method buildAudioTrack.
private AudioTrack buildAudioTrack(JsonBrowser trackInfoJson, String secretToken) {
String trackId = trackInfoJson.get("id").text();
AudioTrackInfo trackInfo = new AudioTrackInfo(trackInfoJson.get("title").text(), trackInfoJson.get("user").get("username").text(), trackInfoJson.get("duration").as(Integer.class), secretToken != null ? trackId + "|" + secretToken : trackId, false, trackInfoJson.get("permalink_url").text());
return new SoundCloudAudioTrack(trackInfo, this);
}
use of com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo in project lavaplayer by sedmelluq.
the class TwitchStreamAudioSourceManager method loadItem.
@Override
public AudioItem loadItem(DefaultAudioPlayerManager manager, AudioReference reference) {
String streamName = getChannelIdentifierFromUrl(reference.identifier);
if (streamName == null) {
return null;
}
JsonBrowser channelInfo = fetchStreamChannelInfo(streamName);
if (channelInfo == null) {
return AudioReference.NO_TRACK;
} else {
final String displayName = channelInfo.get("display_name").text();
final String status = channelInfo.get("status").text();
return new TwitchStreamAudioTrack(new AudioTrackInfo(status, displayName, Long.MAX_VALUE, reference.identifier, true, reference.identifier), this);
}
}
use of com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo in project lavaplayer by sedmelluq.
the class MatroskaContainerProbe method probe.
@Override
public MediaContainerDetectionResult probe(AudioReference reference, SeekableInputStream inputStream) throws IOException {
if (!checkNextBytes(inputStream, EBML_TAG)) {
return null;
}
log.debug("Track {} is a matroska file.", reference.identifier);
MatroskaStreamingFile file = new MatroskaStreamingFile(inputStream);
file.readFile();
if (!hasSupportedAudioTrack(file)) {
return new MediaContainerDetectionResult(this, "No supported audio tracks present in the file.");
}
return new MediaContainerDetectionResult(this, new AudioTrackInfo(UNKNOWN_TITLE, UNKNOWN_ARTIST, (long) file.getDuration(), reference.identifier, false, reference.identifier));
}
Aggregations