refactor(pt/animeshouse): Use PlaylistUtils (#2197)
This commit is contained in:
3
multisrc/overrides/dooplay/animeshouse/additional.gradle
Normal file
3
multisrc/overrides/dooplay/animeshouse/additional.gradle
Normal file
@ -0,0 +1,3 @@
|
||||
dependencies {
|
||||
implementation(project(":lib-playlist-utils"))
|
||||
}
|
@ -9,7 +9,6 @@ class EdifierExtractor(
|
||||
private val client: OkHttpClient,
|
||||
private val headers: Headers,
|
||||
) {
|
||||
|
||||
private val regexEdifier = Regex(""""file":"(.*?)","label":"(\S+?)"""")
|
||||
private val playerName = "EDIFIER"
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package eu.kanade.tachiyomi.animeextension.pt.animeshouse.extractors
|
||||
|
||||
import eu.kanade.tachiyomi.animesource.model.Video
|
||||
import eu.kanade.tachiyomi.network.GET
|
||||
import eu.kanade.tachiyomi.lib.playlistutils.PlaylistUtils
|
||||
import okhttp3.Headers
|
||||
import okhttp3.OkHttpClient
|
||||
|
||||
@ -9,10 +9,9 @@ class GenericExtractor(
|
||||
private val client: OkHttpClient,
|
||||
private val headers: Headers,
|
||||
) {
|
||||
|
||||
private val playlistUtils by lazy { PlaylistUtils(client, headers) }
|
||||
private val regexClpPlayer = Regex("player\\('(\\S+)',")
|
||||
private val regexGcloudPlayer = "file\":\"(\\S+)\"".toRegex()
|
||||
private val regexQuality = Regex("(?<=RESOLUTION=)\\d+x(\\d+).*?\n(https.*)")
|
||||
|
||||
fun getVideoList(url: String, js: String): List<Video> {
|
||||
val (player, regex) = when {
|
||||
@ -22,17 +21,7 @@ class GenericExtractor(
|
||||
|
||||
val playlistUrl = regex.find(js)!!.groupValues.get(1)
|
||||
if ("m3u8.php" in playlistUrl) {
|
||||
client.newCall(GET(playlistUrl, headers)).execute().use { req ->
|
||||
val body = req.body.string()
|
||||
val videos = regexQuality.findAll(body).map {
|
||||
val quality = "$player: " + it.groupValues.get(1) + "p"
|
||||
val videoUrl = it.groupValues.get(2)
|
||||
Video(videoUrl, quality, videoUrl, headers)
|
||||
}.toList()
|
||||
if (videos.size > 0) {
|
||||
return videos
|
||||
}
|
||||
}
|
||||
return playlistUtils.extractFromHls(playlistUrl, videoNameGen = { "$player: $it" })
|
||||
}
|
||||
|
||||
return listOf(Video(playlistUrl, player, playlistUrl, headers))
|
||||
|
@ -9,7 +9,6 @@ class McpExtractor(
|
||||
private val client: OkHttpClient,
|
||||
private val headers: Headers,
|
||||
) {
|
||||
|
||||
private val regexEpId = Regex("ss,\"(\\d+)\"")
|
||||
private val regexVideoUrl = Regex("h\":\"(\\S+?)\"")
|
||||
private val apiUrl = "https://clp-new.animeshouse.net/ah-clp-new"
|
||||
|
@ -1,7 +1,7 @@
|
||||
package eu.kanade.tachiyomi.animeextension.pt.animeshouse.extractors
|
||||
|
||||
import eu.kanade.tachiyomi.animesource.model.Video
|
||||
import eu.kanade.tachiyomi.network.GET
|
||||
import eu.kanade.tachiyomi.lib.playlistutils.PlaylistUtils
|
||||
import okhttp3.Headers
|
||||
import okhttp3.OkHttpClient
|
||||
|
||||
@ -11,32 +11,14 @@ class MpFourDooExtractor(
|
||||
) {
|
||||
private val regexMpdoo = Regex("file\":\"(.*?)\"")
|
||||
private val playerName = "Mp4Doo"
|
||||
private val playlistUtils by lazy { PlaylistUtils(client, headers) }
|
||||
|
||||
fun getVideoList(js: String): List<Video> {
|
||||
val videoUrl = regexMpdoo.find(js)!!.groupValues
|
||||
.get(1)
|
||||
.replace("fy..", "fy.v.")
|
||||
return if (videoUrl.endsWith("playlist.m3u8")) {
|
||||
val playlistBody = client.newCall(GET(videoUrl, headers)).execute()
|
||||
.use { it.body.string() }
|
||||
|
||||
val separator = "#EXT-X-STREAM-INF:"
|
||||
playlistBody.substringAfter(separator).split(separator).map {
|
||||
val quality = playerName + " - " + it.substringAfter("RESOLUTION=")
|
||||
.substringAfter("x")
|
||||
.substringBefore("\n")
|
||||
.substringBefore(",") + "p"
|
||||
|
||||
val path = it.substringAfter("\n").substringBefore("\n")
|
||||
|
||||
val playlistUrl = if (!path.startsWith("https:")) {
|
||||
videoUrl.replace("playlist.m3u8", path)
|
||||
} else {
|
||||
path
|
||||
}
|
||||
|
||||
Video(playlistUrl, quality, playlistUrl, headers)
|
||||
}
|
||||
playlistUtils.extractFromHls(videoUrl, videoNameGen = { "$playerName: $it" })
|
||||
} else {
|
||||
listOf(Video(videoUrl, playerName, videoUrl, headers))
|
||||
}
|
||||
|
Reference in New Issue
Block a user