From bc468b6f36adcf3c3449d44af7a852d1998a917b Mon Sep 17 00:00:00 2001 From: Christian Schabesberger Date: Fri, 26 Feb 2016 01:32:44 +0100 Subject: [PATCH] fixed stream exception handling --- .../newpipe/VideoItemDetailFragment.java | 18 ++++++++++++++++++ .../schabi/newpipe/extractor/VideoInfo.java | 9 ++++++++- app/src/main/res/values/strings.xml | 1 + 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/schabi/newpipe/VideoItemDetailFragment.java b/app/src/main/java/org/schabi/newpipe/VideoItemDetailFragment.java index 05271e798..a023d36a7 100644 --- a/app/src/main/java/org/schabi/newpipe/VideoItemDetailFragment.java +++ b/app/src/main/java/org/schabi/newpipe/VideoItemDetailFragment.java @@ -165,6 +165,24 @@ public class VideoItemDetailFragment extends Fragment { } }); e.printStackTrace(); + } catch(VideoInfo.StreamExctractException e) { + if(!videoInfo.errors.isEmpty()) { + // !!! if this case ever kicks in someone gets kicked out !!! + ErrorActivity.reportError(h, getActivity(), e, VideoItemListActivity.class, null, + ErrorActivity.ErrorInfo.make(ErrorActivity.REQUESTED_STREAM, + service.getServiceInfo().name, videoUrl, R.string.could_not_get_stream)); + } else { + ErrorActivity.reportError(h, getActivity(), videoInfo.errors, VideoItemListActivity.class, null, + ErrorActivity.ErrorInfo.make(ErrorActivity.REQUESTED_STREAM, + service.getServiceInfo().name, videoUrl, R.string.could_not_get_stream)); + } + h.post(new Runnable() { + @Override + public void run() { + getActivity().finish(); + } + }); + e.printStackTrace(); } catch (ParsingException e) { ErrorActivity.reportError(h, getActivity(), e, VideoItemListActivity.class, null, ErrorActivity.ErrorInfo.make(ErrorActivity.REQUESTED_STREAM, diff --git a/app/src/main/java/org/schabi/newpipe/extractor/VideoInfo.java b/app/src/main/java/org/schabi/newpipe/extractor/VideoInfo.java index 2ae58a9f2..d023cf360 100644 --- a/app/src/main/java/org/schabi/newpipe/extractor/VideoInfo.java +++ b/app/src/main/java/org/schabi/newpipe/extractor/VideoInfo.java @@ -28,6 +28,12 @@ import java.util.Vector; @SuppressWarnings("ALL") public class VideoInfo extends AbstractVideoInfo { + public static class StreamExctractException extends ExtractionException { + StreamExctractException(String message) { + super(message); + } + } + /**Fills out the video info fields which are common to all services. * Probably needs to be overridden by subclasses*/ public static VideoInfo getVideoInfo(StreamExtractor extractor, Downloader downloader) @@ -116,7 +122,8 @@ public class VideoInfo extends AbstractVideoInfo { if((videoInfo.video_streams == null || videoInfo.video_streams.isEmpty()) && (videoInfo.audio_streams == null || videoInfo.audio_streams.isEmpty()) && (videoInfo.dashMpdUrl == null || videoInfo.dashMpdUrl.isEmpty())) { - throw new ExtractionException("Could not get any stream. See error variable to get further details."); + throw new StreamExctractException( + "Could not get any stream. See error variable to get further details."); } return videoInfo; diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index bfbe9ca37..0edc9e353 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -88,6 +88,7 @@ Blocked by GEMA. Could not setup download menu. This is a LIVE STREAM. These are not yet supported. + Could not get any stream. Sorry that should not happen. Guru Meditation.