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.
This commit is contained in:
Adam Fontenot 2024-10-15 13:07:26 -04:00
parent c343e31ed2
commit 1b3263c550
No known key found for this signature in database
GPG Key ID: 7C7E7684F08ABF6B

View File

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