File tree Expand file tree Collapse file tree
extractor/src/main/java/org/schabi/newpipe/extractor
services/youtube/extractors Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package org .schabi .newpipe .extractor .exceptions ;
2+
3+ /**
4+ * Content can't be extracted because the service requires logging in to confirm the user is not a
5+ * bot. Can usually only be solvable by changing IP (e.g. in the case of YouTube).
6+ */
7+ public class SignInConfirmNotBotException extends ParsingException {
8+ public SignInConfirmNotBotException (final String message ) {
9+ super (message );
10+ }
11+ }
Original file line number Diff line number Diff line change 5353import org .schabi .newpipe .extractor .exceptions .ParsingException ;
5454import org .schabi .newpipe .extractor .exceptions .PrivateContentException ;
5555import org .schabi .newpipe .extractor .exceptions .YoutubeMusicPremiumContentException ;
56+ import org .schabi .newpipe .extractor .exceptions .SignInConfirmNotBotException ;
5657import org .schabi .newpipe .extractor .linkhandler .LinkHandler ;
5758import org .schabi .newpipe .extractor .localization .ContentCountry ;
5859import org .schabi .newpipe .extractor .localization .DateWrapper ;
@@ -901,7 +902,14 @@ 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"
906+ if (reason != null && reason .contains ("a bot" )) {
907+ throw new SignInConfirmNotBotException (
908+ "YouTube probably temporarily blocked this IP, got error "
909+ + status + ": \" " + reason + "\" " );
910+ }
911+
912+ throw new ContentNotAvailableException ("Got error " + status + ": \" " + reason + "\" " );
905913 }
906914
907915 private void fetchHtml5Client (@ Nonnull final Localization localization ,
You can’t perform that action at this time.
0 commit comments