Merged with dark25 (#636)
* merge merged lib, lib-multisrc, all, ar, de, en, es, fr, hi, id, it, pt, tr src from dark25 * patch
This commit is contained in:
parent
9f385108fc
commit
1384df62f3
350 changed files with 12176 additions and 1064 deletions
16
src/es/zeroanime/build.gradle
Normal file
16
src/es/zeroanime/build.gradle
Normal file
|
@ -0,0 +1,16 @@
|
|||
ext {
|
||||
extName = 'zeroanime'
|
||||
extClass = '.Zeroanime'
|
||||
extVersionCode = 2
|
||||
}
|
||||
|
||||
apply from: "$rootDir/common.gradle"
|
||||
|
||||
dependencies {
|
||||
implementation(project(':lib:universal-extractor'))
|
||||
implementation(project(':lib:streamvid-extractor'))
|
||||
implementation(project(':lib:streamtape-extractor'))
|
||||
implementation(project(':lib:filemoon-extractor'))
|
||||
implementation(project(':lib:mp4upload-extractor'))
|
||||
|
||||
}
|
BIN
src/es/zeroanime/res/mipmap-hdpi/ic_launcher.png
Normal file
BIN
src/es/zeroanime/res/mipmap-hdpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6 KiB |
BIN
src/es/zeroanime/res/mipmap-mdpi/ic_launcher.png
Normal file
BIN
src/es/zeroanime/res/mipmap-mdpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.6 KiB |
BIN
src/es/zeroanime/res/mipmap-xhdpi/ic_launcher.png
Normal file
BIN
src/es/zeroanime/res/mipmap-xhdpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9 KiB |
BIN
src/es/zeroanime/res/mipmap-xxhdpi/ic_launcher.png
Normal file
BIN
src/es/zeroanime/res/mipmap-xxhdpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 15 KiB |
BIN
src/es/zeroanime/res/mipmap-xxxhdpi/ic_launcher.png
Normal file
BIN
src/es/zeroanime/res/mipmap-xxxhdpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 23 KiB |
|
@ -0,0 +1,148 @@
|
|||
package eu.kanade.tachiyomi.animeextension.es.zeroanime
|
||||
|
||||
import eu.kanade.tachiyomi.animesource.model.AnimeFilter
|
||||
import eu.kanade.tachiyomi.animesource.model.AnimeFilter.CheckBox
|
||||
import eu.kanade.tachiyomi.animesource.model.AnimeFilterList
|
||||
import java.util.Calendar
|
||||
|
||||
object ZeroAnimeFilters {
|
||||
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<CheckBox>(name, values)
|
||||
|
||||
private class CheckBoxVal(name: String, state: Boolean = false) : 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("&$name[]=").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() }
|
||||
|
||||
private fun Array<Pair<String, String>>.toCheckBoxVal(): List<CheckBox> = map { CheckBoxVal(it.first, false) }
|
||||
|
||||
private fun String.addSuffix(): String = takeIf { it.isNotBlank() } ?: this
|
||||
|
||||
internal fun getSearchParameters(filters: AnimeFilterList, origen: ZeroAnimeFiltersData.ORIGEN): FilterSearchParams {
|
||||
if (filters.isEmpty()) return FilterSearchParams()
|
||||
|
||||
val strFilter = buildString {
|
||||
when (origen) {
|
||||
ZeroAnimeFiltersData.ORIGEN.ANIME -> {
|
||||
append(filters.parseCheckbox<AnimeGenresFilter>(ZeroAnimeFiltersData.ANIME_GENRES, "genero"))
|
||||
append(filters.asQueryPart<YearsFilter>("years").addSuffix())
|
||||
append(filters.asQueryPart<StatesFilter>("estado"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return FilterSearchParams(strFilter)
|
||||
}
|
||||
|
||||
private val ANIME_FILTER_LIST get() = AnimeFilterList(
|
||||
AnimeFilter.Header("La busqueda por texto ignora el filtro"),
|
||||
AnimeGenresFilter(),
|
||||
YearsFilter(),
|
||||
StatesFilter(),
|
||||
)
|
||||
|
||||
fun getFilterList(origen: ZeroAnimeFiltersData.ORIGEN) = when (origen) {
|
||||
ZeroAnimeFiltersData.ORIGEN.ANIME -> ANIME_FILTER_LIST
|
||||
}
|
||||
|
||||
class AnimeGenresFilter : CheckBoxFilterList("Género", ZeroAnimeFiltersData.ANIME_GENRES.toCheckBoxVal())
|
||||
|
||||
class YearsFilter : QueryPartFilter("Año", ZeroAnimeFiltersData.YEARS)
|
||||
|
||||
class StatesFilter : QueryPartFilter("Estado", ZeroAnimeFiltersData.STATES)
|
||||
|
||||
object ZeroAnimeFiltersData {
|
||||
val YEARS = arrayOf(Pair("Todos", "ALL")) + (1950..Calendar.getInstance().get(Calendar.YEAR)).map { Pair("$it", "$it") }.reversed().toTypedArray()
|
||||
val ANIME_GENRES = arrayOf(
|
||||
Pair("Todos los generos", "ALL"),
|
||||
Pair("Acción", "5"),
|
||||
Pair("Artes marciales", "4"),
|
||||
Pair("Aventuras", "24"),
|
||||
Pair("Carreras", "6"),
|
||||
Pair("Ciencia ficción", "27"),
|
||||
Pair("Comedia", "7"),
|
||||
Pair("Demencia", "9"),
|
||||
Pair("Demonios", "41"),
|
||||
Pair("Deportes", "10"),
|
||||
Pair("Drama", "11"),
|
||||
Pair("Ecchi", "12"),
|
||||
Pair("Escolar", "13"),
|
||||
Pair("Espacial", "14"),
|
||||
Pair("Fantasía", "8"),
|
||||
Pair("Gore", "37"),
|
||||
Pair("Harem", "15"),
|
||||
Pair("Historico", "16"),
|
||||
Pair("Horror", "30"),
|
||||
Pair("Infantil", "17"),
|
||||
Pair("Isekai", "29"),
|
||||
Pair("Josei", "18"),
|
||||
Pair("Juegos", "19"),
|
||||
Pair("Magia", "20"),
|
||||
Pair("Mecha", "21"),
|
||||
Pair("Militar", "32"),
|
||||
Pair("Música", "38"),
|
||||
Pair("Parodia", "33"),
|
||||
Pair("Psicológico", "39"),
|
||||
Pair("Recuerdos de la vida", "42"),
|
||||
Pair("Romance", "1"),
|
||||
Pair("Samurai", "36"),
|
||||
Pair("Sci-Fi", "28"),
|
||||
Pair("Seinen", "3"),
|
||||
Pair("Shoujo", "34"),
|
||||
Pair("Shounen", "2"),
|
||||
Pair("Sobre Natural", "25"),
|
||||
Pair("SuperPoderes", "26"),
|
||||
Pair("Suspenso", "23"),
|
||||
Pair("Terror", "22"),
|
||||
Pair("Vampiros", "40"),
|
||||
Pair("Yaoi", "43"),
|
||||
Pair("Yuri", "35"),
|
||||
Pair("Zombies", "31"),
|
||||
)
|
||||
|
||||
val STATES = arrayOf(
|
||||
Pair("Todos", "2"),
|
||||
Pair("En emisión", "1"),
|
||||
Pair("Finalizado", "0"),
|
||||
)
|
||||
|
||||
enum class ORIGEN {
|
||||
ANIME,
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,275 @@
|
|||
package eu.kanade.tachiyomi.animeextension.es.zeroanime
|
||||
|
||||
import android.app.Application
|
||||
import android.content.SharedPreferences
|
||||
import android.util.Log
|
||||
import androidx.preference.ListPreference
|
||||
import androidx.preference.PreferenceScreen
|
||||
import eu.kanade.tachiyomi.animesource.ConfigurableAnimeSource
|
||||
import eu.kanade.tachiyomi.animesource.model.AnimeFilterList
|
||||
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.ParsedAnimeHttpSource
|
||||
import eu.kanade.tachiyomi.lib.filemoonextractor.FilemoonExtractor
|
||||
import eu.kanade.tachiyomi.lib.mp4uploadextractor.Mp4uploadExtractor
|
||||
import eu.kanade.tachiyomi.lib.streamtapeextractor.StreamTapeExtractor
|
||||
import eu.kanade.tachiyomi.lib.streamvidextractor.StreamVidExtractor
|
||||
import eu.kanade.tachiyomi.lib.universalextractor.UniversalExtractor
|
||||
import eu.kanade.tachiyomi.network.GET
|
||||
import eu.kanade.tachiyomi.util.asJsoup
|
||||
import okhttp3.Request
|
||||
import okhttp3.Response
|
||||
import org.jsoup.Jsoup
|
||||
import org.jsoup.nodes.Document
|
||||
import org.jsoup.nodes.Element
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
|
||||
class Zeroanime : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
||||
|
||||
override val name = "zeroanime"
|
||||
|
||||
override val baseUrl = "https://www4.zeroanime.xyz"
|
||||
|
||||
override val lang = "es"
|
||||
|
||||
override val supportsLatest = false
|
||||
|
||||
private val preferences: SharedPreferences by lazy {
|
||||
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
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 = "mp4upload"
|
||||
private val SERVER_LIST = arrayOf(
|
||||
"filemoon",
|
||||
"mp4upload",
|
||||
"streamtape",
|
||||
"streamvid",
|
||||
)
|
||||
}
|
||||
|
||||
override fun popularAnimeSelector(): String = "ul.animes.list-unstyled.row li.col-6.col-sm-4.col-md-3.col-xl-2"
|
||||
|
||||
override fun popularAnimeRequest(page: Int): Request = GET("$baseUrl/search?q=&letra=&genero=ALL&years=ALL&estado=2&orden=desc&p=$page")
|
||||
|
||||
override fun popularAnimeFromElement(element: Element): SAnime {
|
||||
return SAnime.create().apply {
|
||||
url = element.select("a").attr("href")
|
||||
title = element.select("div.title").text()
|
||||
thumbnail_url = element.select("div.thumb img").attr("src")
|
||||
}
|
||||
}
|
||||
|
||||
override fun popularAnimeNextPageSelector(): String {
|
||||
return "ul.pagination li.page-item:not(.active) a"
|
||||
}
|
||||
|
||||
override fun episodeListParse(response: Response): List<SEpisode> {
|
||||
val document = response.asJsoup()
|
||||
val episodes = mutableListOf<SEpisode>()
|
||||
|
||||
document.select("li.hentai__chapter").forEach { element ->
|
||||
val episode = SEpisode.create().apply {
|
||||
name = element.select("div.chapter_info span.title").text()
|
||||
url = element.select("a").attr("href")
|
||||
episode_number = name.substringAfter("Episodio ").toFloatOrNull() ?: 0F
|
||||
setUrlWithoutDomain(url)
|
||||
}
|
||||
episodes.add(episode)
|
||||
}
|
||||
|
||||
return episodes.sortedByDescending { it.episode_number }
|
||||
}
|
||||
|
||||
override fun episodeListSelector() = throw UnsupportedOperationException()
|
||||
|
||||
override fun episodeFromElement(element: Element) = throw UnsupportedOperationException()
|
||||
|
||||
/*--------------------------------Video extractors------------------------------------*/
|
||||
private val universalExtractor by lazy { UniversalExtractor(client) }
|
||||
private val streamtapeExtractor by lazy { StreamTapeExtractor(client) }
|
||||
private val fileMoonExtractor by lazy { FilemoonExtractor(client) }
|
||||
private val mp4UploadExtractor by lazy { Mp4uploadExtractor(client) }
|
||||
|
||||
override fun videoListParse(response: Response): List<Video> {
|
||||
val document = Jsoup.parse(response.body?.string() ?: "")
|
||||
val videoList = mutableListOf<Video>()
|
||||
|
||||
// Elimina espacios innecesarios del contenido HTML
|
||||
val data = document.html().replace(Regex("""\n|\r|\t|\s{2}| """), "")
|
||||
|
||||
// Coincide con los botones que contienen los enlaces a los videos
|
||||
val matches = Regex("""<button id="embed-.*?data-url="(.*?)".*?->(.*?)</button>""").findAll(data)
|
||||
|
||||
matches.forEach { match ->
|
||||
val (url, srv) = match.destructured
|
||||
var videoUrl = url.trim()
|
||||
|
||||
// Convertir URL relativa en absoluta
|
||||
if (videoUrl.startsWith("../redirect.php?")) {
|
||||
videoUrl = "$baseUrl${videoUrl.replace("../redirect.php?", "/redirect.php?")}"
|
||||
}
|
||||
|
||||
// Solicitud a la URL para obtener la redirección
|
||||
val redirectResponse = client.newCall(Request.Builder().url(videoUrl).build()).execute()
|
||||
val refreshHeader = redirectResponse.header("refresh")
|
||||
val finalUrl = refreshHeader?.let {
|
||||
Regex("""0;\s*URL=(.*?)$""").find(it)?.groupValues?.get(1)
|
||||
} ?: Regex("""url=(.*?)$""").find(videoUrl)?.groupValues?.get(1)
|
||||
|
||||
finalUrl?.let { processedUrl ->
|
||||
var resolvedUrl = processedUrl
|
||||
|
||||
// Procesar enlaces de video internos
|
||||
if (resolvedUrl.startsWith("../video/")) {
|
||||
resolvedUrl = "$baseUrl${resolvedUrl.replace("../video/", "/video/")}"
|
||||
}
|
||||
|
||||
val response = client.newCall(Request.Builder().url(resolvedUrl).build()).execute()
|
||||
val refreshUrl = response.header("refresh")?.let {
|
||||
Regex("""0;\s*URL=(.*?)$""").find(it)?.groupValues?.get(1)
|
||||
}
|
||||
|
||||
Log.d("Zeroanime", "URL extraída del refresh: $refreshUrl")
|
||||
|
||||
// Resolver el servidor y agregar la lista de videos
|
||||
refreshUrl?.let { serverVideoResolver(it, srv) }?.let { videoList.addAll(it) }
|
||||
}
|
||||
}
|
||||
|
||||
return videoList.sort()
|
||||
}
|
||||
|
||||
private fun serverVideoResolver(url: String, server: String): List<Video> {
|
||||
val videoList = mutableListOf<Video>()
|
||||
val embedUrl = url.lowercase()
|
||||
Log.d("Zeroanime", "Server: $embedUrl")
|
||||
return try {
|
||||
when {
|
||||
embedUrl.contains("streamtape") -> {
|
||||
streamtapeExtractor.videosFromUrl(url).also { videoList.addAll(it) }
|
||||
}
|
||||
embedUrl.contains("filemoon") -> {
|
||||
fileMoonExtractor.videosFromUrl(url).also { videoList.addAll(it) }
|
||||
}
|
||||
embedUrl.contains("mp4upload") -> {
|
||||
mp4UploadExtractor.videosFromUrl(url, headers).also { videoList.addAll(it) }
|
||||
}
|
||||
embedUrl.contains("streamvid") -> {
|
||||
StreamVidExtractor(client).videosFromUrl(url).also { videoList.addAll(it) }
|
||||
}
|
||||
|
||||
else -> {
|
||||
universalExtractor.videosFromUrl(url, headers).also { videoList.addAll(it) }
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log.e("Zeroanime", "Error: Server not supported - ${e.message}")
|
||||
emptyList()
|
||||
}
|
||||
}
|
||||
|
||||
override fun videoListSelector() = throw UnsupportedOperationException()
|
||||
|
||||
override fun videoUrlParse(document: Document) = throw UnsupportedOperationException()
|
||||
|
||||
override fun videoFromElement(element: Element) = throw UnsupportedOperationException()
|
||||
|
||||
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 searchAnimeRequest(page: Int, query: String, filters: AnimeFilterList): Request {
|
||||
val params = ZeroAnimeFilters.getSearchParameters(filters, ZeroAnimeFilters.ZeroAnimeFiltersData.ORIGEN.ANIME)
|
||||
|
||||
return when {
|
||||
query.isNotBlank() -> GET("$baseUrl/search?q=$query&p=$page", headers)
|
||||
params.filter.isNotBlank() -> GET("$baseUrl/search${params.getQuery()}&p=$page")
|
||||
else -> popularAnimeRequest(page)
|
||||
}
|
||||
}
|
||||
|
||||
override fun searchAnimeFromElement(element: Element): SAnime = popularAnimeFromElement(element)
|
||||
|
||||
override fun searchAnimeNextPageSelector(): String = popularAnimeNextPageSelector()
|
||||
|
||||
override fun searchAnimeSelector(): String = popularAnimeSelector()
|
||||
|
||||
override fun animeDetailsParse(document: Document): SAnime {
|
||||
return SAnime.create().apply {
|
||||
title = document.select("h1.htitle").text()
|
||||
description = document.select("div.vraven_text.single").text()
|
||||
genre = document.select("div.single_data div.list a").joinToString { it.text() }
|
||||
thumbnail_url = document.select("div.hentai_cover img").attr("abs:src")
|
||||
status = parseStatus(document.select("div.data").text())
|
||||
}
|
||||
}
|
||||
|
||||
private fun parseStatus(statusString: String): Int {
|
||||
return when {
|
||||
statusString.contains("Emisión", ignoreCase = true) -> SAnime.ONGOING
|
||||
statusString.contains("Finalizado", ignoreCase = true) -> SAnime.COMPLETED
|
||||
else -> SAnime.UNKNOWN
|
||||
}
|
||||
}
|
||||
|
||||
override fun latestUpdatesNextPageSelector() = popularAnimeNextPageSelector()
|
||||
|
||||
override fun latestUpdatesFromElement(element: Element): SAnime = popularAnimeFromElement(element)
|
||||
|
||||
override fun latestUpdatesRequest(page: Int) = GET("$baseUrl/search?q=&letra=ALL&genero=ALL&years=2024&estado=2&orden=asc&p=$page")
|
||||
|
||||
override fun latestUpdatesSelector() = popularAnimeSelector()
|
||||
|
||||
override fun getFilterList(): AnimeFilterList = ZeroAnimeFilters.getFilterList(ZeroAnimeFilters.ZeroAnimeFiltersData.ORIGEN.ANIME)
|
||||
|
||||
override fun setupPreferenceScreen(screen: PreferenceScreen) {
|
||||
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)
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue