Skip to content

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

Merged
TobiGr merged 1 commit intoTeamNewPipe:devfrom
Stypox:yt-confirm-not-bot
Aug 28, 2025
Merged

[YouTube] Add custom error for "Sign in to confirm ..."#1352
TobiGr merged 1 commit intoTeamNewPipe:devfrom
Stypox:yt-confirm-not-bot

Conversation

@Stypox
Copy link
Member

@Stypox Stypox commented Jul 28, 2025

  • I carefully read the contribution guidelines and agree to them.
  • I have tested the API against NewPipe.
  • I agree to create a pull request for NewPipe as soon as possible to make it compatible with the changed API.

This PR adds a custom exception when "Sign in to confirm that you're not a bot" is detected from YouTube, so we can show a custom message in NewPipe. I could not test whether the detection works because I am not experiencing temporary bans from YouTube at the moment, but I based my checks on TeamNewPipe/NewPipe#11139 .

@Stypox
Copy link
Member Author

Stypox commented Aug 28, 2025

Many users reported that the detection works fine, e.g. see TeamNewPipe/NewPipe#12533

@Stypox Stypox force-pushed the yt-confirm-not-bot branch from 3d673ee to 3e57052 Compare August 28, 2025 14:53
@Stypox
Copy link
Member Author

Stypox commented Aug 28, 2025

I removed detection for "Watch on the latest version" because that's an extractor bug (i.e. the request is invalid, just like other parsing exceptions) and the user can't do anything about it

@Stypox Stypox force-pushed the yt-confirm-not-bot branch from 3e57052 to b8bd4cd Compare August 28, 2025 14:56
@TobiGr TobiGr merged commit 0023b22 into TeamNewPipe:dev Aug 28, 2025
4 checks passed
+ 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request youtube service, https://www.youtube.com/

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants