From c1ff05db1045c793764ebdff6e6c8e9bf2d6aaec Mon Sep 17 00:00:00 2001 From: devoxin <15076404+devoxin@users.noreply.github.com> Date: Mon, 25 Mar 2024 13:13:06 +0000 Subject: [PATCH 1/6] Add config option for enabling NicoAudioSourceManager (#1027) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add config option and support for nico * enable nico by default * add note on http source * add nico source into environment variables --------- Co-authored-by: Toπ --- LavalinkServer/application.yml.example | 3 ++- .../java/lavalink/server/config/AudioPlayerConfiguration.kt | 2 ++ .../src/main/java/lavalink/server/config/AudioSourcesConfig.kt | 1 + docs/configuration/index.md | 1 + 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/LavalinkServer/application.yml.example b/LavalinkServer/application.yml.example index 8b63c2e34..f9000723b 100644 --- a/LavalinkServer/application.yml.example +++ b/LavalinkServer/application.yml.example @@ -23,7 +23,8 @@ lavalink: soundcloud: true twitch: true vimeo: true - http: true + nico: true + http: true # warning: keeping HTTP enabled without a proxy configured could expose your server's IP address. local: false filters: # All filters are enabled by default volume: true diff --git a/LavalinkServer/src/main/java/lavalink/server/config/AudioPlayerConfiguration.kt b/LavalinkServer/src/main/java/lavalink/server/config/AudioPlayerConfiguration.kt index 79f0213a4..2134288c3 100644 --- a/LavalinkServer/src/main/java/lavalink/server/config/AudioPlayerConfiguration.kt +++ b/LavalinkServer/src/main/java/lavalink/server/config/AudioPlayerConfiguration.kt @@ -9,6 +9,7 @@ import com.sedmelluq.discord.lavaplayer.source.AudioSourceManager import com.sedmelluq.discord.lavaplayer.source.bandcamp.BandcampAudioSourceManager import com.sedmelluq.discord.lavaplayer.source.http.HttpAudioSourceManager import com.sedmelluq.discord.lavaplayer.source.local.LocalAudioSourceManager +import com.sedmelluq.discord.lavaplayer.source.nico.NicoAudioSourceManager import com.sedmelluq.discord.lavaplayer.source.soundcloud.* import com.sedmelluq.discord.lavaplayer.source.twitch.TwitchStreamAudioSourceManager import com.sedmelluq.discord.lavaplayer.source.vimeo.VimeoAudioSourceManager @@ -155,6 +156,7 @@ class AudioPlayerConfiguration { if (sources.isBandcamp) audioPlayerManager.registerSourceManager(BandcampAudioSourceManager()) if (sources.isTwitch) audioPlayerManager.registerSourceManager(TwitchStreamAudioSourceManager()) if (sources.isVimeo) audioPlayerManager.registerSourceManager(VimeoAudioSourceManager()) + if (sources.isNico) audioPlayerManager.registerSourceManager(NicoAudioSourceManager()) if (sources.isLocal) audioPlayerManager.registerSourceManager(LocalAudioSourceManager(mcr)) audioSourceManagers.forEach { diff --git a/LavalinkServer/src/main/java/lavalink/server/config/AudioSourcesConfig.kt b/LavalinkServer/src/main/java/lavalink/server/config/AudioSourcesConfig.kt index 692d8cfcc..e98c2c1b4 100644 --- a/LavalinkServer/src/main/java/lavalink/server/config/AudioSourcesConfig.kt +++ b/LavalinkServer/src/main/java/lavalink/server/config/AudioSourcesConfig.kt @@ -14,6 +14,7 @@ data class AudioSourcesConfig( var isSoundcloud: Boolean = true, var isTwitch: Boolean = true, var isVimeo: Boolean = true, + var isNico: Boolean = false, var isHttp: Boolean = true, var isLocal: Boolean = false, ) diff --git a/docs/configuration/index.md b/docs/configuration/index.md index 011613c41..a67c49f6a 100644 --- a/docs/configuration/index.md +++ b/docs/configuration/index.md @@ -47,6 +47,7 @@ LAVALINK_SERVER_SOURCES_SOUNDCLOUD LAVALINK_SERVER_SOURCES_TWITCH LAVALINK_SERVER_SOURCES_VIMEO LAVALINK_SERVER_SOURCES_HTTP +LAVALINK_SERVER_SOURCES_NICO LAVALINK_SERVER_SOURCES_LOCAL LAVALINK_SERVER_FILTERS_VOLUME From 0736cc403c662020bcb40064349b09da3b320d7a Mon Sep 17 00:00:00 2001 From: topi314 Date: Fri, 19 Apr 2024 22:48:15 +0200 Subject: [PATCH 2/6] update koe to 2.0.1 --- settings.gradle.kts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/settings.gradle.kts b/settings.gradle.kts index 1e6dff63c..57ae1ddec 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -42,8 +42,8 @@ fun VersionCatalogBuilder.voice() { library("lavaplayer-ip-rotator", "dev.arbjerg", "lavaplayer-ext-youtube-rotator").versionRef("lavaplayer") library("lavadsp", "dev.arbjerg", "lavadsp").version("0.7.8") - library("koe", "moe.kyokobot.koe", "core").version("2.0.0-rc2") - library("koe-udpqueue", "moe.kyokobot.koe", "ext-udpqueue").version("2.0.0-rc2") + library("koe", "moe.kyokobot.koe", "core").version("2.0.1") + library("koe-udpqueue", "moe.kyokobot.koe", "ext-udpqueue").version("2.0.1") version("udpqueue", "0.2.7") val platforms = listOf("linux-x86-64", "linux-x86", "linux-aarch64", "linux-arm", "linux-musl-x86-64", "linux-musl-aarch64", "win-x86-64", "win-x86", "darwin") From 78c090c4a44860cfee781ee20e1db391b169a7ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?To=CF=80?= Date: Sun, 28 Apr 2024 11:58:13 +0200 Subject: [PATCH 3/6] Expose lavalink sessions for plugins (#1042) --- .../java/lavalink/server/io/SocketServer.kt | 17 +++++++++-------- .../src/main/java/lavalink/server/util/util.kt | 2 +- .../dev/arbjerg/lavalink/api/ISocketServer.kt | 17 +++++++++++++++++ 3 files changed, 27 insertions(+), 9 deletions(-) create mode 100644 plugin-api/src/main/java/dev/arbjerg/lavalink/api/ISocketServer.kt diff --git a/LavalinkServer/src/main/java/lavalink/server/io/SocketServer.kt b/LavalinkServer/src/main/java/lavalink/server/io/SocketServer.kt index 5cf087783..6ffbdfc61 100644 --- a/LavalinkServer/src/main/java/lavalink/server/io/SocketServer.kt +++ b/LavalinkServer/src/main/java/lavalink/server/io/SocketServer.kt @@ -24,6 +24,7 @@ package lavalink.server.io import com.sedmelluq.discord.lavaplayer.player.AudioPlayerManager import dev.arbjerg.lavalink.api.AudioPluginInfoModifier +import dev.arbjerg.lavalink.api.ISocketServer import dev.arbjerg.lavalink.api.PluginEventHandler import dev.arbjerg.lavalink.protocol.v4.Message import dev.arbjerg.lavalink.protocol.v4.PlayerState @@ -46,11 +47,11 @@ final class SocketServer( koeOptions: KoeOptions, private val eventHandlers: List, private val pluginInfoModifiers: List -) : TextWebSocketHandler() { +) : TextWebSocketHandler(), ISocketServer { // sessionID <-> Session - val contextMap = ConcurrentHashMap() - private val resumableSessions = mutableMapOf() + override val sessions = ConcurrentHashMap() + override val resumableSessions = mutableMapOf() private val koe = Koe.koe(koeOptions) private val statsCollector = StatsCollector(this) private val charPool = ('a'..'z') + ('0'..'9') @@ -81,12 +82,12 @@ final class SocketServer( var sessionId: String do { sessionId = List(16) { charPool.random() }.joinToString("") - } while (contextMap[sessionId] != null) + } while (sessions[sessionId] != null) return sessionId } val contexts: Collection - get() = contextMap.values + get() = sessions.values @Suppress("UastIncorrectHttpHeaderInspection") override fun afterConnectionEstablished(session: WebSocketSession) { @@ -100,7 +101,7 @@ final class SocketServer( if (resumable != null) { session.attributes["sessionId"] = resumable.sessionId - contextMap[resumable.sessionId] = resumable + sessions[resumable.sessionId] = resumable resumable.resume(session) log.info("Resumed session with id $sessionId") resumable.eventEmitter.onWebSocketOpen(true) @@ -123,7 +124,7 @@ final class SocketServer( eventHandlers, pluginInfoModifiers ) - contextMap[sessionId] = socketContext + sessions[sessionId] = socketContext socketContext.sendMessage(Message.Serializer, Message.ReadyEvent(false, sessionId)) socketContext.eventEmitter.onWebSocketOpen(false) if (clientName != null) { @@ -140,7 +141,7 @@ final class SocketServer( } override fun afterConnectionClosed(session: WebSocketSession, status: CloseStatus) { - val context = contextMap.remove(session.attributes["sessionId"]) ?: return + val context = sessions.remove(session.attributes["sessionId"]) ?: return if (context.resumable) { resumableSessions.remove(context.sessionId)?.let { removed -> log.warn( diff --git a/LavalinkServer/src/main/java/lavalink/server/util/util.kt b/LavalinkServer/src/main/java/lavalink/server/util/util.kt index a3b63d39e..040b532a8 100644 --- a/LavalinkServer/src/main/java/lavalink/server/util/util.kt +++ b/LavalinkServer/src/main/java/lavalink/server/util/util.kt @@ -122,7 +122,7 @@ fun getRootCause(throwable: Throwable?): Throwable { } fun socketContext(socketServer: SocketServer, sessionId: String) = - socketServer.contextMap[sessionId] ?: throw ResponseStatusException(HttpStatus.NOT_FOUND, "Session not found") + socketServer.sessions[sessionId] ?: throw ResponseStatusException(HttpStatus.NOT_FOUND, "Session not found") fun existingPlayer(socketContext: SocketContext, guildId: Long) = socketContext.players[guildId] ?: throw ResponseStatusException(HttpStatus.NOT_FOUND, "Player not found") diff --git a/plugin-api/src/main/java/dev/arbjerg/lavalink/api/ISocketServer.kt b/plugin-api/src/main/java/dev/arbjerg/lavalink/api/ISocketServer.kt new file mode 100644 index 000000000..d54627e20 --- /dev/null +++ b/plugin-api/src/main/java/dev/arbjerg/lavalink/api/ISocketServer.kt @@ -0,0 +1,17 @@ +package dev.arbjerg.lavalink.api + +/** + * Represents a Lavalink server which handles WebSocket connections. + */ +interface ISocketServer { + /** + * A map of all active sessions by their session id. + */ + val sessions: Map + + /** + * A map of all resumable sessions by their session id. + * A session is resumable if the client configured resuming and has disconnected. + */ + val resumableSessions: Map +} \ No newline at end of file From 96b87bd62355d8e1b6054180bae8ca88e835f7c9 Mon Sep 17 00:00:00 2001 From: topi314 Date: Sun, 5 May 2024 22:29:31 +0200 Subject: [PATCH 4/6] update lavaplayer to 2.1.2 --- settings.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings.gradle.kts b/settings.gradle.kts index 57ae1ddec..b573a8e37 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -36,7 +36,7 @@ fun VersionCatalogBuilder.spring() { } fun VersionCatalogBuilder.voice() { - version("lavaplayer", "2.1.1") + version("lavaplayer", "2.1.2") library("lavaplayer", "dev.arbjerg", "lavaplayer").versionRef("lavaplayer") library("lavaplayer-ip-rotator", "dev.arbjerg", "lavaplayer-ext-youtube-rotator").versionRef("lavaplayer") From f985f7029631da0e8cc6eaf60bf2b0915023548e Mon Sep 17 00:00:00 2001 From: topi314 Date: Sun, 5 May 2024 22:36:11 +0200 Subject: [PATCH 5/6] add warning about enabled default youtube source --- .../lavalink/server/config/AudioPlayerConfiguration.kt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/LavalinkServer/src/main/java/lavalink/server/config/AudioPlayerConfiguration.kt b/LavalinkServer/src/main/java/lavalink/server/config/AudioPlayerConfiguration.kt index 2134288c3..ca6fd99c1 100644 --- a/LavalinkServer/src/main/java/lavalink/server/config/AudioPlayerConfiguration.kt +++ b/LavalinkServer/src/main/java/lavalink/server/config/AudioPlayerConfiguration.kt @@ -103,6 +103,14 @@ class AudioPlayerConfiguration { val mcr: MediaContainerRegistry = MediaContainerRegistry.extended(*mediaContainerProbes.toTypedArray()) if (sources.isYoutube) { + log.warn( + """ + The default Youtube source is now deprecated and won't receive further updates. + You should use the new Youtube source plugin instead. + https://github.com/lavalink-devs/youtube-source#plugin. + To disable this warning, set 'lavalink.server.sources.youtube' to false in your application.yml. + """.trimIndent() + ) val youtubeConfig = serverConfig.youtubeConfig val youtube: YoutubeAudioSourceManager if (youtubeConfig != null) { From 0e13bbf8d1f8fb29d5e7c8eea48789d22430daa5 Mon Sep 17 00:00:00 2001 From: topi314 Date: Sun, 5 May 2024 22:38:57 +0200 Subject: [PATCH 6/6] update changelog for v4.0.5 --- CHANGELOG.md | 23 ++++++++++++++++++++++- docs/changelog/v3.md | 7 +++++++ docs/changelog/v4.md | 11 ++++++++++- 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bda14c865..93d5d7963 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,8 +3,17 @@ Each release usually includes various fixes and improvements. The most noteworthy of these, as well as any features and breaking changes, are listed here. +## v4.0.5 +* Updated Lavaplayer to [`2.1.2`](https://github.com/lavalink-devs/lavaplayer/releases/tag/2.1.2) +* Updated Koe to [`2.0.1`](https://github.com/KyokoBot/koe/releases/tag/2.0.1) (fixes the `IndexOutOfBoundsException` when playing a YouTube track) +* Added option to enable [Nico](https://www.nicovideo.jp/) source +* Expose Lavalink sessions to plugins via the `ISocketServer` interface + +> [!WARNING] +> The default Youtube source is now deprecated and won't receive further updates. Please use https://github.com/lavalink-devs/youtube-source#plugin instead. + ## v4.0.4 -* Update Lavaplayer to `2.1.1` +* Update Lavaplayer to [`2.1.1`](https://github.com/lavalink-devs/lavaplayer/releases/tag/2.1.1) ## v4.0.3 * Fixed plugins not registering (introduced in [`4.0.2`](https://github.com/lavalink-devs/Lavalink/releases/tag/4.0.2)) @@ -89,6 +98,18 @@ Contributors: +## v3.7.12 +* Updated Lavaplayer to [`1.5.4`](https://github.com/lavalink-devs/lavaplayer/releases/tag/1.5.4) +* Updated Koe to [`2.0.1`](https://github.com/KyokoBot/koe/releases/tag/2.0.1) (fixes the `IndexOutOfBoundsException` when playing a YouTube track) + +> [!WARNING] +> The default Youtube source is now deprecated and won't receive further updates. Please use https://github.com/lavalink-devs/youtube-source#plugin instead. + +## v3.7.11 +* Fixed not being able to seek when player is paused +* Update Oshi to `6.4.3` +* Update Lavaplayer to `1.5.3` + ## v3.7.10 * Update lavaplayer to [`1.5.2`](https://github.com/lavalink-devs/lavaplayer/releases/tag/1.5.2) - Fixed NPE on missing author in playlist tracks in YouTube diff --git a/docs/changelog/v3.md b/docs/changelog/v3.md index 9c1c3c351..f28508457 100644 --- a/docs/changelog/v3.md +++ b/docs/changelog/v3.md @@ -1,3 +1,10 @@ +## v3.7.12 +* Updated Lavaplayer to [`1.5.4`](https://github.com/lavalink-devs/lavaplayer/releases/tag/1.5.4) +* Updated Koe to [`2.0.1`](https://github.com/KyokoBot/koe/releases/tag/2.0.1) (fixes the `IndexOutOfBoundsException` when playing a YouTube track) + +> [!WARNING] +> The default Youtube source is now deprecated and won't receive further updates. Please use https://github.com/lavalink-devs/youtube-source#plugin instead. + ## v3.7.11 * Fixed not being able to seek when player is paused * Updated Oshi to `6.4.3` diff --git a/docs/changelog/v4.md b/docs/changelog/v4.md index d9b9a2d82..8f17b3035 100644 --- a/docs/changelog/v4.md +++ b/docs/changelog/v4.md @@ -1,5 +1,14 @@ +## v4.0.5 +* Updated Lavaplayer to [`2.1.2`](https://github.com/lavalink-devs/lavaplayer/releases/tag/2.1.2) +* Updated Koe to [`2.0.1`](https://github.com/KyokoBot/koe/releases/tag/2.0.1) (fixes the `IndexOutOfBoundsException` when playing a YouTube track) +* Added option to enable [Nico](https://www.nicovideo.jp/) source +* Expose Lavalink sessions to plugins via the `ISocketServer` interface + +> [!WARNING] +> The default Youtube source is now deprecated and won't receive further updates. Please use https://github.com/lavalink-devs/youtube-source#plugin instead. + ## v4.0.4 -* Updated Lavaplayer to `2.1.1` +* Updated Lavaplayer to [`2.1.1`](https://github.com/lavalink-devs/lavaplayer/releases/tag/2.1.1) ## v4.0.3 * Fixed plugins not registering (introduced in [`4.0.2`](https://github.com/lavalink-devs/Lavalink/releases/tag/4.0.2))