Test if the extractor can get AudiStreams with the hard-coded cliend_id
SoundCloud client_id are changed on a regular basis now. We might want to remove the hardcoded id completely on a later point of time when client_id is changed to often
This commit is contained in:
parent
dc20f2aa0c
commit
efad0be99f
|
@ -42,7 +42,7 @@ public class SoundcloudParsingHelper {
|
||||||
|
|
||||||
Downloader dl = NewPipe.getDownloader();
|
Downloader dl = NewPipe.getDownloader();
|
||||||
clientId = HARDCODED_CLIENT_ID;
|
clientId = HARDCODED_CLIENT_ID;
|
||||||
if (checkIfHardcodedClientIdIsValid(dl)) {
|
if (checkIfHardcodedClientIdIsValid()) {
|
||||||
return clientId;
|
return clientId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,11 +73,11 @@ public class SoundcloudParsingHelper {
|
||||||
throw new ExtractionException("Couldn't extract client id");
|
throw new ExtractionException("Couldn't extract client id");
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean checkIfHardcodedClientIdIsValid(Downloader dl) {
|
static boolean checkIfHardcodedClientIdIsValid() {
|
||||||
final String apiUrl = "https://api.soundcloud.com/connect?client_id=" + HARDCODED_CLIENT_ID;
|
|
||||||
try {
|
try {
|
||||||
// Should return 200 to indicate that the client id is valid, a 401 is returned otherwise.
|
SoundcloudStreamExtractor e = (SoundcloudStreamExtractor) SoundCloud
|
||||||
return dl.head(apiUrl).responseCode() == 200;
|
.getStreamExtractor("https://soundcloud.com/liluzivert/do-what-i-want-produced-by-maaly-raw-don-cannon");
|
||||||
|
return e.getAudioStreams().size() >= 1;
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
// No need to throw an exception here. If something went wrong, the client_id is wrong
|
// No need to throw an exception here. If something went wrong, the client_id is wrong
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -17,7 +17,7 @@ public class SoundcloudParsingHelperTest {
|
||||||
@Test
|
@Test
|
||||||
public void assertThatHardcodedClientIdIsValid() throws Exception {
|
public void assertThatHardcodedClientIdIsValid() throws Exception {
|
||||||
assertTrue("Hardcoded client id is not valid anymore",
|
assertTrue("Hardcoded client id is not valid anymore",
|
||||||
SoundcloudParsingHelper.checkIfHardcodedClientIdIsValid(DownloaderTestImpl.getInstance()));
|
SoundcloudParsingHelper.checkIfHardcodedClientIdIsValid());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue