Fix parsing of SoundCloud stream info items

This commit is contained in:
Mauricio Colli 2017-09-11 13:18:17 -03:00
parent 0c632e195b
commit e9156ee499
2 changed files with 8 additions and 7 deletions

View File

@ -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;

View File

@ -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