Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use new youtube source #132

Merged
merged 1 commit into from
Apr 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ repositories {
dependencies {
implementation("org.apache.commons:commons-text:1.10.0")
implementation("io.github.cdimascio:dotenv-kotlin:6.4.1")
implementation("net.dv8tion:JDA:5.0.0-beta.13")
implementation("net.dv8tion:JDA:5.0.0-beta.23")
implementation("ch.qos.logback:logback-classic:1.4.5")
implementation('dev.arbjerg:lavaplayer:2.1.1') // https://github.com/lavalink-devs/lavaplayer
implementation("dev.arbjerg:lavaplayer:2.1.1") // https://github.com/lavalink-devs/lavaplayer
implementation("com.github.lavalink-devs:youtube-source:1.0.5")
implementation("org.mongodb:mongodb-driver-sync:4.8.2")
implementation ("org.scilab.forge:jlatexmath:1.0.7")
}
Expand Down
3 changes: 3 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
rootProject.name = 'WylxBot'
include('main')

// Youtube-Source
include('lldevs')

16 changes: 16 additions & 0 deletions src/main/java/com/wylxbot/wylx/Core/Music/WylxPlayerManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
import com.sedmelluq.discord.lavaplayer.player.AudioPlayerManager;
import com.sedmelluq.discord.lavaplayer.player.DefaultAudioPlayerManager;
import com.sedmelluq.discord.lavaplayer.source.AudioSourceManagers;
import dev.lavalink.youtube.YoutubeAudioSourceManager;
import dev.lavalink.youtube.clients.AndroidWithThumbnail;
import dev.lavalink.youtube.clients.MusicWithThumbnail;
import dev.lavalink.youtube.clients.WebWithThumbnail;

import java.util.concurrent.ConcurrentHashMap;

Expand All @@ -13,6 +17,18 @@ public class WylxPlayerManager {

private WylxPlayerManager() {
playerManager = new DefaultAudioPlayerManager();

// Use Youtube Source manager from youtube-source repo instead of built-in
YoutubeAudioSourceManager ytSrcMgr = new YoutubeAudioSourceManager(
/*allowSearch:*/ true,
new MusicWithThumbnail(),
new WebWithThumbnail(),
new AndroidWithThumbnail()
);

playerManager.registerSourceManager(ytSrcMgr);

// Add rest of the build-in audio sources
AudioSourceManagers.registerRemoteSources(playerManager);
AudioSourceManagers.registerLocalSource(playerManager);

Expand Down
Loading