feat(src/es): Katanime extension added #510

Merged
imper1aldev merged 1 commit from katanime into main 2025-01-11 05:15:16 -06:00
10 changed files with 672 additions and 0 deletions

View file

@ -0,0 +1,19 @@
ext {
extName = 'Katanime'
extClass = '.Katanime'
extVersionCode = 1
}
apply from: "$rootDir/common.gradle"
dependencies {
implementation(project(':lib:streamwish-extractor'))
implementation(project(':lib:streamtape-extractor'))
implementation(project(':lib:filemoon-extractor'))
implementation(project(':lib:sendvid-extractor'))
implementation(project(':lib:vidguard-extractor'))
implementation(project(':lib:mp4upload-extractor'))
implementation(project(':lib:dood-extractor'))
implementation(project(':lib:playlist-utils'))
implementation "dev.datlag.jsunpacker:jsunpacker:1.0.1"
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

View file

@ -0,0 +1,220 @@
package eu.kanade.tachiyomi.lib.cryptoaes
/*
* Copyright (C) The Tachiyomi Open Source Project
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
// Thanks to Vlad on Stackoverflow: https://stackoverflow.com/a/63701411
import android.util.Base64
import java.security.MessageDigest
import java.util.Arrays
import javax.crypto.Cipher
import javax.crypto.spec.IvParameterSpec
import javax.crypto.spec.SecretKeySpec
/**
* Conforming with CryptoJS AES method
*/
@Suppress("unused")
object CryptoAES {
private const val KEY_SIZE = 32 // 256 bits
private const val IV_SIZE = 16 // 128 bits
private const val SALT_SIZE = 8 // 64 bits
private const val HASH_CIPHER = "AES/CBC/PKCS7PADDING"
private const val HASH_CIPHER_FALLBACK = "AES/CBC/PKCS5PADDING"
private const val AES = "AES"
private const val KDF_DIGEST = "MD5"
/**
* Decrypt using CryptoJS defaults compatible method.
* Uses KDF equivalent to OpenSSL's EVP_BytesToKey function
*
* http://stackoverflow.com/a/29152379/4405051
* @param cipherText base64 encoded ciphertext
* @param password passphrase
*/
fun decrypt(cipherText: String, password: String): String {
return try {
val ctBytes = Base64.decode(cipherText, Base64.DEFAULT)
val saltBytes = Arrays.copyOfRange(ctBytes, SALT_SIZE, IV_SIZE)
val cipherTextBytes = Arrays.copyOfRange(ctBytes, IV_SIZE, ctBytes.size)
val md5 = MessageDigest.getInstance("MD5")
val keyAndIV = generateKeyAndIV(KEY_SIZE, IV_SIZE, 1, saltBytes, password.toByteArray(Charsets.UTF_8), md5)
decryptAES(
cipherTextBytes,
keyAndIV?.get(0) ?: ByteArray(KEY_SIZE),
keyAndIV?.get(1) ?: ByteArray(IV_SIZE),
)
} catch (e: Exception) {
""
}
}
fun decryptWithSalt(cipherText: String, salt: String, password: String): String {
return try {
val ctBytes = Base64.decode(cipherText, Base64.DEFAULT)
val md5: MessageDigest = MessageDigest.getInstance("MD5")
val keyAndIV = generateKeyAndIV(
KEY_SIZE,
IV_SIZE,
1,
salt.decodeHex(),
password.toByteArray(Charsets.UTF_8),
md5,
)
decryptAES(
ctBytes,
keyAndIV?.get(0) ?: ByteArray(KEY_SIZE),
keyAndIV?.get(1) ?: ByteArray(IV_SIZE),
)
} catch (e: Exception) {
""
}
}
/**
* Decrypt using CryptoJS defaults compatible method.
*
* @param cipherText base64 encoded ciphertext
* @param keyBytes key as a bytearray
* @param ivBytes iv as a bytearray
*/
fun decrypt(cipherText: String, keyBytes: ByteArray, ivBytes: ByteArray): String {
return try {
val cipherTextBytes = Base64.decode(cipherText, Base64.DEFAULT)
decryptAES(cipherTextBytes, keyBytes, ivBytes)
} catch (e: Exception) {
""
}
}
/**
* Encrypt using CryptoJS defaults compatible method.
*
* @param plainText plaintext
* @param keyBytes key as a bytearray
* @param ivBytes iv as a bytearray
*/
fun encrypt(plainText: String, keyBytes: ByteArray, ivBytes: ByteArray): String {
return try {
val cipherTextBytes = plainText.toByteArray()
encryptAES(cipherTextBytes, keyBytes, ivBytes)
} catch (e: Exception) {
""
}
}
/**
* Decrypt using CryptoJS defaults compatible method.
*
* @param cipherTextBytes encrypted text as a bytearray
* @param keyBytes key as a bytearray
* @param ivBytes iv as a bytearray
*/
private fun decryptAES(cipherTextBytes: ByteArray, keyBytes: ByteArray, ivBytes: ByteArray): String {
return try {
val cipher = try {
Cipher.getInstance(HASH_CIPHER)
} catch (e: Throwable) { Cipher.getInstance(HASH_CIPHER_FALLBACK) }
val keyS = SecretKeySpec(keyBytes, AES)
cipher.init(Cipher.DECRYPT_MODE, keyS, IvParameterSpec(ivBytes))
cipher.doFinal(cipherTextBytes).toString(Charsets.UTF_8)
} catch (e: Exception) {
""
}
}
/**
* Encrypt using CryptoJS defaults compatible method.
*
* @param plainTextBytes encrypted text as a bytearray
* @param keyBytes key as a bytearray
* @param ivBytes iv as a bytearray
*/
private fun encryptAES(plainTextBytes: ByteArray, keyBytes: ByteArray, ivBytes: ByteArray): String {
return try {
val cipher = try {
Cipher.getInstance(HASH_CIPHER)
} catch (e: Throwable) { Cipher.getInstance(HASH_CIPHER_FALLBACK) }
val keyS = SecretKeySpec(keyBytes, AES)
cipher.init(Cipher.ENCRYPT_MODE, keyS, IvParameterSpec(ivBytes))
Base64.encodeToString(cipher.doFinal(plainTextBytes), Base64.DEFAULT)
} catch (e: Exception) {
""
}
}
/**
* Generates a key and an initialization vector (IV) with the given salt and password.
*
* https://stackoverflow.com/a/41434590
* This method is equivalent to OpenSSL's EVP_BytesToKey function
* (see https://github.com/openssl/openssl/blob/master/crypto/evp/evp_key.c).
* By default, OpenSSL uses a single iteration, MD5 as the algorithm and UTF-8 encoded password data.
*
* @param keyLength the length of the generated key (in bytes)
* @param ivLength the length of the generated IV (in bytes)
* @param iterations the number of digestion rounds
* @param salt the salt data (8 bytes of data or `null`)
* @param password the password data (optional)
* @param md the message digest algorithm to use
* @return an two-element array with the generated key and IV
*/
private fun generateKeyAndIV(
keyLength: Int,
ivLength: Int,
iterations: Int,
salt: ByteArray,
password: ByteArray,
md: MessageDigest,
): Array<ByteArray?>? {
val digestLength = md.digestLength
val requiredLength = (keyLength + ivLength + digestLength - 1) / digestLength * digestLength
val generatedData = ByteArray(requiredLength)
var generatedLength = 0
return try {
md.reset()
// Repeat process until sufficient data has been generated
while (generatedLength < keyLength + ivLength) {
// Digest data (last digest if available, password data, salt if available)
if (generatedLength > 0) md.update(generatedData, generatedLength - digestLength, digestLength)
md.update(password)
md.update(salt, 0, SALT_SIZE)
md.digest(generatedData, generatedLength, digestLength)
// additional rounds
for (i in 1 until iterations) {
md.update(generatedData, generatedLength, digestLength)
md.digest(generatedData, generatedLength, digestLength)
}
generatedLength += digestLength
}
// Copy key and IV into separate byte arrays
val result = arrayOfNulls<ByteArray>(2)
result[0] = generatedData.copyOfRange(0, keyLength)
if (ivLength > 0) result[1] = generatedData.copyOfRange(keyLength, keyLength + ivLength)
result
} catch (e: Exception) {
throw e
} finally {
// Clean out temporary data
Arrays.fill(generatedData, 0.toByte())
}
}
// Stolen from AnimixPlay(EN) / GogoCdnExtractor
fun String.decodeHex(): ByteArray {
check(length % 2 == 0) { "Must have an even length" }
return chunked(2)
.map { it.toInt(16).toByte() }
.toByteArray()
}
}

View file

@ -0,0 +1,259 @@
package eu.kanade.tachiyomi.animeextension.es.katanime
import android.app.Application
import android.content.SharedPreferences
import androidx.preference.ListPreference
import androidx.preference.PreferenceScreen
import eu.kanade.tachiyomi.animeextension.es.katanime.extractors.UnpackerExtractor
import eu.kanade.tachiyomi.animesource.ConfigurableAnimeSource
import eu.kanade.tachiyomi.animesource.model.AnimeFilterList
import eu.kanade.tachiyomi.animesource.model.AnimesPage
import eu.kanade.tachiyomi.animesource.model.SAnime
import eu.kanade.tachiyomi.animesource.model.SEpisode
import eu.kanade.tachiyomi.animesource.model.Video
import eu.kanade.tachiyomi.animesource.online.AnimeHttpSource
import eu.kanade.tachiyomi.lib.cryptoaes.CryptoAES
import eu.kanade.tachiyomi.lib.doodextractor.DoodExtractor
import eu.kanade.tachiyomi.lib.filemoonextractor.FilemoonExtractor
import eu.kanade.tachiyomi.lib.mp4uploadextractor.Mp4uploadExtractor
import eu.kanade.tachiyomi.lib.sendvidextractor.SendvidExtractor
import eu.kanade.tachiyomi.lib.streamtapeextractor.StreamTapeExtractor
import eu.kanade.tachiyomi.lib.streamwishextractor.StreamWishExtractor
import eu.kanade.tachiyomi.lib.vidguardextractor.VidGuardExtractor
import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.util.asJsoup
import eu.kanade.tachiyomi.util.parseAs
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import okhttp3.Request
import okhttp3.Response
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
import java.text.SimpleDateFormat
import java.util.Calendar
import java.util.Locale
class Katanime : ConfigurableAnimeSource, AnimeHttpSource() {
override val name = "Katanime"
override val baseUrl = "https://katanime.net"
override val lang = "es"
override val supportsLatest = true
private val preferences: SharedPreferences by lazy {
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
}
companion object {
const val DECRYPTION_PASSWORD = "hanabi"
private const val PREF_QUALITY_KEY = "preferred_quality"
private const val PREF_QUALITY_DEFAULT = "1080"
private val QUALITY_LIST = arrayOf("1080", "720", "480", "360")
private const val PREF_SERVER_KEY = "preferred_server"
private const val PREF_SERVER_DEFAULT = "VidGuard"
private val SERVER_LIST = arrayOf(
"StreamWish",
"VidGuard",
"Filemoon",
"StreamTape",
"FileLions",
"DoodStream",
"Sendvid",
"LuluStream",
"Mp4Upload",
)
private val DATE_FORMATTER by lazy {
SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.ENGLISH)
}
}
override fun animeDetailsParse(response: Response): SAnime {
val document = response.asJsoup()
return SAnime.create().apply {
title = document.selectFirst(".comics-title")?.ownText() ?: ""
description = document.selectFirst("#sinopsis p")?.ownText()
genre = document.select(".anime-genres a").joinToString { it.text() }
status = with(document.select(".details-by #estado").text()) {
when {
contains("Finalizado", true) -> SAnime.COMPLETED
contains("Emision", true) -> SAnime.ONGOING
else -> SAnime.UNKNOWN
}
}
}
}
override fun popularAnimeRequest(page: Int) = GET("$baseUrl/populares", headers)
override fun popularAnimeParse(response: Response): AnimesPage {
val document = response.asJsoup()
val elements = document.select("#article-div .full > a")
val nextPage = document.select(".pagination .active ~ li:not(.disabled)").any()
val animeList = elements.map { element ->
SAnime.create().apply {
setUrlWithoutDomain(element.attr("abs:href"))
title = element.selectFirst("img")!!.attr("alt")
thumbnail_url = element.selectFirst("img")?.getImageUrl()
}
}
return AnimesPage(animeList, nextPage)
}
override fun latestUpdatesParse(response: Response) = popularAnimeParse(response)
override fun latestUpdatesRequest(page: Int): Request {
val currentYear = Calendar.getInstance().get(Calendar.YEAR)
return GET("$baseUrl/animes?fecha=$currentYear&p=$page")
}
override fun searchAnimeRequest(page: Int, query: String, filters: AnimeFilterList): Request {
val params = KatanimeFilters.getSearchParameters(filters)
return when {
query.isNotBlank() -> GET("$baseUrl/buscar?q=$query&p=$page", headers)
params.filter.isNotBlank() -> GET("$baseUrl/animes${params.getQuery()}&p=$page", headers)
else -> popularAnimeRequest(page)
}
}
override fun searchAnimeParse(response: Response) = popularAnimeParse(response)
override fun episodeListParse(response: Response): List<SEpisode> {
val jsoup = response.asJsoup()
return jsoup.select("#c_list .cap_list").map {
SEpisode.create().apply {
name = it.selectFirst(".entry-title-h2")?.ownText() ?: ""
episode_number = it.selectFirst(".entry-title-h2")?.ownText()?.substringAfter("Capítulo")?.trim()?.toFloat() ?: 0F
date_upload = it.selectFirst(".timeago")?.attr("datetime")?.toDate() ?: 0L
setUrlWithoutDomain(it.attr("abs:href"))
}
}.reversed()
}
override fun videoListParse(response: Response): List<Video> {
val document = response.asJsoup()
val videoList = mutableListOf<Video>()
document.select("[data-player]:not([data-player-name=\"Mega\"])").forEach { element ->
runCatching {
val dataPlayer = element.attr("data-player")
val playerDocument = client.newCall(GET("$baseUrl/reproductor?url=$dataPlayer"))
.execute()
.asJsoup()
val encryptedData = playerDocument
.selectFirst("script:containsData(var e =)")?.data()
?.substringAfter("var e = '")?.substringBefore("';")
?: return emptyList()
val json = encryptedData.parseAs<CryptoDto>()
val decryptedLink = CryptoAES.decryptWithSalt(json.ct!!, json.s!!, DECRYPTION_PASSWORD)
.replace("\\/", "/").replace("\"", "")
serverVideoResolver(decryptedLink).also(videoList::addAll)
}
}
return videoList
}
private val doodExtractor by lazy { DoodExtractor(client) }
private val streamTapeExtractor by lazy { StreamTapeExtractor(client) }
private val filemoonExtractor by lazy { FilemoonExtractor(client) }
private val sendvidExtractor by lazy { SendvidExtractor(client, headers) }
private val vidGuardExtractor by lazy { VidGuardExtractor(client) }
private val mp4uploadExtractor by lazy { Mp4uploadExtractor(client) }
private val unpackerExtractor by lazy { UnpackerExtractor(client, headers) }
private fun serverVideoResolver(url: String): List<Video> {
return when {
arrayOf("wishembed", "streamwish", "strwish", "wish").any(url) -> StreamWishExtractor(client, headers).videosFromUrl(url, videoNameGen = { "StreamWish:$it" })
arrayOf("doodstream", "dood.", "ds2play", "doods.").any(url) -> doodExtractor.videosFromUrl(url, "DoodStream")
arrayOf("streamtape", "stp", "stape").any(url) -> streamTapeExtractor.videosFromUrl(url, quality = "StreamTape")
arrayOf("filemoon", "moonplayer").any(url) -> filemoonExtractor.videosFromUrl(url, prefix = "Filemoon:")
arrayOf("sendvid").any(url) -> sendvidExtractor.videosFromUrl(url)
arrayOf("lulu").any(url) -> unpackerExtractor.videosFromUrl(url)
arrayOf("vembed", "guard", "listeamed", "bembed", "vgfplay").any(url) -> vidGuardExtractor.videosFromUrl(url)
arrayOf("mp4upload").any(url) -> mp4uploadExtractor.videosFromUrl(url, headers)
else -> emptyList()
}
}
override fun List<Video>.sort(): List<Video> {
val quality = preferences.getString(PREF_QUALITY_KEY, PREF_QUALITY_DEFAULT)!!
val server = preferences.getString(PREF_SERVER_KEY, PREF_SERVER_DEFAULT)!!
return this.sortedWith(
compareBy(
{ it.quality.contains(server, true) },
{ it.quality.contains(quality) },
{ Regex("""(\d+)p""").find(it.quality)?.groupValues?.get(1)?.toIntOrNull() ?: 0 },
),
).reversed()
}
override fun getFilterList(): AnimeFilterList = KatanimeFilters.FILTER_LIST
override fun setupPreferenceScreen(screen: PreferenceScreen) {
ListPreference(screen.context).apply {
key = PREF_SERVER_KEY
title = "Preferred server"
entries = SERVER_LIST
entryValues = SERVER_LIST
setDefaultValue(PREF_SERVER_DEFAULT)
summary = "%s"
setOnPreferenceChangeListener { _, newValue ->
val selected = newValue as String
val index = findIndexOfValue(selected)
val entry = entryValues[index] as String
preferences.edit().putString(key, entry).commit()
}
}.also(screen::addPreference)
ListPreference(screen.context).apply {
key = PREF_QUALITY_KEY
title = "Preferred quality"
entries = QUALITY_LIST
entryValues = QUALITY_LIST
setDefaultValue(PREF_QUALITY_DEFAULT)
summary = "%s"
setOnPreferenceChangeListener { _, newValue ->
val selected = newValue as String
val index = findIndexOfValue(selected)
val entry = entryValues[index] as String
preferences.edit().putString(key, entry).commit()
}
}.also(screen::addPreference)
}
private fun Array<String>.any(url: String): Boolean = this.any { url.contains(it, ignoreCase = true) }
private fun String.toDate(): Long = runCatching { DATE_FORMATTER.parse(trim())?.time }.getOrNull() ?: 0L
private fun org.jsoup.nodes.Element.getImageUrl(): String? {
return when {
isValidUrl("data-src") -> attr("abs:data-src")
isValidUrl("data-lazy-src") -> attr("abs:data-lazy-src")
isValidUrl("srcset") -> attr("abs:srcset").substringBefore(" ")
isValidUrl("src") -> attr("abs:src")
else -> ""
}
}
private fun org.jsoup.nodes.Element.isValidUrl(attrName: String): Boolean {
if (!hasAttr(attrName)) return false
return !attr(attrName).contains("data:image/")
}
@Serializable
data class CryptoDto(
@SerialName("ct") var ct: String? = null,
@SerialName("iv") var iv: String? = null,
@SerialName("s") var s: String? = null,
)
}

View file

@ -0,0 +1,143 @@
package eu.kanade.tachiyomi.animeextension.es.katanime
import eu.kanade.tachiyomi.animesource.model.AnimeFilter
import eu.kanade.tachiyomi.animesource.model.AnimeFilterList
import java.util.Calendar
object KatanimeFilters {
open class QueryPartFilter(displayName: String, val vals: Array<Pair<String, String>>) : AnimeFilter.Select<String>(
displayName,
vals.map { it.first }.toTypedArray(),
) {
fun toQueryPart(name: String) = vals[state].second.takeIf { it.isNotEmpty() }?.let { "&$name=${vals[state].second}" } ?: run { "" }
}
open class CheckBoxFilterList(name: String, values: List<CheckBox>) : AnimeFilter.Group<AnimeFilter.CheckBox>(name, values)
private class CheckBoxVal(name: String, state: Boolean = false) : AnimeFilter.CheckBox(name, state)
private inline fun <reified R> AnimeFilterList.parseCheckbox(
options: Array<Pair<String, String>>,
name: String,
): String {
return (this.getFirst<R>() as CheckBoxFilterList).state
.mapNotNull { checkbox ->
if (checkbox.state) {
options.find { it.first == checkbox.name }!!.second
} else {
null
}
}.joinToString(",").let {
if (it.isBlank()) {
""
} else {
"&$name=$it"
}
}
}
private inline fun <reified R> AnimeFilterList.asQueryPart(name: String): String {
return (this.getFirst<R>() as QueryPartFilter).toQueryPart(name)
}
private inline fun <reified R> AnimeFilterList.getFirst(): R {
return this.filterIsInstance<R>().first()
}
private fun String.changePrefix() = this.takeIf { it.startsWith("&") }?.let { this.replaceFirst("&", "?") } ?: run { this }
data class FilterSearchParams(val filter: String = "") { fun getQuery() = filter.changePrefix() }
internal fun getSearchParameters(filters: AnimeFilterList): FilterSearchParams {
if (filters.isEmpty()) return FilterSearchParams()
return FilterSearchParams(
filters.asQueryPart<TypesFilter>("categoria") +
filters.asQueryPart<LanguageFilter>("idioma") +
filters.parseCheckbox<GenresFilter>(KatanimeFiltersData.GENRES, "genero") +
filters.asQueryPart<YearFilter>("fecha"),
)
}
val FILTER_LIST get() = AnimeFilterList(
AnimeFilter.Header("La busqueda por texto ignora el filtro"),
TypesFilter(),
LanguageFilter(),
GenresFilter(),
YearFilter(),
)
class TypesFilter : QueryPartFilter("Categoria", KatanimeFiltersData.TYPES)
class LanguageFilter : QueryPartFilter("Idioma", KatanimeFiltersData.LANGUAGE)
class GenresFilter : CheckBoxFilterList("Género", KatanimeFiltersData.GENRES.map { CheckBoxVal(it.first, false) })
class YearFilter : QueryPartFilter("Año", KatanimeFiltersData.YEARS)
private object KatanimeFiltersData {
val TYPES = arrayOf(
Pair("Todos", ""),
Pair("Anime", "anime"),
Pair("Ova", "ova"),
Pair("Película", "pelicula"),
Pair("Especial", "especial"),
Pair("Ona", "ona"),
Pair("Musical", "musical"),
)
val LANGUAGE = arrayOf(
Pair("Todos", ""),
Pair("Japones subtitulado", "Japones subtitulado"),
Pair("Audio latino", "Audio latino"),
)
val GENRES = arrayOf(
Pair("Acción", "accion"),
Pair("Aventura", "aventura"),
Pair("Coches", "coches"),
Pair("Comedia", "comedia"),
Pair("Avant Garde", "avant-garde"),
Pair("Demonios", "demonios"),
Pair("Misterio", "misterio"),
Pair("Drama", "drama"),
Pair("Ecchi", "ecchi"),
Pair("Fantasía", "fantasia"),
Pair("Juego", "juego"),
Pair("Hentai", "hentai"),
Pair("Histórico", "historico"),
Pair("Horror", "horror"),
Pair("Infantil", "Infantil"),
Pair("Magia", "magia"),
Pair("Artes Marciales", "artes-marciales"),
Pair("Mecha", "mecha"),
Pair("Música", "musica"),
Pair("Parodia", "parodia"),
Pair("Samurái", "samurai"),
Pair("Romance", "romance"),
Pair("Escolar", "escolar"),
Pair("Ciencia Ficción", "ciencia-ficcion"),
Pair("Shoujo", "shoujo"),
Pair("Yuri", "yuri"),
Pair("Shônen", "shonen"),
Pair("Yaoi", "yaoi"),
Pair("Espacial", "espacial"),
Pair("Deportes", "deportes"),
Pair("Superpoderes", "superpoderes"),
Pair("Vampiros", "vampiros"),
Pair("Criuoi", "criuoi"),
Pair("Yurii", "yurii"),
Pair("Harem", "harem"),
Pair("Recuentos de la vida", "recuentos-de-la-vida"),
Pair("Sobrenatural", "sobrenatural"),
Pair("Militar", "militar"),
Pair("Policía", "policia"),
Pair("Psicológico", "psicologico"),
Pair("Suspenso", "suspenso"),
Pair("Seinen", "seinen"),
Pair("Josei", "josei"),
Pair("Gore", "gore"),
)
val YEARS = arrayOf(Pair("Todos", "")) + (1982..Calendar.getInstance().get(Calendar.YEAR)).map { Pair("$it", "$it") }.reversed().toTypedArray()
}
}

View file

@ -0,0 +1,31 @@
package eu.kanade.tachiyomi.animeextension.es.katanime.extractors
import dev.datlag.jsunpacker.JsUnpacker
import eu.kanade.tachiyomi.animesource.model.Video
import eu.kanade.tachiyomi.lib.playlistutils.PlaylistUtils
import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.util.asJsoup
import okhttp3.Headers
import okhttp3.OkHttpClient
class UnpackerExtractor(private val client: OkHttpClient, private val headers: Headers) {
private val playlistUtils by lazy { PlaylistUtils(client, headers) }
fun videosFromUrl(url: String, quality: String = "LuluStream"): List<Video> {
val doc = client.newCall(GET(url, headers)).execute()
.asJsoup()
val script = doc.selectFirst("script:containsData(eval)")
?.data()
?.let(JsUnpacker::unpackAndCombine)
?: return emptyList()
val playlistUrl = script.substringAfter("file:\"").substringBefore('"')
return playlistUtils.extractFromHls(
playlistUrl,
referer = playlistUrl,
videoNameGen = { "$quality:$it" },
)
}
}