File tree Expand file tree Collapse file tree 4 files changed +27
-9
lines changed
src/main/java/dev/lavalink/youtube/plugin Expand file tree Collapse file tree 4 files changed +27
-9
lines changed Original file line number Diff line number Diff line change @@ -308,14 +308,19 @@ Body:
308308` ` `
309309
310310Response :
311+
312+ If the YouTube source is not enabled, or the `refreshToken` is invalid :
313+ ` 500 - Internal Server Error`
314+
315+ Otherwise :
311316` 204 - No Content`
312317
313318# ## `GET` `/youtube`
314319
315320Response :
316321
317322If the YouTube source is not enabled :
318- ` 400 - Bad Request `
323+ ` 500 - Internal Server Error `
319324
320325Otherwise :
321326` ` ` json
@@ -324,8 +329,6 @@ Otherwise:
324329}
325330` ` `
326331
327-
328-
329332# # Migration from Lavaplayer's built-in YouTube source
330333
331334This client is intended as a direct replacement for Lavaplayer's built-in `YoutubeAudioSourceManager`,
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ lavalinkPlugin {
1212 name = " youtube-plugin"
1313 path = " dev.lavalink.youtube.plugin"
1414 apiVersion = libs.versions.lavalink
15- serverVersion = " 4.0.4 "
15+ serverVersion = " 4.0.7 "
1616 configurePublishing = false
1717}
1818
Original file line number Diff line number Diff line change 22
33import com .sedmelluq .discord .lavaplayer .player .AudioPlayerManager ;
44import dev .lavalink .youtube .YoutubeAudioSourceManager ;
5+ import dev .lavalink .youtube .plugin .rest .MinimalConfigResponse ;
56import org .slf4j .Logger ;
67import org .slf4j .LoggerFactory ;
78import org .springframework .http .HttpStatus ;
89import org .springframework .stereotype .Service ;
910import org .springframework .web .bind .annotation .*;
1011import org .springframework .web .server .ResponseStatusException ;
1112
12- import java .util .Collections ;
13- import java .util .Map ;
14-
1513@ Service
1614@ RestController
1715public class YoutubeRestHandler {
@@ -24,14 +22,14 @@ public YoutubeRestHandler(AudioPlayerManager playerManager) {
2422 }
2523
2624 @ GetMapping ("/youtube" )
27- public Map < String , String > getYoutubeConfig () {
25+ public MinimalConfigResponse getYoutubeConfig () {
2826 YoutubeAudioSourceManager source = playerManager .source (YoutubeAudioSourceManager .class );
2927
3028 if (source == null ) {
3129 throw new ResponseStatusException (HttpStatus .BAD_REQUEST , "The YouTube source manager is not registered." );
3230 }
3331
34- return Collections . singletonMap ( "refreshToken" , source . getOauth2RefreshToken () );
32+ return MinimalConfigResponse . from ( source );
3533 }
3634
3735 @ PostMapping ("/youtube" )
Original file line number Diff line number Diff line change 1+ package dev .lavalink .youtube .plugin .rest ;
2+
3+ import dev .lavalink .youtube .YoutubeAudioSourceManager ;
4+ import org .jetbrains .annotations .Nullable ;
5+
6+ public class MinimalConfigResponse {
7+ @ Nullable
8+ public String refreshToken ;
9+
10+ private MinimalConfigResponse (@ Nullable String refreshToken ) {
11+ this .refreshToken = refreshToken ;
12+ }
13+
14+ public static MinimalConfigResponse from (YoutubeAudioSourceManager sourceManager ) {
15+ return new MinimalConfigResponse (sourceManager .getOauth2RefreshToken ());
16+ }
17+ }
You can’t perform that action at this time.
0 commit comments