Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
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;
Expand Down Expand Up @@ -901,7 +902,14 @@ private static void checkPlayabilityStatus(@Nonnull final JsonObject playability
}
}

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 + "\"");
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking, should this really be a ContentNotAvailableException? I think ContentNotAvailableException should be reserved for when the extractor notices that the service explicitly reports a resource as not being available (e.g. age restricted, channel deleted, and so on). It should not be used for unknown errors in fetching resources, which is the case here. I would turn this into just ParsingException, add a clarifying comment to ContentNotAvailableException, and check all other places where ContentNotAvailableException is thrown. What's your opinion @AudricV?

Note: currently in some parts of NewPipe we assume that ContentNotAvailableExceptions are not supposed to be reported.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless we start detecting all real unavailability errors (deleted video, unavailable/removed due to closed/removed YouTube account, ...), I don't think so.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now we are unsure what the issue is here: it might be that the video is actually unavailable, but it might also be that YouTube refused to provide data for other reasons. So reporting that the content is unavailable is incorrect, we should instead report that the extractor failed to extract the data. Even if the video was actually unavailable and the extractor was unable to notice that, then it's the extractor's fault so ParsingException fits.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what I was going after. But for this classification to really work well, we need the two exception types to be distinct.

Image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds like a good idea.

}

private void fetchHtml5Client(@Nonnull final Localization localization,
Expand Down