diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/exceptions/SignInConfirmNotBotException.java b/extractor/src/main/java/org/schabi/newpipe/extractor/exceptions/SignInConfirmNotBotException.java new file mode 100644 index 000000000..29e4c8be0 --- /dev/null +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/exceptions/SignInConfirmNotBotException.java @@ -0,0 +1,11 @@ +package org.schabi.newpipe.extractor.exceptions; + +/** + * Content can't be extracted because the service requires logging in to confirm the user is not a + * bot. Can usually only be solvable by changing IP (e.g. in the case of YouTube). + */ +public class SignInConfirmNotBotException extends ParsingException { + public SignInConfirmNotBotException(final String message) { + super(message); + } +} diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java index b2b3dc270..eb050fd13 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java @@ -53,6 +53,7 @@ import org.schabi.newpipe.extractor.exceptions.PaidContentException; import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.exceptions.PrivateContentException; import org.schabi.newpipe.extractor.exceptions.YoutubeMusicPremiumContentException; +import org.schabi.newpipe.extractor.exceptions.SignInConfirmNotBotException; import org.schabi.newpipe.extractor.linkhandler.LinkHandler; import org.schabi.newpipe.extractor.localization.ContentCountry; import org.schabi.newpipe.extractor.localization.DateWrapper; @@ -901,7 +902,14 @@ public class YoutubeStreamExtractor extends StreamExtractor { } } - throw new ContentNotAvailableException("Got error: \"" + reason + "\""); + // "Sign in to confirm that you're not a bot" + if (reason != null && reason.contains("a bot")) { + throw new SignInConfirmNotBotException( + "YouTube probably temporarily blocked this IP, got error " + + status + ": \"" + reason + "\""); + } + + throw new ContentNotAvailableException("Got error " + status + ": \"" + reason + "\""); } private void fetchHtml5Client(@Nonnull final Localization localization,