[YouTube] Add custom error for "Sign in to confirm ..."

pull/1352/head
Stypox 2025-07-28 23:13:23 +02:00
rodzic a524390e39
commit b8bd4cda8c
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4BDF1B40A49FDD23
2 zmienionych plików z 20 dodań i 1 usunięć

Wyświetl plik

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

Wyświetl plik

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