Commit e9156ee4 authored by Mauricio Colli's avatar Mauricio Colli
Browse files

Fix parsing of SoundCloud stream info items

parent 0c632e19
......@@ -42,8 +42,7 @@ public class SoundcloudParsingHelper {
Element jsElement = doc.select("script[src^=https://a-v2.sndcdn.com/assets/app]").first();
String js = dl.download(jsElement.attr("src"));
clientId = Parser.matchGroup1(",client_id:\"(.*?)\"", js);
return clientId;
return clientId = Parser.matchGroup1(",client_id:\"(.*?)\"", js);
}
public static String toDateString(String time) throws ParsingException {
......@@ -138,7 +137,10 @@ public class SoundcloudParsingHelper {
JsonArray responseCollection = responseObject.getArray("collection");
for (Object o : responseCollection) {
if (o instanceof JsonObject) collector.commit(new SoundcloudStreamInfoItemExtractor((JsonObject) o));
if (o instanceof JsonObject) {
JsonObject object = (JsonObject) o;
collector.commit(new SoundcloudStreamInfoItemExtractor(charts ? object.getObject("track") : object));
}
}
String nextStreamsUrl;
......
......@@ -7,7 +7,7 @@ import org.schabi.newpipe.extractor.stream.StreamType;
public class SoundcloudStreamInfoItemExtractor implements StreamInfoItemExtractor {
private final JsonObject searchResult;
protected final JsonObject searchResult;
public SoundcloudStreamInfoItemExtractor(JsonObject searchResult) {
this.searchResult = searchResult;
......@@ -30,13 +30,12 @@ public class SoundcloudStreamInfoItemExtractor implements StreamInfoItemExtracto
@Override
public String getUploaderName() {
//return searchResult.getObject("user").getString("username");
return searchResult.getObject("track").getObject("user").getString("username");
return searchResult.getObject("user").getString("username");
}
@Override
public String getUploadDate() throws ParsingException {
return SoundcloudParsingHelper.toDateString(searchResult.getObject("track").getString("created_at"));
return SoundcloudParsingHelper.toDateString(searchResult.getString("created_at"));
}
@Override
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment