nekopoi: fix video loading

This commit is contained in:
sora 2023-07-21 23:17:23 +07:00
parent 92bd21310a
commit b8b87dea74
2 changed files with 7 additions and 7 deletions

View file

@ -1,5 +1,5 @@
// use an integer for version numbers // use an integer for version numbers
version = 2 version = 3
cloudstream { cloudstream {

View file

@ -30,6 +30,7 @@ class Nekopoi : MainAPI() {
"SendCm", "SendCm",
"GoogleDrive", "GoogleDrive",
) )
const val mirroredHost = "https://www.mirrored.to"
fun getStatus(t: String?): ShowStatus { fun getStatus(t: String?): ShowStatus {
return when (t) { return when (t) {
@ -156,7 +157,7 @@ class Nekopoi : MainAPI() {
?.attr("href") ?.attr("href")
}.filter { it.first != Qualities.P360.value }.map { }.filter { it.first != Qualities.P360.value }.map {
val bypassedAds = bypassMirrored(bypassOuo(it.second)) val bypassedAds = bypassMirrored(bypassOuo(it.second))
bypassedAds.amap ads@{ adsLink -> bypassedAds.apmap ads@{ adsLink ->
loadExtractor( loadExtractor(
fixEmbed(adsLink) ?: return@ads, fixEmbed(adsLink) ?: return@ads,
"$mainUrl/", "$mainUrl/",
@ -227,19 +228,18 @@ class Nekopoi : MainAPI() {
private suspend fun bypassMirrored(url: String?): List<String?> { private suspend fun bypassMirrored(url: String?): List<String?> {
val request = app.get(url ?: return emptyList()) val request = app.get(url ?: return emptyList())
val hostUrl = getBaseUrl(request.url)
var nextUrl = request.document.selectFirst("div.row div.centered a")?.attr("href") var nextUrl = request.document.selectFirst("div.row div.centered a")?.attr("href")
nextUrl = app.get(nextUrl ?: return emptyList()).text.substringAfter("\"GET\", \"") nextUrl = app.get(nextUrl ?: return emptyList()).text.substringAfter("\"GET\", \"")
.substringBefore("\"") .substringBefore("\"")
return app.get(fixUrl(nextUrl, hostUrl)).document.select("table.hoverable tbody tr") return app.get(fixUrl(nextUrl, mirroredHost)).document.select("table.hoverable tbody tr")
.filter { mirror -> .filter { mirror ->
!mirrorIsBlackList(mirror.selectFirst("img")?.attr("alt")) !mirrorIsBlackList(mirror.selectFirst("img")?.attr("alt"))
}.amap { }.apmap {
val fileLink = it.selectFirst("a")?.attr("href") val fileLink = it.selectFirst("a")?.attr("href")
app.get( app.get(
fixUrl( fixUrl(
fileLink ?: return@amap null, fileLink ?: return@apmap null,
hostUrl mirroredHost
) )
).document.selectFirst("div.code_wrap code")?.text() ).document.selectFirst("div.code_wrap code")?.text()
} }