diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/exceptions/GeographicRestrictionException.java b/extractor/src/main/java/org/schabi/newpipe/extractor/exceptions/GeographicRestrictionException.java new file mode 100644 index 0000000000..23ba31aa9e --- /dev/null +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/exceptions/GeographicRestrictionException.java @@ -0,0 +1,11 @@ +package org.schabi.newpipe.extractor.exceptions; + +public class GeographicRestrictionException extends ContentNotAvailableException { + public GeographicRestrictionException(String message) { + super(message); + } + + public GeographicRestrictionException(String message, Throwable cause) { + super(message, cause); + } +} diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/exceptions/SoundCloudGoPlusException.java b/extractor/src/main/java/org/schabi/newpipe/extractor/exceptions/SoundCloudGoPlusException.java new file mode 100644 index 0000000000..e3643dfb92 --- /dev/null +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/exceptions/SoundCloudGoPlusException.java @@ -0,0 +1,11 @@ +package org.schabi.newpipe.extractor.exceptions; + +public class SoundCloudGoPlusException extends ContentNotAvailableException { + public SoundCloudGoPlusException() { + super("This track is a SoundCloud Go+ track"); + } + + public SoundCloudGoPlusException(Throwable cause) { + super("This track is a SoundCloud Go+ track", cause); + } +} \ No newline at end of file diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/extractors/SoundcloudStreamExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/extractors/SoundcloudStreamExtractor.java index 62e79cb2d1..2597b3fb58 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/extractors/SoundcloudStreamExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/extractors/SoundcloudStreamExtractor.java @@ -13,7 +13,9 @@ import org.schabi.newpipe.extractor.exceptions.ContentNotAvailableException; import org.schabi.newpipe.extractor.exceptions.ContentNotSupportedException; import org.schabi.newpipe.extractor.exceptions.ExtractionException; +import org.schabi.newpipe.extractor.exceptions.GeographicRestrictionException; import org.schabi.newpipe.extractor.exceptions.ParsingException; +import org.schabi.newpipe.extractor.exceptions.SoundCloudGoPlusException; import org.schabi.newpipe.extractor.linkhandler.LinkHandler; import org.schabi.newpipe.extractor.localization.DateWrapper; import org.schabi.newpipe.extractor.services.soundcloud.SoundcloudParsingHelper; @@ -53,6 +55,12 @@ public void onFetchPage(@Nonnull Downloader downloader) throws IOException, Extr String policy = track.getString("policy", EMPTY_STRING); if (!policy.equals("ALLOW") && !policy.equals("MONETIZE")) { + if (policy.equals("SNIP")) { + throw new SoundCloudGoPlusException(); + } + if (policy.equals("BLOCK")) { + throw new GeographicRestrictionException("This track is not available in user's country"); + } throw new ContentNotAvailableException("Content not available: policy " + policy); } }