From 72a24b1734d613f76cc4ca9b9a446bd963bf28ef Mon Sep 17 00:00:00 2001 From: Dark25 Date: Tue, 29 Oct 2024 21:19:06 +0100 Subject: [PATCH] Feat(pt/RineCloud): Update extractor (#125) --- src/pt/rinecloud/build.gradle | 2 +- .../extractors/RineCloudExtractor.kt | 28 +++++++++---------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/pt/rinecloud/build.gradle b/src/pt/rinecloud/build.gradle index 90812f45be..092c957f87 100644 --- a/src/pt/rinecloud/build.gradle +++ b/src/pt/rinecloud/build.gradle @@ -3,7 +3,7 @@ ext { extClass = '.RineCloud' themePkg = 'animestream' baseUrl = 'https://rine.cloud' - overrideVersionCode = 11 + overrideVersionCode = 12 } apply from: "$rootDir/common.gradle" diff --git a/src/pt/rinecloud/src/eu/kanade/tachiyomi/animeextension/pt/rinecloud/extractors/RineCloudExtractor.kt b/src/pt/rinecloud/src/eu/kanade/tachiyomi/animeextension/pt/rinecloud/extractors/RineCloudExtractor.kt index ced8df4e0d..a5c313e7b2 100644 --- a/src/pt/rinecloud/src/eu/kanade/tachiyomi/animeextension/pt/rinecloud/extractors/RineCloudExtractor.kt +++ b/src/pt/rinecloud/src/eu/kanade/tachiyomi/animeextension/pt/rinecloud/extractors/RineCloudExtractor.kt @@ -29,21 +29,19 @@ class RineCloudExtractor(private val client: OkHttpClient, private val headers: ?: return emptyList() } - return if ("googlevideo" in script) { - script.substringAfter("sources:").substringBefore("]") - .split("{") - .drop(1) - .map { - val videoUrl = it.substringAfter("file\":\"").substringBefore('"') - val quality = it.substringAfter("label\":\"").substringBefore('"') - Video(videoUrl, "Rinecloud - $quality", videoUrl, headers) - } - } else { - val masterPlaylistUrl = script.substringAfter("sources:") - .substringAfter("file\":\"") - .substringBefore('"') + return script.substringAfter("sources:").substringBefore("]") + .split("{") + .drop(1) + .flatMap { + val videoUrl = it.substringAfter("\"file\"").substringAfter('"').substringBefore('"') + val quality = it.substringAfter("\"label\"").substringAfter('"').substringBefore('"').ifBlank { "Unknown" } - playlistUtils.extractFromHls(masterPlaylistUrl, videoNameGen = { "Rinecloud - $it" }) - } + when { + arrayOf("googlevideo", ".mp4").any(videoUrl) -> listOf(Video(videoUrl, "Rinecloud - $quality", videoUrl, headers)) + else -> playlistUtils.extractFromHls(videoUrl, videoNameGen = { "Rinecloud - ${if (it == "Video") quality else it}" }) + } + } } + + private fun Array.any(url: String): Boolean = this.any { url.contains(it, ignoreCase = true) } }