Skip to content

Commit

Permalink
Feat(pt/RineCloud): Update extractor (#125)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dark25 authored Oct 29, 2024
1 parent 35ec1cb commit 72a24b1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/pt/rinecloud/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ext {
extClass = '.RineCloud'
themePkg = 'animestream'
baseUrl = 'https://rine.cloud'
overrideVersionCode = 11
overrideVersionCode = 12
}

apply from: "$rootDir/common.gradle"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>.any(url: String): Boolean = this.any { url.contains(it, ignoreCase = true) }
}

0 comments on commit 72a24b1

Please sign in to comment.