2
0
mirror of https://github.com/TeamNewPipe/NewPipeExtractor synced 2025-08-30 13:57:46 +00:00

Merge pull request #1352 from Stypox/yt-confirm-not-bot

[YouTube] Add custom error for "Sign in to confirm ..."
This commit is contained in:
Tobi 2025-08-28 10:20:25 -07:00 committed by GitHub
commit 0023b22095
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 20 additions and 1 deletions

View File

@ -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);
}
}

View File

@ -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,