fix(pt/rinecloud): Fix video extractor (#2132)

This commit is contained in:
Claudemirovsky
2023-09-03 07:44:39 -03:00
committed by GitHub
parent 29ae7097d1
commit c15316f7c6
4 changed files with 23 additions and 20 deletions

View File

@ -1,3 +1,4 @@
dependencies {
implementation(project(":lib-unpacker"))
implementation(project(":lib-playlist-utils"))
}

View File

@ -15,11 +15,10 @@ class RineCloud : AnimeStream(
override val prefQualityValues = arrayOf("1080p", "720p", "480p", "360p", "240p")
override val prefQualityEntries = prefQualityValues
private val rinecloudExtractor by lazy { RineCloudExtractor(client, headers) }
override fun getVideoList(url: String, name: String): List<Video> {
return when {
"rine.cloud" in url -> {
RineCloudExtractor(client).videosFromUrl(url, headers)
}
"rine.cloud" in url -> rinecloudExtractor.videosFromUrl(url)
else -> emptyList()
}
}

View File

@ -2,14 +2,17 @@ package eu.kanade.tachiyomi.animeextension.pt.rinecloud.extractors
import android.util.Base64
import eu.kanade.tachiyomi.animesource.model.Video
import eu.kanade.tachiyomi.lib.playlistutils.PlaylistUtils
import eu.kanade.tachiyomi.lib.unpacker.Unpacker
import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.util.asJsoup
import okhttp3.Headers
import okhttp3.OkHttpClient
class RineCloudExtractor(private val client: OkHttpClient) {
fun videosFromUrl(url: String, headers: Headers): List<Video> {
class RineCloudExtractor(private val client: OkHttpClient, private val headers: Headers) {
private val playlistUtils by lazy { PlaylistUtils(client, headers) }
fun videosFromUrl(url: String): List<Video> {
val playerDoc = client.newCall(GET(url, headers)).execute().asJsoup()
val scriptData = playerDoc.selectFirst("script:containsData(JuicyCodes.Run)")
?.data()
@ -23,21 +26,21 @@ class RineCloudExtractor(private val client: OkHttpClient) {
val unpackedJs = Unpacker.unpack(decodedData).ifEmpty { return emptyList() }
val masterPlaylistUrl = unpackedJs.substringAfter("sources:[")
.substringAfter("file\":\"")
.substringBefore('"')
return if ("googlevideo" in unpackedJs) {
unpackedJs.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 = unpackedJs.substringAfter("sources:")
.substringAfter("file\":\"")
.substringBefore('"')
val playlistData = client.newCall(GET(masterPlaylistUrl, headers)).execute()
.body.string()
val separator = "#EXT-X-STREAM-INF:"
return playlistData.substringAfter(separator).split(separator).map {
val quality = it.substringAfter("RESOLUTION=")
.substringAfter("x")
.substringBefore("\n")
.substringBefore(",") + "p"
val videoUrl = it.substringAfter("\n").substringBefore("\n")
Video(videoUrl, "RineCloud - $quality", videoUrl, headers = headers)
playlistUtils.extractFromHls(masterPlaylistUrl, videoNameGen = { "Rinecloud - $it" })
}
}
}

View File

@ -23,7 +23,7 @@ class AnimeStreamGenerator : ThemeSourceGenerator {
SingleLang("LMAnime", "https://lmanime.com", "all", isNsfw = false, overrideVersionCode = 2),
SingleLang("LuciferDonghua", "https://luciferdonghua.in", "en", isNsfw = false),
SingleLang("MiniOppai", "https://minioppai.org", "id", isNsfw = true, overrideVersionCode = 2),
SingleLang("RineCloud", "https://rine.cloud", "pt-BR", isNsfw = false),
SingleLang("RineCloud", "https://rine.cloud", "pt-BR", isNsfw = false, overrideVersionCode = 1),
SingleLang("TRAnimeCI", "https://tranimeci.com", "tr", isNsfw = false),
)