5858import org .schabi .newpipe .extractor .StreamingService ;
5959import org .schabi .newpipe .extractor .StreamingService .LinkType ;
6060import org .schabi .newpipe .extractor .channel .ChannelInfo ;
61- import org .schabi .newpipe .extractor .exceptions .AgeRestrictedContentException ;
62- import org .schabi .newpipe .extractor .exceptions .ContentNotAvailableException ;
63- import org .schabi .newpipe .extractor .exceptions .ContentNotSupportedException ;
6461import org .schabi .newpipe .extractor .exceptions .ExtractionException ;
65- import org .schabi .newpipe .extractor .exceptions .GeographicRestrictionException ;
66- import org .schabi .newpipe .extractor .exceptions .PaidContentException ;
67- import org .schabi .newpipe .extractor .exceptions .PrivateContentException ;
68- import org .schabi .newpipe .extractor .exceptions .ReCaptchaException ;
69- import org .schabi .newpipe .extractor .exceptions .SoundCloudGoPlusContentException ;
70- import org .schabi .newpipe .extractor .exceptions .YoutubeMusicPremiumContentException ;
7162import org .schabi .newpipe .extractor .linkhandler .ListLinkHandler ;
7263import org .schabi .newpipe .extractor .playlist .PlaylistInfo ;
7364import org .schabi .newpipe .extractor .stream .StreamInfo ;
74- import org .schabi .newpipe .ktx .ExceptionUtils ;
7565import org .schabi .newpipe .local .dialog .PlaylistDialog ;
7666import org .schabi .newpipe .player .PlayerType ;
7767import org .schabi .newpipe .player .helper .PlayerHelper ;
@@ -260,7 +250,8 @@ private void handleUrl(final String url) {
260250 showUnsupportedUrlDialog (url );
261251 }
262252 }, throwable -> handleError (this , new ErrorInfo (throwable ,
263- UserAction .SHARE_TO_NEWPIPE , "Getting service from url: " + url ))));
253+ UserAction .SHARE_TO_NEWPIPE , "Getting service from url: " + url ,
254+ null , url ))));
264255 }
265256
266257 /**
@@ -269,40 +260,19 @@ private void handleUrl(final String url) {
269260 * @param errorInfo the error information
270261 */
271262 private static void handleError (final Context context , final ErrorInfo errorInfo ) {
272- if (errorInfo .getThrowable () != null ) {
273- errorInfo .getThrowable ().printStackTrace ();
274- }
275-
276- if (errorInfo .getThrowable () instanceof ReCaptchaException ) {
263+ if (errorInfo .getRecaptchaUrl () != null ) {
277264 Toast .makeText (context , R .string .recaptcha_request_toast , Toast .LENGTH_LONG ).show ();
278265 // Starting ReCaptcha Challenge Activity
279266 final Intent intent = new Intent (context , ReCaptchaActivity .class );
280267 intent .addFlags (Intent .FLAG_ACTIVITY_NEW_TASK );
268+ intent .putExtra (ReCaptchaActivity .RECAPTCHA_URL_EXTRA , errorInfo .getRecaptchaUrl ());
281269 context .startActivity (intent );
282- } else if (errorInfo .getThrowable () != null
283- && ExceptionUtils .isNetworkRelated (errorInfo .getThrowable ())) {
284- Toast .makeText (context , R .string .network_error , Toast .LENGTH_LONG ).show ();
285- } else if (errorInfo .getThrowable () instanceof AgeRestrictedContentException ) {
286- Toast .makeText (context , R .string .restricted_video_no_stream ,
287- Toast .LENGTH_LONG ).show ();
288- } else if (errorInfo .getThrowable () instanceof GeographicRestrictionException ) {
289- Toast .makeText (context , R .string .georestricted_content , Toast .LENGTH_LONG ).show ();
290- } else if (errorInfo .getThrowable () instanceof PaidContentException ) {
291- Toast .makeText (context , R .string .paid_content , Toast .LENGTH_LONG ).show ();
292- } else if (errorInfo .getThrowable () instanceof PrivateContentException ) {
293- Toast .makeText (context , R .string .private_content , Toast .LENGTH_LONG ).show ();
294- } else if (errorInfo .getThrowable () instanceof SoundCloudGoPlusContentException ) {
295- Toast .makeText (context , R .string .soundcloud_go_plus_content ,
296- Toast .LENGTH_LONG ).show ();
297- } else if (errorInfo .getThrowable () instanceof YoutubeMusicPremiumContentException ) {
298- Toast .makeText (context , R .string .youtube_music_premium_content ,
299- Toast .LENGTH_LONG ).show ();
300- } else if (errorInfo .getThrowable () instanceof ContentNotAvailableException ) {
301- Toast .makeText (context , R .string .content_not_available , Toast .LENGTH_LONG ).show ();
302- } else if (errorInfo .getThrowable () instanceof ContentNotSupportedException ) {
303- Toast .makeText (context , R .string .content_not_supported , Toast .LENGTH_LONG ).show ();
304- } else {
270+ } else if (errorInfo .isReportable ()) {
305271 ErrorUtil .createNotification (context , errorInfo );
272+ } else {
273+ // this exception does not usually indicate a problem that should be reported,
274+ // so just show a toast instead of the notification
275+ Toast .makeText (context , errorInfo .getMessage (context ), Toast .LENGTH_LONG ).show ();
306276 }
307277
308278 if (context instanceof RouterActivity ) {
@@ -665,7 +635,8 @@ private void handleChoice(final String selectedChoiceKey) {
665635 startActivity (intent );
666636 finish ();
667637 }, throwable -> handleError (this , new ErrorInfo (throwable ,
668- UserAction .SHARE_TO_NEWPIPE , "Starting info activity: " + currentUrl )))
638+ UserAction .SHARE_TO_NEWPIPE , "Starting info activity: " + currentUrl ,
639+ null , currentUrl )))
669640 );
670641 return ;
671642 }
@@ -852,10 +823,10 @@ private void openAddToPlaylistDialog(final int currentServiceId, final String cu
852823 })
853824 )),
854825 throwable -> runOnVisible (ctx -> handleError (ctx , new ErrorInfo (
855- throwable ,
856- UserAction .REQUESTED_STREAM ,
826+ throwable , UserAction .REQUESTED_STREAM ,
857827 "Tried to add " + currentUrl + " to a playlist" ,
858- ((RouterActivity ) ctx ).currentService .getServiceId ())
828+ ((RouterActivity ) ctx ).currentService .getServiceId (),
829+ currentUrl )
859830 ))
860831 )
861832 );
@@ -995,7 +966,7 @@ public void handleChoice(final Choice choice) {
995966 }
996967 }, throwable -> handleError (this , new ErrorInfo (throwable , finalUserAction ,
997968 choice .url + " opened with " + choice .playerChoice ,
998- choice .serviceId )));
969+ choice .serviceId , choice . url )));
999970 }
1000971 }
1001972
0 commit comments