Skip to content

Commit

Permalink
Support yt oauth
Browse files Browse the repository at this point in the history
  • Loading branch information
davidffa committed Sep 7, 2024
1 parent 767913a commit 3ad55a6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
10 changes: 9 additions & 1 deletion application.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 3ad55a6

Please sign in to comment.