Merge pull request #271 from mauriciocolli/improve-status-checking
[YouTube] Improve response status checks
This commit is contained in:
commit
6446abc6d1
|
@ -623,7 +623,8 @@ public class YoutubeStreamExtractor extends StreamExtractor {
|
|||
|
||||
final JsonObject playabilityStatus = playerResponse.getObject("playabilityStatus", JsonUtils.DEFAULT_EMPTY);
|
||||
final String status = playabilityStatus.getString("status");
|
||||
if (status != null && status.toLowerCase().equals("error")) {
|
||||
// If status exist, and is not "OK", throw a ContentNotAvailableException with the reason.
|
||||
if (status != null && !status.toLowerCase().equals("ok")) {
|
||||
final String reason = playabilityStatus.getString("reason");
|
||||
throw new ContentNotAvailableException("Got error: \"" + reason + "\"");
|
||||
}
|
||||
|
|
|
@ -145,7 +145,7 @@ public class PeertubeStreamExtractorDefaultTest {
|
|||
@Test
|
||||
public void testGetAgeLimit() throws ExtractionException, IOException {
|
||||
assertEquals(0, extractor.getAgeLimit());
|
||||
PeertubeStreamExtractor ageLimit = (PeertubeStreamExtractor) PeerTube.getStreamExtractor("https://peertube.co.uk/videos/watch/6762bb04-cad5-407b-81ee-c18eac4715a7");
|
||||
PeertubeStreamExtractor ageLimit = (PeertubeStreamExtractor) PeerTube.getStreamExtractor("https://peertube.co.uk/videos/watch/3c0da7fb-e4d9-442e-84e3-a8c47004ee28");
|
||||
ageLimit.fetchPage();
|
||||
assertEquals(18, ageLimit.getAgeLimit());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue