Handle content not available exception more comprehensively
This commit is contained in:
parent
d051df9599
commit
b4cabe23e3
3 changed files with 16 additions and 25 deletions
|
@ -17,6 +17,7 @@ import org.schabi.newpipe.BaseFragment;
|
||||||
import org.schabi.newpipe.MainActivity;
|
import org.schabi.newpipe.MainActivity;
|
||||||
import org.schabi.newpipe.R;
|
import org.schabi.newpipe.R;
|
||||||
import org.schabi.newpipe.ReCaptchaActivity;
|
import org.schabi.newpipe.ReCaptchaActivity;
|
||||||
|
import org.schabi.newpipe.extractor.exceptions.ContentNotAvailableException;
|
||||||
import org.schabi.newpipe.extractor.exceptions.ReCaptchaException;
|
import org.schabi.newpipe.extractor.exceptions.ReCaptchaException;
|
||||||
import org.schabi.newpipe.report.ErrorActivity;
|
import org.schabi.newpipe.report.ErrorActivity;
|
||||||
import org.schabi.newpipe.report.UserAction;
|
import org.schabi.newpipe.report.UserAction;
|
||||||
|
@ -181,6 +182,9 @@ public abstract class BaseStateFragment<I> extends BaseFragment implements ViewC
|
||||||
if (exception instanceof ReCaptchaException) {
|
if (exception instanceof ReCaptchaException) {
|
||||||
onReCaptchaException((ReCaptchaException) exception);
|
onReCaptchaException((ReCaptchaException) exception);
|
||||||
return true;
|
return true;
|
||||||
|
} else if (exception instanceof ContentNotAvailableException) {
|
||||||
|
showError(getString(R.string.content_not_available), false);
|
||||||
|
return true;
|
||||||
} else if (exception instanceof IOException) {
|
} else if (exception instanceof IOException) {
|
||||||
showError(getString(R.string.network_error), true);
|
showError(getString(R.string.network_error), true);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -51,7 +51,6 @@ import org.schabi.newpipe.download.DownloadDialog;
|
||||||
import org.schabi.newpipe.extractor.InfoItem;
|
import org.schabi.newpipe.extractor.InfoItem;
|
||||||
import org.schabi.newpipe.extractor.NewPipe;
|
import org.schabi.newpipe.extractor.NewPipe;
|
||||||
import org.schabi.newpipe.extractor.ServiceList;
|
import org.schabi.newpipe.extractor.ServiceList;
|
||||||
import org.schabi.newpipe.extractor.exceptions.ContentNotAvailableException;
|
|
||||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||||
import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeStreamExtractor;
|
import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeStreamExtractor;
|
||||||
|
@ -1220,20 +1219,12 @@ public class VideoDetailFragment
|
||||||
protected boolean onError(Throwable exception) {
|
protected boolean onError(Throwable exception) {
|
||||||
if (super.onError(exception)) return true;
|
if (super.onError(exception)) return true;
|
||||||
|
|
||||||
else if (exception instanceof ContentNotAvailableException) {
|
int errorId = exception instanceof YoutubeStreamExtractor.DecryptException ? R.string.youtube_signature_decryption_error
|
||||||
showError(getString(R.string.content_not_available), false);
|
: exception instanceof ExtractionException ? R.string.parsing_error
|
||||||
} else {
|
|
||||||
int errorId = exception instanceof YoutubeStreamExtractor.DecryptException
|
|
||||||
? R.string.youtube_signature_decryption_error
|
|
||||||
: exception instanceof ParsingException
|
|
||||||
? R.string.parsing_error
|
|
||||||
: R.string.general_error;
|
: R.string.general_error;
|
||||||
onUnrecoverableError(exception,
|
|
||||||
UserAction.REQUESTED_STREAM,
|
onUnrecoverableError(exception, UserAction.REQUESTED_STREAM,
|
||||||
NewPipe.getNameOfService(serviceId),
|
NewPipe.getNameOfService(serviceId), url, errorId);
|
||||||
url,
|
|
||||||
errorId);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -440,16 +440,12 @@ public class ChannelFragment extends BaseListInfoFragment<ChannelInfo> {
|
||||||
protected boolean onError(Throwable exception) {
|
protected boolean onError(Throwable exception) {
|
||||||
if (super.onError(exception)) return true;
|
if (super.onError(exception)) return true;
|
||||||
|
|
||||||
if (exception instanceof ContentNotAvailableException) {
|
int errorId = exception instanceof ExtractionException
|
||||||
showError(getString(R.string.content_not_available), false);
|
? R.string.parsing_error : R.string.general_error;
|
||||||
} else {
|
|
||||||
int errorId = exception instanceof ExtractionException ? R.string.parsing_error : R.string.general_error;
|
onUnrecoverableError(exception, UserAction.REQUESTED_CHANNEL,
|
||||||
onUnrecoverableError(exception,
|
NewPipe.getNameOfService(serviceId), url, errorId);
|
||||||
UserAction.REQUESTED_CHANNEL,
|
|
||||||
NewPipe.getNameOfService(serviceId),
|
|
||||||
url,
|
|
||||||
errorId);
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue