2
0
mirror of https://github.com/TeamNewPipe/NewPipeExtractor synced 2025-08-22 01:48:58 +00:00

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.
This commit is contained in:
AudricV 2025-07-28 22:18:52 +02:00
parent 25e30b745a
commit 2cccf48d6c
No known key found for this signature in database
GPG Key ID: DA92EC7905614198
2 changed files with 22 additions and 2 deletions

View File

@ -0,0 +1,20 @@
package org.schabi.newpipe.extractor.exceptions;
/**
* Exception for contents not supported in a country.
*
* <p>
* Unsupported content means content is not intentionally geographically restricted such as for
* distribution rights, for which {@link GeographicRestrictionException} should be used instead.
* </p>
*/
public class UnsupportedContentInCountryException extends ContentNotAvailableException {
public UnsupportedContentInCountryException(final String message) {
super(message);
}
public UnsupportedContentInCountryException(final String message, final Throwable cause) {
super(message, cause);
}
}

View File

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