From 137f7d78775430194deb3cfefc526c7fcda770bc Mon Sep 17 00:00:00 2001 From: Avery Black Date: Tue, 23 Apr 2024 22:30:26 -0700 Subject: [PATCH] Use new youtube source --- build.gradle | 5 +++-- settings.gradle | 3 +++ .../wylx/Core/Music/WylxPlayerManager.java | 16 ++++++++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 0a21ac2..239bec0 100644 --- a/build.gradle +++ b/build.gradle @@ -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") } diff --git a/settings.gradle b/settings.gradle index b6d7c8a..ead40bc 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,3 +1,6 @@ rootProject.name = 'WylxBot' include('main') +// Youtube-Source +include('lldevs') + diff --git a/src/main/java/com/wylxbot/wylx/Core/Music/WylxPlayerManager.java b/src/main/java/com/wylxbot/wylx/Core/Music/WylxPlayerManager.java index 84129c0..dbd302f 100644 --- a/src/main/java/com/wylxbot/wylx/Core/Music/WylxPlayerManager.java +++ b/src/main/java/com/wylxbot/wylx/Core/Music/WylxPlayerManager.java @@ -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; @@ -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);