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 00000000..23ba31aa --- /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 00000000..e3643dfb --- /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 fc246dfb..ea1b8f30 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 @@ -12,7 +12,9 @@ import org.schabi.newpipe.extractor.downloader.Downloader; 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; @@ -43,6 +45,12 @@ public class SoundcloudStreamExtractor extends StreamExtractor { 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); } }