Skip to content

Commit

Permalink
Add GeographicRestrictionException and SoundCloudGoPlusException to N…
Browse files Browse the repository at this point in the history
…ewPipe

This commit adds these two new exceptions to the BaseStateFragment and to the ExtractorFragment. It also adds two new strings corresponding to these exceptions, in English and French.
  • Loading branch information
AudricV committed Jan 21, 2021
1 parent cce896e commit 3a663dd
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ dependencies {

// NewPipe dependencies
// You can use a local version by uncommenting a few lines in settings.gradle
implementation 'com.github.TeamNewPipe:NewPipeExtractor:beb705013c4dbe2c1a893fa338140e7a5176a0d5'
implementation 'com.github.TiA4f8R:NewPipeExtractor:67422957753c39658f4bdc071b73fdf89c4b5e40'
implementation "com.github.TeamNewPipe:nanojson:1d9e1aea9049fc9f85e68b43ba39fe7be1c1f751"

implementation "org.jsoup:jsoup:1.13.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
import org.schabi.newpipe.ReCaptchaActivity;
import org.schabi.newpipe.extractor.exceptions.ContentNotAvailableException;
import org.schabi.newpipe.extractor.exceptions.ContentNotSupportedException;
import org.schabi.newpipe.extractor.exceptions.GeographicRestrictionException;
import org.schabi.newpipe.extractor.exceptions.ReCaptchaException;
import org.schabi.newpipe.extractor.exceptions.SoundCloudGoPlusException;
import org.schabi.newpipe.ktx.ExceptionUtils;
import org.schabi.newpipe.report.ErrorActivity;
import org.schabi.newpipe.report.ErrorInfo;
Expand Down Expand Up @@ -229,6 +231,12 @@ protected boolean onError(final Throwable exception) {
} else if (ExceptionUtils.isNetworkRelated(exception)) {
showError(getString(R.string.network_error), true);
return true;
} else if (exception instanceof GeographicRestrictionException) {
showError(getString(R.string.georestricted_content), false);
return true;
} else if (exception instanceof SoundCloudGoPlusException) {
showError(getString(R.string.soundcloud_go_plus_content), false);
return true;
} else if (exception instanceof ContentNotSupportedException) {
showError(getString(R.string.content_not_supported), false);
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@
import org.schabi.newpipe.extractor.comments.CommentsInfo;
import org.schabi.newpipe.extractor.exceptions.ContentNotAvailableException;
import org.schabi.newpipe.extractor.exceptions.ContentNotSupportedException;
import org.schabi.newpipe.extractor.exceptions.GeographicRestrictionException;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.exceptions.ReCaptchaException;
import org.schabi.newpipe.extractor.exceptions.SoundCloudGoPlusException;
import org.schabi.newpipe.extractor.feed.FeedExtractor;
import org.schabi.newpipe.extractor.feed.FeedInfo;
import org.schabi.newpipe.extractor.kiosk.KioskInfo;
Expand Down Expand Up @@ -302,6 +304,11 @@ public static void handleGeneralException(final Context context, final int servi
Toast.makeText(context, R.string.network_error, Toast.LENGTH_LONG).show();
} else if (exception instanceof ContentNotAvailableException) {
Toast.makeText(context, R.string.content_not_available, Toast.LENGTH_LONG).show();
} else if (exception instanceof SoundCloudGoPlusException) {
Toast.makeText(context, R.string.soundcloud_go_plus_content,
Toast.LENGTH_LONG).show();
} else if (exception instanceof GeographicRestrictionException) {
Toast.makeText(context, R.string.georestricted_content, Toast.LENGTH_LONG).show();
} else if (exception instanceof ContentNotSupportedException) {
Toast.makeText(context, R.string.content_not_supported, Toast.LENGTH_LONG).show();
} else {
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -659,4 +659,6 @@
<string name="show_meta_info_summary">Désactivez cette option pour masquer les zones de méta-informations contenant des informations supplémentaires sur le créateur du flux, le contenu du flux ou une demande de recherche.</string>
<string name="show_meta_info_title">Afficher les méta-infos</string>
<string name="no_app_to_open_intent">Aucune application sur votre appareil ne peut ouvrir ceci</string>
<string name="georestricted_content">Ce contenu n\'est pas disponible dans votre pays</string>
<string name="soundcloud_go_plus_content">Ceci est une piste SoundCloud Go+, à minima dans votre pays, qui ne peut être écoutée dans NewPipe</string>
</resources>
4 changes: 3 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="main_bg_subtitle">Tap \"Search\" to get started
\n</string>
Expand Down Expand Up @@ -700,4 +700,6 @@
<string name="recent">Recent</string>
<string name="chapters">Chapters</string>
<string name="no_app_to_open_intent">No app on your device can open this</string>
<string name="georestricted_content">This content is not available in your country</string>
<string name="soundcloud_go_plus_content">This is a SoundCloud Go+ track, at least in your country, so it cannot be streamed by NewPipe</string>
</resources>

0 comments on commit 3a663dd

Please sign in to comment.