Skip to content

Commit e9156ee

Browse files
committed
Fix parsing of SoundCloud stream info items
1 parent 0c632e1 commit e9156ee

2 files changed

Lines changed: 8 additions & 7 deletions

File tree

src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudParsingHelper.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ public static String clientId() throws ReCaptchaException, IOException, RegexExc
4242
Element jsElement = doc.select("script[src^=https://a-v2.sndcdn.com/assets/app]").first();
4343
String js = dl.download(jsElement.attr("src"));
4444

45-
clientId = Parser.matchGroup1(",client_id:\"(.*?)\"", js);
46-
return clientId;
45+
return clientId = Parser.matchGroup1(",client_id:\"(.*?)\"", js);
4746
}
4847

4948
public static String toDateString(String time) throws ParsingException {
@@ -138,7 +137,10 @@ public static String getStreamsFromApi(StreamInfoItemCollector collector, String
138137

139138
JsonArray responseCollection = responseObject.getArray("collection");
140139
for (Object o : responseCollection) {
141-
if (o instanceof JsonObject) collector.commit(new SoundcloudStreamInfoItemExtractor((JsonObject) o));
140+
if (o instanceof JsonObject) {
141+
JsonObject object = (JsonObject) o;
142+
collector.commit(new SoundcloudStreamInfoItemExtractor(charts ? object.getObject("track") : object));
143+
}
142144
}
143145

144146
String nextStreamsUrl;

src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamInfoItemExtractor.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
public class SoundcloudStreamInfoItemExtractor implements StreamInfoItemExtractor {
99

10-
private final JsonObject searchResult;
10+
protected final JsonObject searchResult;
1111

1212
public SoundcloudStreamInfoItemExtractor(JsonObject searchResult) {
1313
this.searchResult = searchResult;
@@ -30,13 +30,12 @@ public long getDuration() {
3030

3131
@Override
3232
public String getUploaderName() {
33-
//return searchResult.getObject("user").getString("username");
34-
return searchResult.getObject("track").getObject("user").getString("username");
33+
return searchResult.getObject("user").getString("username");
3534
}
3635

3736
@Override
3837
public String getUploadDate() throws ParsingException {
39-
return SoundcloudParsingHelper.toDateString(searchResult.getObject("track").getString("created_at"));
38+
return SoundcloudParsingHelper.toDateString(searchResult.getString("created_at"));
4039
}
4140

4241
@Override

0 commit comments

Comments
 (0)