From 222d659d9e6ebebed5ea9a690518b1a7c1ac0c2d Mon Sep 17 00:00:00 2001 From: wb9688 Date: Wed, 18 Mar 2020 11:01:46 +0100 Subject: [PATCH] [SoundCloud] Don't make separate request for getAudioStreams() in StreamExtractor Signed-off-by: Stypox --- .../soundcloud/SoundcloudStreamExtractor.java | 24 ++++++++----------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamExtractor.java index 5c176720c..16eaad012 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamExtractor.java @@ -14,7 +14,14 @@ import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.linkhandler.LinkHandler; import org.schabi.newpipe.extractor.localization.DateWrapper; -import org.schabi.newpipe.extractor.stream.*; +import org.schabi.newpipe.extractor.stream.AudioStream; +import org.schabi.newpipe.extractor.stream.Description; +import org.schabi.newpipe.extractor.stream.StreamExtractor; +import org.schabi.newpipe.extractor.stream.StreamInfoItem; +import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector; +import org.schabi.newpipe.extractor.stream.StreamType; +import org.schabi.newpipe.extractor.stream.SubtitlesStream; +import org.schabi.newpipe.extractor.stream.VideoStream; import java.io.IOException; import java.io.UnsupportedEncodingException; @@ -148,24 +155,13 @@ public class SoundcloudStreamExtractor extends StreamExtractor { List audioStreams = new ArrayList<>(); Downloader dl = NewPipe.getDownloader(); - String apiUrl = "https://api-v2.soundcloud.com/tracks/" + urlEncode(getId()) - + "?client_id=" + urlEncode(SoundcloudParsingHelper.clientId()); - - String response = dl.get(apiUrl, getExtractorLocalization()).responseBody(); - JsonObject responseObject; - try { - responseObject = JsonParser.object().from(response); - } catch (JsonParserException e) { - throw new ParsingException("Could not parse json response", e); - } - // Streams can be streamable and downloadable - or explicitly not. // For playing the track, it is only necessary to have a streamable track. // If this is not the case, this track might not be published yet. - if (!responseObject.getBoolean("streamable")) return audioStreams; + if (!track.getBoolean("streamable")) return audioStreams; try { - JsonArray transcodings = responseObject.getObject("media").getArray("transcodings"); + JsonArray transcodings = track.getObject("media").getArray("transcodings"); // get information about what stream formats are available for (Object transcoding : transcodings) {