diff --git a/core/src/main/kotlin/su/plo/voice/discs/AddonConfig.kt b/core/src/main/kotlin/su/plo/voice/discs/AddonConfig.kt index bd0fe25..658edb5 100644 --- a/core/src/main/kotlin/su/plo/voice/discs/AddonConfig.kt +++ b/core/src/main/kotlin/su/plo/voice/discs/AddonConfig.kt @@ -156,6 +156,16 @@ class AddonConfig { """ ) val useOauth2: Boolean = false + + @ConfigField( + comment = """ + You can check available clients here: https://github.com/lavalink-devs/youtube-source?tab=readme-ov-file#available-clients + """, + nullComment = """ + clients = ["WEB", "ANDROID", "TVHTML5EMBEDDED", "MUSIC"] + """ + ) + val clients: List? = null } @ConfigField diff --git a/core/src/main/kotlin/su/plo/voice/discs/PlasmoAudioPlayerManager.kt b/core/src/main/kotlin/su/plo/voice/discs/PlasmoAudioPlayerManager.kt index b7736eb..84a462e 100644 --- a/core/src/main/kotlin/su/plo/voice/discs/PlasmoAudioPlayerManager.kt +++ b/core/src/main/kotlin/su/plo/voice/discs/PlasmoAudioPlayerManager.kt @@ -9,6 +9,7 @@ import su.plo.voice.api.server.audio.provider.AudioFrameProvider import su.plo.voice.api.server.audio.provider.AudioFrameResult import su.plo.voice.api.server.audio.source.ServerProximitySource import su.plo.voice.discs.utils.PluginKoinComponent +import su.plo.voice.discs.config.YoutubeClient import su.plo.voice.lavaplayer.libs.com.sedmelluq.discord.lavaplayer.player.AudioLoadResultHandler import su.plo.voice.lavaplayer.libs.com.sedmelluq.discord.lavaplayer.player.AudioPlayerManager import su.plo.voice.lavaplayer.libs.com.sedmelluq.discord.lavaplayer.player.DefaultAudioPlayerManager @@ -197,8 +198,26 @@ class PlasmoAudioPlayerManager : PluginKoinComponent { val proxyHttpBuilder = proxyHttpBuilder() proxyHttpBuilder?.let { lavaPlayerManager.setHttpBuilderConfigurator(it) } + val youtubeClients = config.youtubeSource.clients + ?.mapNotNull { + try { + // todo: config resolver don't support list of enums for some reason + YoutubeClient.valueOf(it) + } catch (e: IllegalArgumentException) { + null + } + } + ?.takeIf { it.isNotEmpty() } + ?: listOf( + YoutubeClient.WEB, + YoutubeClient.ANDROID, + YoutubeClient.TVHTML5EMBEDDED, + YoutubeClient.MUSIC + ) + plugin.slF4JLogger.info("YouTube clients: {}", youtubeClients) + lavaPlayerManager.registerSourceManager( - YoutubeAudioSourceManager(true) + YoutubeAudioSourceManager(true, *youtubeClients.map { it.client }.toTypedArray()) .also { source -> proxyHttpBuilder?.let { source.httpInterfaceManager.configureBuilder(it) } diff --git a/core/src/main/kotlin/su/plo/voice/discs/config/YoutubeClient.kt b/core/src/main/kotlin/su/plo/voice/discs/config/YoutubeClient.kt new file mode 100644 index 0000000..9d19d06 --- /dev/null +++ b/core/src/main/kotlin/su/plo/voice/discs/config/YoutubeClient.kt @@ -0,0 +1,28 @@ +package su.plo.voice.discs.config + +import su.plo.voice.lavaplayer.libs.dev.lavalink.youtube.clients.Android +import su.plo.voice.lavaplayer.libs.dev.lavalink.youtube.clients.AndroidLite +import su.plo.voice.lavaplayer.libs.dev.lavalink.youtube.clients.AndroidMusic +import su.plo.voice.lavaplayer.libs.dev.lavalink.youtube.clients.AndroidTestsuite +import su.plo.voice.lavaplayer.libs.dev.lavalink.youtube.clients.Ios +import su.plo.voice.lavaplayer.libs.dev.lavalink.youtube.clients.MediaConnect +import su.plo.voice.lavaplayer.libs.dev.lavalink.youtube.clients.Music +import su.plo.voice.lavaplayer.libs.dev.lavalink.youtube.clients.TvHtml5Embedded +import su.plo.voice.lavaplayer.libs.dev.lavalink.youtube.clients.Web +import su.plo.voice.lavaplayer.libs.dev.lavalink.youtube.clients.WebEmbedded +import su.plo.voice.lavaplayer.libs.dev.lavalink.youtube.clients.skeleton.Client + +enum class YoutubeClient( + val client: Client +) { + MUSIC(Music()), + WEB(Web()), + WEBEMBEDDED(WebEmbedded()), + ANDROID(Android()), + ANDROID_TESTSUITE(AndroidTestsuite()), + ANDROID_LITE(AndroidLite()), + ANDROID_MUSIC(AndroidMusic()), + MEDIA_CONNECT(MediaConnect()), + IOS(Ios()), + TVHTML5EMBEDDED(TvHtml5Embedded()) +} \ No newline at end of file