4141public class YandexMusicSourceManager extends ExtendedAudioSourceManager implements HttpConfigurable , AudioLyricsManager , AudioSearchManager {
4242 public static final Pattern URL_PATTERN = Pattern .compile ("(https?://)?music\\ .yandex\\ .(?<domain>ru|com|kz|by)/(?<type1>artist|album|track)/(?<identifier>[0-9]+)(/(?<type2>track)/(?<identifier2>[0-9]+))?/?" );
4343 public static final Pattern URL_PLAYLIST_PATTERN = Pattern .compile ("(https?://)?music\\ .yandex\\ .(?<domain>ru|com|kz|by)/users/(?<identifier>[0-9A-Za-z@.-]+)/playlists/(?<identifier2>[0-9]+)/?" );
44+ public static final Pattern URL_PLAYLIST_UUID_PATTERN = Pattern .compile ("(https?://)?music\\ .yandex\\ .(?<domain>ru|com|kz|by)/playlists/(?<identifier>[0-9A-Za-z\\ -.]+)" );
4445 public static final Pattern EXTRACT_LYRICS_STROKE = Pattern .compile ("\\ [(?<min>\\ d{2}):(?<sec>\\ d{2})\\ .(?<mil>\\ d{2})] ?(?<text>.+)?" );
4546 public static final String SEARCH_PREFIX = "ymsearch:" ;
4647 public static final String RECOMMENDATIONS_PREFIX = "ymrec:" ;
@@ -316,6 +317,11 @@ public AudioItem loadItem(AudioPlayerManager manager, AudioReference reference)
316317 var playlistId = matcher .group ("identifier2" );
317318 return this .getPlaylist (userId , playlistId , matcher .group ("domain" ));
318319 }
320+ matcher = URL_PLAYLIST_UUID_PATTERN .matcher (reference .identifier );
321+ if (matcher .find ()) {
322+ var uuid = matcher .group ("identifier" );
323+ return this .getPlaylist (uuid , matcher .group ("domain" ));
324+ }
319325 } catch (IOException e ) {
320326 throw new RuntimeException (e );
321327 }
@@ -430,12 +436,27 @@ private AudioItem getArtist(String id, String domainEnd) throws IOException {
430436 );
431437 }
432438
439+ private AudioItem getPlaylist (String uuid , String domainEnd ) throws IOException {
440+ var json = this .getJson (
441+ PUBLIC_API_BASE + "/playlist/" + uuid
442+ + "?page-size=" + PLAYLIST_MAX_PAGE_ITEMS * playlistLoadLimit
443+ + "&rich-tracks=true"
444+ );
445+
446+ return this .getPlaylist (json , domainEnd , "https://music.yandex." + domainEnd + "/playlists/" + uuid );
447+ }
448+
433449 private AudioItem getPlaylist (String userString , String id , String domainEnd ) throws IOException {
434450 var json = this .getJson (
435451 PUBLIC_API_BASE + "/users/" + userString + "/playlists/" + id
436452 + "?page-size=" + PLAYLIST_MAX_PAGE_ITEMS * playlistLoadLimit
437453 + "&rich-tracks=true"
438454 );
455+
456+ return this .getPlaylist (json , domainEnd , "https://music.yandex." + domainEnd + "/users/" + userString + "/playlists/" + id );
457+ }
458+
459+ private AudioItem getPlaylist (JsonBrowser json , String domainEnd , String playlistUrl ) {
439460 if (json .isNull () || json .get ("result" ).isNull () || json .get ("result" ).get ("tracks" ).values ().isEmpty ()) {
440461 return AudioReference .NO_TRACK ;
441462 }
@@ -456,7 +477,7 @@ private AudioItem getPlaylist(String userString, String id, String domainEnd) th
456477 playlistTitle ,
457478 tracks ,
458479 ExtendedAudioPlaylist .Type .PLAYLIST ,
459- "https://music.yandex." + domainEnd + "/users/" + userString + "/playlists/" + id ,
480+ playlistUrl ,
460481 this .parseCoverUri (json .get ("result" )),
461482 author ,
462483 tracks .size ()
0 commit comments