Skip to content

Commit 2cccf48

Browse files
committed
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.
1 parent 25e30b7 commit 2cccf48

2 files changed

Lines changed: 22 additions & 2 deletions

File tree

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package org.schabi.newpipe.extractor.exceptions;
2+
3+
/**
4+
* Exception for contents not supported in a country.
5+
*
6+
* <p>
7+
* Unsupported content means content is not intentionally geographically restricted such as for
8+
* distribution rights, for which {@link GeographicRestrictionException} should be used instead.
9+
* </p>
10+
*/
11+
public class UnsupportedContentInCountryException extends ContentNotAvailableException {
12+
13+
public UnsupportedContentInCountryException(final String message) {
14+
super(message);
15+
}
16+
17+
public UnsupportedContentInCountryException(final String message, final Throwable cause) {
18+
super(message, cause);
19+
}
20+
}

extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/kiosk/YoutubeTrendingMusicExtractor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
import org.schabi.newpipe.extractor.StreamingService;
44
import org.schabi.newpipe.extractor.downloader.Downloader;
5-
import org.schabi.newpipe.extractor.exceptions.ContentNotSupportedException;
65
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
76
import org.schabi.newpipe.extractor.exceptions.ParsingException;
7+
import org.schabi.newpipe.extractor.exceptions.UnsupportedContentInCountryException;
88
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;
99

1010
import javax.annotation.Nonnull;
@@ -23,7 +23,7 @@ public void onFetchPage(@Nonnull final Downloader downloader)
2323
throws IOException, ExtractionException {
2424
if (!YT_CHARTS_SUPPORTED_COUNTRY_CODES.contains(
2525
getExtractorContentCountry().getCountryCode())) {
26-
throw new ContentNotSupportedException(
26+
throw new UnsupportedContentInCountryException(
2727
"YouTube Charts doesn't support this country for trending music videos charts");
2828
}
2929
super.onFetchPage(downloader);

0 commit comments

Comments
 (0)