Skip to content

Commit b71f343

Browse files
committed
Add custom error for "Sign in to confirm ..."
1 parent 260ba47 commit b71f343

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package org.schabi.newpipe.extractor.exceptions;
2+
3+
public class YoutubeSignInConfirmNotBotException extends ParsingException {
4+
public YoutubeSignInConfirmNotBotException(final String message) {
5+
super(message);
6+
}
7+
}

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
import org.schabi.newpipe.extractor.exceptions.ParsingException;
5454
import org.schabi.newpipe.extractor.exceptions.PrivateContentException;
5555
import org.schabi.newpipe.extractor.exceptions.YoutubeMusicPremiumContentException;
56+
import org.schabi.newpipe.extractor.exceptions.YoutubeSignInConfirmNotBotException;
5657
import org.schabi.newpipe.extractor.linkhandler.LinkHandler;
5758
import org.schabi.newpipe.extractor.localization.ContentCountry;
5859
import org.schabi.newpipe.extractor.localization.DateWrapper;
@@ -901,7 +902,13 @@ private static void checkPlayabilityStatus(@Nonnull final JsonObject playability
901902
}
902903
}
903904

904-
throw new ContentNotAvailableException("Got error: \"" + reason + "\"");
905+
// "Sign in to confirm that you're not a bot", "Watch on the latest version"
906+
if (reason != null && (reason.contains("a bot") || reason.contains("latest"))) {
907+
throw new YoutubeSignInConfirmNotBotException(
908+
"YouTube probably temporarily blocked this IP, got error: " + reason);
909+
}
910+
911+
throw new ContentNotAvailableException("Got error " + status + ": \"" + reason + "\"");
905912
}
906913

907914
private void fetchHtml5Client(@Nonnull final Localization localization,

0 commit comments

Comments
 (0)