Skip to content

Commit 937cfcd

Browse files
author
Bruce A Downs
authored
1 parent b807187 commit 937cfcd

File tree

2 files changed

+2
-20
lines changed

2 files changed

+2
-20
lines changed

src/main/java/se/michaelthelin/spotify/model_objects/specification/Track.java

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ public Track createModelObject(JsonObject jsonObject) {
562562
: null)
563563
.setDurationMs(
564564
hasAndNotNull(jsonObject, "duration_ms")
565-
? getDurationMsFixed(jsonObject) // TODO: use `jsonObject.get("duration_ms").getAsInt()` when Spotify has fixed their API / API description, see method documentation below
565+
? jsonObject.get("duration_ms").getAsInt()
566566
: null)
567567
.setExplicit(
568568
hasAndNotNull(jsonObject, "explicit")
@@ -627,22 +627,6 @@ public Track createModelObject(JsonObject jsonObject) {
627627
: null)
628628
.build();
629629
}
630-
631-
/**
632-
* @see <a href="https://community.spotify.com/t5/Spotify-for-Developers/duration-ms-includes-nonsense-JSON/m-p/5753768">Bug report on Spotify forums</a>
633-
* @deprecated This is a temporary workaround to handle an edge-case involving local files,
634-
* which for some reason have their duration_ms field contain an additional field called totalMilliseconds.
635-
* Once Spotify fixes their API, this workaround should be removed.
636-
*/
637-
@Deprecated
638-
private static int getDurationMsFixed(JsonObject jsonObject) {
639-
JsonElement durationMs = jsonObject.get("duration_ms");
640-
if (durationMs.isJsonPrimitive()) {
641-
return durationMs.getAsInt();
642-
} else {
643-
return durationMs.getAsJsonObject().get("totalMilliseconds").getAsInt();
644-
}
645-
}
646630
}
647631

648632
@Override

src/test/fixtures/requests/data/tracks/GetTrackRequestLocal.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,7 @@
170170
"UY"
171171
],
172172
"disc_number": 1,
173-
"duration_ms": {
174-
"totalMilliseconds": 222200
175-
},
173+
"duration_ms": 222200,
176174
"explicit": false,
177175
"external_ids": {
178176
"isrc": "GBFFP0300052"

0 commit comments

Comments
 (0)