From 2cccf48d6c81930ad09d7d12eb3c974c0245d60a Mon Sep 17 00:00:00 2001 From: AudricV <74829229+AudricV@users.noreply.github.com> Date: Mon, 28 Jul 2025 22:18:52 +0200 Subject: [PATCH] Add an UnsupportedContentInCountryException and use it in YouTube Charts This allows client to distinguish of a generic ContentNotSupportedException, which hasn't fully its place for its usage in YouTube Charts. --- .../UnsupportedContentInCountryException.java | 20 +++++++++++++++++++ .../kiosk/YoutubeTrendingMusicExtractor.java | 4 ++-- 2 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 extractor/src/main/java/org/schabi/newpipe/extractor/exceptions/UnsupportedContentInCountryException.java diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/exceptions/UnsupportedContentInCountryException.java b/extractor/src/main/java/org/schabi/newpipe/extractor/exceptions/UnsupportedContentInCountryException.java new file mode 100644 index 000000000..92d20c02e --- /dev/null +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/exceptions/UnsupportedContentInCountryException.java @@ -0,0 +1,20 @@ +package org.schabi.newpipe.extractor.exceptions; + +/** + * Exception for contents not supported in a country. + * + *
+ * Unsupported content means content is not intentionally geographically restricted such as for + * distribution rights, for which {@link GeographicRestrictionException} should be used instead. + *
+ */ +public class UnsupportedContentInCountryException extends ContentNotAvailableException { + + public UnsupportedContentInCountryException(final String message) { + super(message); + } + + public UnsupportedContentInCountryException(final String message, final Throwable cause) { + super(message, cause); + } +} diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/kiosk/YoutubeTrendingMusicExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/kiosk/YoutubeTrendingMusicExtractor.java index b545ec1e6..53ed963f4 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/kiosk/YoutubeTrendingMusicExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/kiosk/YoutubeTrendingMusicExtractor.java @@ -2,9 +2,9 @@ package org.schabi.newpipe.extractor.services.youtube.extractors.kiosk; import org.schabi.newpipe.extractor.StreamingService; import org.schabi.newpipe.extractor.downloader.Downloader; -import org.schabi.newpipe.extractor.exceptions.ContentNotSupportedException; import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.exceptions.ParsingException; +import org.schabi.newpipe.extractor.exceptions.UnsupportedContentInCountryException; import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler; import javax.annotation.Nonnull; @@ -23,7 +23,7 @@ public class YoutubeTrendingMusicExtractor extends YoutubeChartsBaseKioskExtract throws IOException, ExtractionException { if (!YT_CHARTS_SUPPORTED_COUNTRY_CODES.contains( getExtractorContentCountry().getCountryCode())) { - throw new ContentNotSupportedException( + throw new UnsupportedContentInCountryException( "YouTube Charts doesn't support this country for trending music videos charts"); } super.onFetchPage(downloader);