From 1b3263c550e4aa4a0e8dfa5ac023884f47004c66 Mon Sep 17 00:00:00 2001 From: Adam Fontenot Date: Tue, 15 Oct 2024 13:07:26 -0400 Subject: [PATCH] Catch RegexException in subscriber count extractor When the subscriber count extraction fails to find the Regex pattern, a RegexException is thrown. This is not a fatal error in most cases, for example when downloading the channel page in order to update the user's subscriptions, and so the correct behavior is to return UNKNOWN_SUBSCRIBER_COUNT. Related issue: https://github.com/TeamNewPipe/NewPipe/issues/11353. This bug comprises two issues: subscribers cannot be extracted for channels with pronoun tags, and when the RegexException is thrown, channel subscriptions will fail to update because the exception is uncaught. This commit fixes the latter aspect of the issue. --- .../services/youtube/extractors/YoutubeChannelExtractor.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeChannelExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeChannelExtractor.java index adc4d948f..0fab9aa6b 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeChannelExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeChannelExtractor.java @@ -43,6 +43,7 @@ import org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper; import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeChannelTabExtractor.VideosTabExtractor; import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeChannelLinkHandlerFactory; import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeChannelTabLinkHandlerFactory; +import org.schabi.newpipe.extractor.utils.Parser; import org.schabi.newpipe.extractor.utils.Utils; import java.io.IOException; @@ -304,6 +305,8 @@ public class YoutubeChannelExtractor extends ChannelExtractor { .getString(CONTENT)); } catch (final NumberFormatException e) { throw new ParsingException("Could not get subscriber count", e); + } catch (final Parser.RegexException e) { + return UNKNOWN_SUBSCRIBER_COUNT; } }