fix shahid4u (#940)

This commit is contained in:
adly98
2022-10-17 08:15:22 +02:00
committed by GitHub
parent c20783a72c
commit 35687654cd
3 changed files with 38 additions and 35 deletions

View File

@ -5,7 +5,7 @@ ext {
extName = 'شاهد فور يو' extName = 'شاهد فور يو'
pkgNameSuffix = 'ar.shahid4u' pkgNameSuffix = 'ar.shahid4u'
extClass = '.Shahid4U' extClass = '.Shahid4U'
extVersionCode = 6 extVersionCode = 7
libVersion = '13' libVersion = '13'
} }

View File

@ -206,19 +206,25 @@ class Shahid4U : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
private fun videosFromElement(document: Document): List<Video> { private fun videosFromElement(document: Document): List<Video> {
val videoList = mutableListOf<Video>() val videoList = mutableListOf<Video>()
val scriptSelect = document.select("script:containsData(eval)").first().data() return try {
val serverPrefix = scriptSelect.substringAfter("|net|cdn|amzn|").substringBefore("|rewind|icon|") val scriptSelect = document.select("script:containsData(eval)").first().data()
val sourceServer = "https://$serverPrefix.e-amzn-cdn.net" val serverPrefix =
val qualities = scriptSelect.substringAfter("|image|").substringBefore("|sources|").replace("||", "|").split("|") scriptSelect.substringAfter("|net|cdn|amzn|").substringBefore("|rewind|icon|")
qualities.forEachIndexed { i, q -> val sourceServer = "https://$serverPrefix.e-amzn-cdn.net"
if (i % 2 == 0) { val qualities = scriptSelect.substringAfter("|image|").substringBefore("|sources|")
val id = qualities[i + 1] .replace("||", "|").split("|")
val src = "$sourceServer/$id/v.mp4" qualities.forEachIndexed { i, q ->
val video = Video(src, "Main: $q", src) if (i % 2 == 0) {
videoList.add(video) val id = qualities[i + 1]
val src = "$sourceServer/$id/v.mp4"
val video = Video(src, "Main: $q", src)
videoList.add(video)
}
} }
videoList
} catch (e: Exception) {
videoList
} }
return videoList
} }
override fun List<Video>.sort(): List<Video> { override fun List<Video>.sort(): List<Video> {
@ -276,6 +282,7 @@ class Shahid4U : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
return GET(catUrl, headers) return GET(catUrl, headers)
} }
} }
else -> {}
} }
} }
return GET(url, headers) return GET(url, headers)

View File

@ -4,40 +4,36 @@ import eu.kanade.tachiyomi.animesource.model.Video
import eu.kanade.tachiyomi.network.GET import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.util.asJsoup import eu.kanade.tachiyomi.util.asJsoup
import okhttp3.OkHttpClient import okhttp3.OkHttpClient
import java.lang.Exception
class OkruExtractor(private val client: OkHttpClient) { class OkruExtractor(private val client: OkHttpClient) {
fun videosFromUrl(url: String): List<Video> { fun videosFromUrl(url: String, qualityPrefix: String = ""): List<Video> {
val document = client.newCall(GET(url)).execute().asJsoup() val videoList = mutableListOf<Video>()
if (document == null) { return try {
throw Exception("Not used") val document = client.newCall(GET(url)).execute().asJsoup()
} else { val qualities = listOf(
val videoList = mutableListOf<Video>() Pair("full", "1080p"),
val qualityMap = mapOf( Pair("hd", "720p"),
"Okru: mobile" to "Okru: 140p", Pair("sd", "480p"),
"Okru: lowest" to "Okru: 240p", Pair("low", "360p"),
"Okru: low" to "Okru: 360p", Pair("lowest", "240p"),
"Okru: sd" to "Okru: 480p", Pair("mobile", "144p")
"Okru: hd" to "Okru: 720p",
"Okru: fhd" to "Okru: 1080p"
) )
val videosString = document.select("div[data-options]").attr("data-options") val videosString = document.select("div[data-options]").attr("data-options")
.substringAfter("\\\"videos\\\":[{\\\"name\\\":\\\"") .substringAfter("\\\"videos\\\":[{\\\"name\\\":\\\"")
.substringBefore("]") .substringBefore("]")
videosString.split("{\\\"name\\\":\\\"").reversed().forEach { it1 -> videosString.split("{\\\"name\\\":\\\"").reversed().forEach {
val videoUrl = it1.substringAfter("url\\\":\\\"") val videoUrl = it.substringAfter("url\\\":\\\"")
.substringBefore("\\\"") .substringBefore("\\\"")
.replace("\\\\u0026", "&") .replace("\\\\u0026", "&")
val videoQuality = "Okru: " + it1.substringBefore("\\\"") val quality = try { qualities.find { q -> q.first == it.substringBefore("\\\"") }?.second } catch (e: Exception) { it.substringBefore("\\\"") }
val videoQuality = qualityPrefix + "Okru:" + quality
if (videoUrl.startsWith("https://")) { if (videoUrl.startsWith("https://")) {
val video = qualityMap[videoQuality]?.let { Video(videoUrl, it, videoUrl) } videoList.add(Video(videoUrl, videoQuality, videoUrl, headers = null))
if (video != null)
videoList.add(video)
else
videoList.add(Video(videoUrl, videoQuality, videoUrl))
} }
} }
return videoList videoList
} catch (e: Exception) {
videoList
} }
} }
} }