From 82a4e603f908647bb1ae2e6fa8469412dc5a06a5 Mon Sep 17 00:00:00 2001 From: Ruben Gees Date: Sun, 26 Feb 2017 15:52:10 +0100 Subject: [PATCH] Improve error handling of stream resolvers --- .../com/proxerme/app/stream/resolver/ClipfishResolver.kt | 5 ++--- .../com/proxerme/app/stream/resolver/CrunchyrollResolver.kt | 5 ++--- .../app/stream/resolver/DailyMotionStreamResolver.kt | 4 ++-- .../com/proxerme/app/stream/resolver/Mp4UploadResolver.kt | 4 ++-- .../proxerme/app/stream/resolver/NovamovStreamResolver.kt | 2 +- .../com/proxerme/app/stream/resolver/StreamcloudResolver.kt | 2 +- .../proxerme/app/stream/resolver/VideoWeedStreamResolver.kt | 2 +- app/src/main/res/values/strings.xml | 2 +- 8 files changed, 12 insertions(+), 14 deletions(-) diff --git a/app/src/main/kotlin/com/proxerme/app/stream/resolver/ClipfishResolver.kt b/app/src/main/kotlin/com/proxerme/app/stream/resolver/ClipfishResolver.kt index 54f92a68..a9d3869c 100644 --- a/app/src/main/kotlin/com/proxerme/app/stream/resolver/ClipfishResolver.kt +++ b/app/src/main/kotlin/com/proxerme/app/stream/resolver/ClipfishResolver.kt @@ -19,12 +19,11 @@ class ClipfishResolver : StreamResolver() { private val regex = Regex("video/(\\d+)?") override fun resolve(url: String): StreamResolutionResult { - val id = regex.find(url)?.groupValues?.get(1) - ?: throw StreamResolutionException() + val id = regex.find(url)?.groupValues?.get(1) ?: throw StreamResolutionException() return StreamResolutionResult(Intent(Intent.ACTION_VIEW, Uri.parse("clipfish://video/$id?ref=proxer")), { AppRequiredDialog.show(it, "Clipfish", "com.rtli.clipfish") }) } -} \ No newline at end of file +} diff --git a/app/src/main/kotlin/com/proxerme/app/stream/resolver/CrunchyrollResolver.kt b/app/src/main/kotlin/com/proxerme/app/stream/resolver/CrunchyrollResolver.kt index feb2e01e..ed088635 100644 --- a/app/src/main/kotlin/com/proxerme/app/stream/resolver/CrunchyrollResolver.kt +++ b/app/src/main/kotlin/com/proxerme/app/stream/resolver/CrunchyrollResolver.kt @@ -19,12 +19,11 @@ class CrunchyrollResolver : StreamResolver() { private val regex = Regex("media_id=(\\d+)") override fun resolve(url: String): StreamResolutionResult { - val id = regex.find(url)?.groupValues?.get(1) - ?: throw StreamResolutionException() + val id = regex.find(url)?.groupValues?.get(1) ?: throw StreamResolutionException() return StreamResolutionResult(Intent(Intent.ACTION_VIEW, Uri.parse("crunchyroll://media/$id")), { AppRequiredDialog.show(it, "Crunchyroll", "com.crunchyroll.crunchyroid") }) } -} \ No newline at end of file +} diff --git a/app/src/main/kotlin/com/proxerme/app/stream/resolver/DailyMotionStreamResolver.kt b/app/src/main/kotlin/com/proxerme/app/stream/resolver/DailyMotionStreamResolver.kt index cc8be20c..117db590 100644 --- a/app/src/main/kotlin/com/proxerme/app/stream/resolver/DailyMotionStreamResolver.kt +++ b/app/src/main/kotlin/com/proxerme/app/stream/resolver/DailyMotionStreamResolver.kt @@ -47,8 +47,8 @@ class DailyMotionStreamResolver : StreamResolver() { } }?.flatten()?.sortedByDescending { it.first } - val result = Uri.parse(mp4Links?.firstOrNull()?.second) - ?: throw StreamResolutionException() + val result = Uri.parse(mp4Links?.firstOrNull()?.second + ?: throw StreamResolutionException()) return StreamResolutionResult(result, "video/mp4") } else { diff --git a/app/src/main/kotlin/com/proxerme/app/stream/resolver/Mp4UploadResolver.kt b/app/src/main/kotlin/com/proxerme/app/stream/resolver/Mp4UploadResolver.kt index 4ecad0ac..8ab2c79f 100644 --- a/app/src/main/kotlin/com/proxerme/app/stream/resolver/Mp4UploadResolver.kt +++ b/app/src/main/kotlin/com/proxerme/app/stream/resolver/Mp4UploadResolver.kt @@ -26,8 +26,8 @@ class Mp4UploadResolver : StreamResolver() { .url(url) .build()).execute() - val result = Uri.parse(regex.find(validateAndGetResult(response))?.groupValues?.get(1)) - ?: throw StreamResolutionException() + val result = Uri.parse(regex.find(validateAndGetResult(response))?.groupValues?.get(1) + ?: throw StreamResolutionException()) return StreamResolutionResult(result, "video/mp4") } diff --git a/app/src/main/kotlin/com/proxerme/app/stream/resolver/NovamovStreamResolver.kt b/app/src/main/kotlin/com/proxerme/app/stream/resolver/NovamovStreamResolver.kt index dc710764..e5766841 100644 --- a/app/src/main/kotlin/com/proxerme/app/stream/resolver/NovamovStreamResolver.kt +++ b/app/src/main/kotlin/com/proxerme/app/stream/resolver/NovamovStreamResolver.kt @@ -41,7 +41,7 @@ class NovamovStreamResolver : StreamResolver() { .build()).execute() val result = Uri.parse(urlRegex.find(validateAndGetResult(apiResponse)) - ?.groupValues?.get(1)) ?: throw StreamResolutionException() + ?.groupValues?.get(1) ?: throw StreamResolutionException()) return StreamResolutionResult(result, "video/x-flv") } diff --git a/app/src/main/kotlin/com/proxerme/app/stream/resolver/StreamcloudResolver.kt b/app/src/main/kotlin/com/proxerme/app/stream/resolver/StreamcloudResolver.kt index fa18b4e1..4082bb8d 100644 --- a/app/src/main/kotlin/com/proxerme/app/stream/resolver/StreamcloudResolver.kt +++ b/app/src/main/kotlin/com/proxerme/app/stream/resolver/StreamcloudResolver.kt @@ -39,7 +39,7 @@ class StreamcloudResolver : StreamResolver() { .execute() val result = Uri.parse(fileRegex.find(validateAndGetResult(response)) - ?.groupValues?.get(1)) ?: throw StreamResolutionException() + ?.groupValues?.get(1) ?: throw StreamResolutionException()) return StreamResolutionResult(result, "video/mp4") } diff --git a/app/src/main/kotlin/com/proxerme/app/stream/resolver/VideoWeedStreamResolver.kt b/app/src/main/kotlin/com/proxerme/app/stream/resolver/VideoWeedStreamResolver.kt index 1324df7d..7934383f 100644 --- a/app/src/main/kotlin/com/proxerme/app/stream/resolver/VideoWeedStreamResolver.kt +++ b/app/src/main/kotlin/com/proxerme/app/stream/resolver/VideoWeedStreamResolver.kt @@ -40,7 +40,7 @@ class VideoWeedStreamResolver : StreamResolver() { .build()).execute() val result = Uri.parse(urlRegex.find(validateAndGetResult(apiResponse)) - ?.groupValues?.get(1)) ?: throw StreamResolutionException() + ?.groupValues?.get(1) ?: throw StreamResolutionException()) return StreamResolutionResult(result, "video/x-flv") } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 753695f2..c6293a41 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -127,7 +127,7 @@ Dieser Hoster konnte nicht verarbeitet werden Der Eintrag konnte nicht gelöscht werden: %s Das Lesezeichen konnte nicht gelöscht werden: %s - Fehler beim Laden des Streams + Fehler beim Laden des Streams. Das Video ist eventuell nicht mehr verfügbar Der Server hat nicht rechtzeitig geantwortet. Versuche es später noch einmal