|
11 | 11 | import xyz.gianlu.librespot.core.Session; |
12 | 12 | import xyz.gianlu.librespot.dealer.ApiClient; |
13 | 13 | import xyz.gianlu.librespot.mercury.MercuryClient; |
| 14 | +import xyz.gianlu.librespot.mercury.MercuryRequests; |
14 | 15 | import xyz.gianlu.librespot.mercury.model.*; |
15 | 16 |
|
16 | 17 | import java.io.IOException; |
@@ -87,14 +88,29 @@ private JsonObject handle(@NotNull Session session, @NotNull MetadataType type, |
87 | 88 | return ProtobufToJson.convert(session.api().getMetadata4Episode(EpisodeId.fromUri(uri))); |
88 | 89 | case TRACK: |
89 | 90 | return ProtobufToJson.convert(session.api().getMetadata4Track(TrackId.fromUri(uri))); |
| 91 | + case PLAYLIST: |
| 92 | + return handlePlaylist(session, uri); |
90 | 93 | default: |
91 | 94 | throw new IllegalArgumentException(type.name()); |
92 | 95 | } |
93 | 96 | } |
94 | 97 |
|
| 98 | + @NotNull |
| 99 | + private JsonObject handlePlaylist(@NotNull Session session, @NotNull String uri) throws IOException, MercuryClient.MercuryException { |
| 100 | + JsonObject obj = new JsonObject(); |
| 101 | + obj.add("tracks", session.mercury().sendSync(MercuryRequests.getPlaylist(PlaylistId.fromUri(uri))).json()); |
| 102 | + |
| 103 | + try { |
| 104 | + obj.add("annotations", session.mercury().sendSync(MercuryRequests.getPlaylistAnnotation(PlaylistId.fromUri(uri))).json()); |
| 105 | + } catch (MercuryClient.MercuryException ignored) { |
| 106 | + } |
| 107 | + |
| 108 | + return obj; |
| 109 | + } |
| 110 | + |
95 | 111 | private enum MetadataType { |
96 | 112 | EPISODE("episode"), TRACK("track"), ALBUM("album"), |
97 | | - ARTIST("artist"), SHOW("show"); |
| 113 | + ARTIST("artist"), SHOW("show"), PLAYLIST("playlist"); |
98 | 114 |
|
99 | 115 | private final String val; |
100 | 116 |
|
|
0 commit comments