diff --git a/LavalinkServer/src/main/kotlin/lavalink/server/config/AudioPlayerConfiguration.kt b/LavalinkServer/src/main/kotlin/lavalink/server/config/AudioPlayerConfiguration.kt index 3031b82..1900d73 100644 --- a/LavalinkServer/src/main/kotlin/lavalink/server/config/AudioPlayerConfiguration.kt +++ b/LavalinkServer/src/main/kotlin/lavalink/server/config/AudioPlayerConfiguration.kt @@ -82,6 +82,14 @@ class AudioPlayerConfiguration { TvHtml5EmbeddedWithThumbnail() ) + lavaplayerProps.youtubeConfig?.let { ytConfig -> + if (ytConfig.oauthEnabled == true) { + youtube.useOauth2(ytConfig.refreshToken, ytConfig.refreshToken != null) + } + + Web.setPoTokenAndVisitorData(ytConfig.poToken, ytConfig.visitorData) + } + if (routePlanner != null) { val retryLimit = lavaplayerProps.ratelimit?.retryLimit ?: -1 @@ -102,12 +110,6 @@ class AudioPlayerConfiguration { } audioPlayerManager.registerSourceManager(youtube) - - val ytConfig = lavaplayerProps.youtubeConfig - - if (ytConfig != null) { - Web.setPoTokenAndVisitorData(ytConfig.poToken, ytConfig.visitorData) - } } if (sources.soundcloud) audioPlayerManager.registerSourceManager(SoundCloudAudioSourceManager.createDefault(lavaplayerProps.isSoundcloudSearchEnabled)) diff --git a/LavalinkServer/src/main/kotlin/lavalink/server/config/YoutubeConfig.kt b/LavalinkServer/src/main/kotlin/lavalink/server/config/YoutubeConfig.kt index 3401f91..28b5c61 100644 --- a/LavalinkServer/src/main/kotlin/lavalink/server/config/YoutubeConfig.kt +++ b/LavalinkServer/src/main/kotlin/lavalink/server/config/YoutubeConfig.kt @@ -3,4 +3,6 @@ package lavalink.server.config class YoutubeConfig { var poToken: String? = null var visitorData: String? = null + var oauthEnabled: Boolean? = null + var refreshToken: String? = null } \ No newline at end of file diff --git a/application.yml.example b/application.yml.example index 39c5c81..1d0618f 100644 --- a/application.yml.example +++ b/application.yml.example @@ -40,9 +40,17 @@ lavalink: odyseeSearchEnabled: true soundcloudSearchEnabled: true yandexMusicSearchEnabled: true - #youtubeConfig: (Bypass yt bot detection, get them here https://github.com/iv-org/youtube-trusted-session-generator) + #youtubeConfig: + # (Bypass yt bot detection (method 1), get them here https://github.com/iv-org/youtube-trusted-session-generator) #poToken: "" #visitorData: "" + # (Bypass yt bot detection (method 2) + # First, enable oauth, by uncommenting the oauthEnabled and start the lavalink + # Secondly, follow the instructions in the lavalink logs and login to youtube using a burner account + # Finally, get the refresh token in the lavalink logs and uncomment the refreshToken line and put it there + # More info: https://github.com/lavalink-devs/youtube-source?tab=readme-ov-file#using-oauth-tokens + #oauthEnabled: true + #refreshToken: "" # You can get your yandex oauth token here https://music-yandex-bot.ru/ used to remove the 30s limit on some tracks #yandexOAuthToken: #ratelimit: