Unverified Commit 35325d98 authored by TiA4f8R's avatar TiA4f8R
Browse files

Add GeographicRestrictionException and SoundCloudGoPlusException in NewPipe...

Add GeographicRestrictionException and SoundCloudGoPlusException in NewPipe Extractor to be able to display different error messages

This commit adds two new exceptions in NewPipe Extractor: GeographicRestrictionException and SoundCloudGoPlusException (which extend to ContentNotAvailableException). These exceptions allow showing different error messages to user when a content isn't available in his/her/its country (only used for now by SoundCloudStreamExtractor) or when the content is a SoundCloud Go+ track.
parent cb07ffa1
package org.schabi.newpipe.extractor.exceptions;
public class GeographicRestrictionException extends ContentNotAvailableException {
public GeographicRestrictionException(String message) {
public GeographicRestrictionException(String message, Throwable cause) {
super(message, cause);
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
......@@ -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);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment