This commit is contained in:
wb9688 2017-08-06 09:24:07 +00:00 committed by GitHub
commit e54bcf1064
1 changed files with 11 additions and 8 deletions

View File

@ -22,16 +22,20 @@ public class SoundcloudParsingHelper {
private SoundcloudParsingHelper() { private SoundcloudParsingHelper() {
} }
public static final String clientId() throws ReCaptchaException, IOException, RegexException { private static String clientId;
Downloader dl = NewPipe.getDownloader();
String response = dl.download("https://soundcloud.com"); public static String clientId() throws ReCaptchaException, IOException, RegexException {
Document doc = Jsoup.parse(response); if (clientId.isEmpty()) {
Downloader dl = NewPipe.getDownloader();
Element jsElement = doc.select("script[src^=https://a-v2.sndcdn.com/assets/app]").first(); String response = dl.download("https://soundcloud.com");
String js = dl.download(jsElement.attr("src")); Document doc = Jsoup.parse(response);
String clientId = Parser.matchGroup1(",client_id:\"(.*?)\"", js); 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;
} }
@ -76,5 +80,4 @@ public class SoundcloudParsingHelper {
throw new ParsingException(e.getMessage(), e); throw new ParsingException(e.getMessage(), e);
} }
} }
} }