3131import static org .schabi .newpipe .extractor .utils .Utils .replaceHttpWithHttps ;
3232
3333public class SoundcloudParsingHelper {
34+ private static final String HARDCODED_CLIENT_ID = "LHzSAKe8eP9Yy3FgBugfBapRPLncO6Ng" ; // Updated on 22/10/19
3435 private static String clientId ;
3536
3637 private SoundcloudParsingHelper () {
@@ -40,11 +41,8 @@ public static String clientId() throws ExtractionException, IOException {
4041 if (clientId != null && !clientId .isEmpty ()) return clientId ;
4142
4243 Downloader dl = NewPipe .getDownloader ();
43- clientId = "LHzSAKe8eP9Yy3FgBugfBapRPLncO6Ng" ; // Updated on 22/10/19
44- final String apiUrl = "https://api.soundcloud.com/connect?client_id=" + clientId ;
45- // Should return 200 to indicate that the client id is valid, a 401 is returned otherwise.
46- // In that case, the fallback method is used.
47- if (dl .head (apiUrl ).getResponseCode () == 200 ) {
44+ clientId = HARDCODED_CLIENT_ID ;
45+ if (checkIfHardcodedClientIdIsValid (dl )) {
4846 return clientId ;
4947 }
5048
@@ -75,6 +73,12 @@ public static String clientId() throws ExtractionException, IOException {
7573 throw new ExtractionException ("Couldn't extract client id" );
7674 }
7775
76+ static boolean checkIfHardcodedClientIdIsValid (Downloader dl ) throws IOException , ReCaptchaException {
77+ final String apiUrl = "https://api.soundcloud.com/connect?client_id=" + HARDCODED_CLIENT_ID ;
78+ // Should return 200 to indicate that the client id is valid, a 401 is returned otherwise.
79+ return dl .head (apiUrl ).getResponseCode () == 200 ;
80+ }
81+
7882 public static String toDateString (String time ) throws ParsingException {
7983 try {
8084 Date date ;
0 commit comments