feat(tr/anizm): Add Aincrab extractor (#2252)
This commit is contained in:
@ -8,11 +8,12 @@ ext {
|
||||
extName = 'Anizm'
|
||||
pkgNameSuffix = 'tr.anizm'
|
||||
extClass = '.Anizm'
|
||||
extVersionCode = 4
|
||||
extVersionCode = 5
|
||||
libVersion = '13'
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(project(":lib-playlist-utils"))
|
||||
implementation(project(":lib-dood-extractor"))
|
||||
implementation(project(":lib-filemoon-extractor"))
|
||||
implementation(project(":lib-gdriveplayer-extractor"))
|
||||
|
@ -7,6 +7,7 @@ import androidx.preference.ListPreference
|
||||
import androidx.preference.MultiSelectListPreference
|
||||
import androidx.preference.PreferenceScreen
|
||||
import eu.kanade.tachiyomi.animeextension.tr.anizm.AnizmFilters.applyFilterParams
|
||||
import eu.kanade.tachiyomi.animeextension.tr.anizm.extractors.AincradExtractor
|
||||
import eu.kanade.tachiyomi.animesource.ConfigurableAnimeSource
|
||||
import eu.kanade.tachiyomi.animesource.model.AnimeFilterList
|
||||
import eu.kanade.tachiyomi.animesource.model.AnimesPage
|
||||
@ -208,7 +209,10 @@ class Anizm : ParsedAnimeHttpSource(), ConfigurableAnimeSource {
|
||||
.let(Jsoup::parse)
|
||||
.select("a.videoPlayerButtons")
|
||||
.toList()
|
||||
.filter { it.text().trim() in chosenHosts }
|
||||
.filter { host ->
|
||||
val hostName = host.text().trim()
|
||||
chosenHosts.any { hostName.contains(it, true) }
|
||||
}
|
||||
.map { fansub to it.attr("video").replace("/video/", "/player/") }
|
||||
}.getOrElse { emptyList() }
|
||||
}
|
||||
@ -236,6 +240,7 @@ class Anizm : ParsedAnimeHttpSource(), ConfigurableAnimeSource {
|
||||
client.newBuilder().followRedirects(false).build()
|
||||
}
|
||||
|
||||
private val aincradExtractor by lazy { AincradExtractor(client, headers, json) }
|
||||
private val doodExtractor by lazy { DoodExtractor(client) }
|
||||
private val filemoonExtractor by lazy { FilemoonExtractor(client) }
|
||||
private val gdrivePlayerExtractor by lazy { GdrivePlayerExtractor(client) }
|
||||
@ -270,6 +275,7 @@ class Anizm : ParsedAnimeHttpSource(), ConfigurableAnimeSource {
|
||||
}
|
||||
"uqload" in url -> uqloadExtractor.videosFromUrl(url)
|
||||
"voe.sx" in url -> voeExtractor.videoFromUrl(url)?.let(::listOf)
|
||||
"anizmplayer.com" in url -> aincradExtractor.videosFromUrl(url)
|
||||
else -> null
|
||||
} ?: emptyList()
|
||||
}
|
||||
@ -449,6 +455,7 @@ class Anizm : ParsedAnimeHttpSource(), ConfigurableAnimeSource {
|
||||
private const val PREF_HOSTS_SELECTION_KEY = "pref_hosts_selection"
|
||||
private const val PREF_HOSTS_SELECTION_TITLE = "Disable/enable video hosts"
|
||||
private val PREF_HOSTS_SELECTION_ENTRIES = arrayOf(
|
||||
"Aincrad",
|
||||
"DoodStream",
|
||||
"FileMoon",
|
||||
"GDrive",
|
||||
|
@ -0,0 +1,50 @@
|
||||
package eu.kanade.tachiyomi.animeextension.tr.anizm.extractors
|
||||
|
||||
import eu.kanade.tachiyomi.animesource.model.Video
|
||||
import eu.kanade.tachiyomi.lib.playlistutils.PlaylistUtils
|
||||
import eu.kanade.tachiyomi.network.POST
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.decodeFromString
|
||||
import kotlinx.serialization.json.Json
|
||||
import okhttp3.FormBody
|
||||
import okhttp3.Headers
|
||||
import okhttp3.OkHttpClient
|
||||
|
||||
class AincradExtractor(
|
||||
private val client: OkHttpClient,
|
||||
private val headers: Headers,
|
||||
private val json: Json,
|
||||
) {
|
||||
private val playlistUtils by lazy { PlaylistUtils(client, headers) }
|
||||
|
||||
fun videosFromUrl(url: String): List<Video> {
|
||||
val hash = url.substringAfterLast("video/").substringBefore("/")
|
||||
val body = FormBody.Builder()
|
||||
.add("hash", hash)
|
||||
.add("r", "https://anizm.net/")
|
||||
.build()
|
||||
|
||||
val headers = headers.newBuilder()
|
||||
.set("Origin", DOMAIN)
|
||||
.set("Referer", url)
|
||||
.set("X-Requested-With", "XMLHttpRequest")
|
||||
.build()
|
||||
val req = POST("$DOMAIN/player/index.php?data=$hash&do=getVideo", headers, body)
|
||||
val res = client.newCall(req).execute().use { it.body.string() }
|
||||
return runCatching {
|
||||
val data = json.decodeFromString<ResponseDto>(res)
|
||||
playlistUtils.extractFromHls(
|
||||
data.securedLink!!,
|
||||
referer = url,
|
||||
videoNameGen = { "Aincrad - $it" },
|
||||
)
|
||||
}.getOrElse { emptyList() }
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class ResponseDto(val securedLink: String?)
|
||||
|
||||
companion object {
|
||||
private const val DOMAIN = "https://anizmplayer.com"
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user