Skip to content

Commit 6446abc

Browse files
authored
Merge pull request #271 from mauriciocolli/improve-status-checking
[YouTube] Improve response status checks
2 parents 65f0ec6 + 6aa4d59 commit 6446abc

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,8 @@ public void onFetchPage(@Nonnull Downloader downloader) throws IOException, Extr
623623

624624
final JsonObject playabilityStatus = playerResponse.getObject("playabilityStatus", JsonUtils.DEFAULT_EMPTY);
625625
final String status = playabilityStatus.getString("status");
626-
if (status != null && status.toLowerCase().equals("error")) {
626+
// If status exist, and is not "OK", throw a ContentNotAvailableException with the reason.
627+
if (status != null && !status.toLowerCase().equals("ok")) {
627628
final String reason = playabilityStatus.getString("reason");
628629
throw new ContentNotAvailableException("Got error: \"" + reason + "\"");
629630
}

extractor/src/test/java/org/schabi/newpipe/extractor/services/peertube/PeertubeStreamExtractorDefaultTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ public void testGetSubtitlesList() throws IOException, ExtractionException {
145145
@Test
146146
public void testGetAgeLimit() throws ExtractionException, IOException {
147147
assertEquals(0, extractor.getAgeLimit());
148-
PeertubeStreamExtractor ageLimit = (PeertubeStreamExtractor) PeerTube.getStreamExtractor("https://peertube.co.uk/videos/watch/6762bb04-cad5-407b-81ee-c18eac4715a7");
148+
PeertubeStreamExtractor ageLimit = (PeertubeStreamExtractor) PeerTube.getStreamExtractor("https://peertube.co.uk/videos/watch/3c0da7fb-e4d9-442e-84e3-a8c47004ee28");
149149
ageLimit.fetchPage();
150150
assertEquals(18, ageLimit.getAgeLimit());
151151
}

0 commit comments

Comments
 (0)