Skip to content

Commit

Permalink
Fix crash when parsing song other artists
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex1304 committed Jun 19, 2024
1 parent b3fec3e commit 58521fd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion client/src/test/java/jdash/client/GDClientTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public final class GDClientTest {
/* Not part of unit tests, this is only to test the real router implementation */
public static void main(String[] args) {
final var client = GDClient.create();
System.out.println(client.getSongInfo(10007009).block());
System.out.println(client.getSongInfo(10010067).block());
}

@BeforeEach
Expand Down
8 changes: 4 additions & 4 deletions common/src/main/java/jdash/common/internal/InternalUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public static Map<Long, GDSong> structureSongsInfo(String songsInfoRD) {
Objects.equals(data.get(SONG_NG_SCOUTED), "1"),
Optional.ofNullable(urlDecode(data.get(SONG_URL))).filter(not(String::isEmpty)),
MusicLibraryProvider.parse(data.get(SONG_PROVIDER_ID)),
toList(data.get(SONG_OTHER_ARTIST_IDS), 0, Long::parseLong).orElse(List.of())
toList(data.get(SONG_OTHER_ARTIST_IDS), 0, Long::parseLong, "\\.").orElse(List.of())
));
}

Expand Down Expand Up @@ -313,14 +313,14 @@ public static GDUserProfile buildUserProfile(Map<Integer, String> data) {
}

private static Optional<List<Integer>> toIntList(String str, int minSize) {
return toList(str, minSize, Integer::parseInt);
return toList(str, minSize, Integer::parseInt, ",");
}

private static <T> Optional<List<T>> toList(String str, int minSize, Function<String, T> parser) {
private static <T> Optional<List<T>> toList(String str, int minSize, Function<String, T> parser, String sep) {
if (str == null || str.isEmpty()) {
return Optional.empty();
}
return Optional.of(Arrays.stream(str.split(",")).map(parser).toList())
return Optional.of(Arrays.stream(str.split(sep)).map(parser).toList())
.filter(values -> values.size() >= minSize);
}

Expand Down
12 changes: 6 additions & 6 deletions website/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8316,14 +8316,14 @@ write-file-atomic@^3.0.3:
typedarray-to-buffer "^3.1.5"

ws@^7.3.1:
version "7.5.9"
resolved "https://registry.yarnpkg.com/ws/-/ws-7.5.9.tgz#54fa7db29f4c7cec68b1ddd3a89de099942bb591"
integrity sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==
version "7.5.10"
resolved "https://registry.yarnpkg.com/ws/-/ws-7.5.10.tgz#58b5c20dc281633f6c19113f39b349bd8bd558d9"
integrity "sha1-WLXCDcKBYz9sGRE/ObNJvYvVWNk= sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ=="

ws@^8.13.0:
version "8.17.0"
resolved "https://registry.yarnpkg.com/ws/-/ws-8.17.0.tgz#d145d18eca2ed25aaf791a183903f7be5e295fea"
integrity sha512-uJq6108EgZMAl20KagGkzCKfMEjxmKvZHG7Tlq0Z6nOky7YF7aq4mOx6xK8TJ/i1LeK4Qus7INktacctDgY8Ow==
version "8.17.1"
resolved "https://registry.yarnpkg.com/ws/-/ws-8.17.1.tgz#9293da530bb548febc95371d90f9c878727d919b"
integrity "sha1-kpPaUwu1SP68lTcdkPnIeHJ9kZs= sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ=="

xdg-basedir@^5.0.1, xdg-basedir@^5.1.0:
version "5.1.0"
Expand Down

0 comments on commit 58521fd

Please sign in to comment.