forked from aniyomiorg/aniyomi-extensions
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #68 from Dark25/MonosChinos
Fix(es/MonosChinos): Update source
- Loading branch information
Showing
9 changed files
with
367 additions
and
205 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
398 changes: 194 additions & 204 deletions
398
src/es/monoschinos/src/eu/kanade/tachiyomi/animeextension/es/monoschinos/MonosChinos.kt
Large diffs are not rendered by default.
Oops, something went wrong.
29 changes: 29 additions & 0 deletions
29
src/es/monoschinos/src/eu/kanade/tachiyomi/animeextension/es/monoschinos/MonosChinosDto.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package eu.kanade.tachiyomi.animeextension.es.monoschinos | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class EpisodesDto( | ||
@SerialName("paginate_url") var paginateUrl: String? = null, | ||
@SerialName("perpage") var perpage: Double? = null, | ||
@SerialName("eps") var eps: ArrayList<Eps> = arrayListOf(), | ||
) | ||
|
||
@Serializable | ||
data class Eps( | ||
@SerialName("num") var num: Int? = null, | ||
) | ||
|
||
@Serializable | ||
data class EpisodeInfoDto( | ||
@SerialName("default") var default: String? = null, | ||
@SerialName("caps") var caps: ArrayList<Caps> = arrayListOf(), | ||
) | ||
|
||
@Serializable | ||
data class Caps( | ||
@SerialName("episodio") var episodio: Int? = null, | ||
@SerialName("url") var url: String? = null, | ||
@SerialName("thumb") var thumb: String? = null, | ||
) |
139 changes: 139 additions & 0 deletions
139
...s/monoschinos/src/eu/kanade/tachiyomi/animeextension/es/monoschinos/MonosChinosFilters.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
package eu.kanade.tachiyomi.animeextension.es.monoschinos | ||
|
||
import eu.kanade.tachiyomi.animesource.model.AnimeFilter | ||
import eu.kanade.tachiyomi.animesource.model.AnimeFilterList | ||
import java.util.Calendar | ||
|
||
object MonosChinosFilters { | ||
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.parseCheckbox<GenresFilter>(DoramasytFiltersData.GENRES, "genero") + | ||
filters.parseCheckbox<TypesFilter>(DoramasytFiltersData.TYPES, "tipo") + | ||
filters.asQueryPart<YearsFilter>("fecha") + | ||
filters.asQueryPart<LettersFilter>("letra"), | ||
) | ||
} | ||
|
||
val FILTER_LIST get() = AnimeFilterList( | ||
AnimeFilter.Header("La busqueda por texto ignora el filtro"), | ||
GenresFilter(), | ||
TypesFilter(), | ||
YearsFilter(), | ||
LettersFilter(), | ||
) | ||
|
||
class GenresFilter : CheckBoxFilterList("Género", DoramasytFiltersData.GENRES.map { CheckBoxVal(it.first, false) }) | ||
|
||
class TypesFilter : CheckBoxFilterList("Tipo", DoramasytFiltersData.TYPES.map { CheckBoxVal(it.first, false) }) | ||
|
||
class YearsFilter : QueryPartFilter("Año", DoramasytFiltersData.YEARS) | ||
|
||
class LettersFilter : QueryPartFilter("Letra", DoramasytFiltersData.LETTER) | ||
|
||
private object DoramasytFiltersData { | ||
val TYPES = arrayOf( | ||
Pair("<Selecionar>", ""), | ||
Pair("Pelicula", "pelicula"), | ||
Pair("Anime", "anime"), | ||
) | ||
|
||
val YEARS = arrayOf(Pair("<Seleccionar>", "")) + (1982..Calendar.getInstance().get(Calendar.YEAR)).map { Pair("$it", "$it") }.reversed().toTypedArray() | ||
|
||
val LETTER = arrayOf(Pair("<Seleccionar>", "")) + ('A'..'Z').map { Pair("$it", "$it") }.toTypedArray() | ||
|
||
val GENRES = arrayOf( | ||
Pair("<Selecionar>", ""), | ||
Pair("Acción", "accion"), | ||
Pair("Aventura", "aventura"), | ||
Pair("Carreras", "carreras"), | ||
Pair("Ciencia Ficción", "ciencia-ficcion"), | ||
Pair("Comedia", "comedia"), | ||
Pair("Cyberpunk", "cyberpunk"), | ||
Pair("Deportes", "deportes"), | ||
Pair("Drama", "drama"), | ||
Pair("Ecchi", "ecchi"), | ||
Pair("Escolares", "escolares"), | ||
Pair("Fantasía", "fantasia"), | ||
Pair("Gore", "gore"), | ||
Pair("Harem", "harem"), | ||
Pair("Horror", "horror"), | ||
Pair("Josei", "josei"), | ||
Pair("Lucha", "lucha"), | ||
Pair("Magia", "magia"), | ||
Pair("Mecha", "mecha"), | ||
Pair("Militar", "militar"), | ||
Pair("Misterio", "misterio"), | ||
Pair("Música", "musica"), | ||
Pair("Parodias", "parodias"), | ||
Pair("Psicológico", "psicologico"), | ||
Pair("Recuerdos de la vida", "recuerdos-de-la-vida"), | ||
Pair("Seinen", "seinen"), | ||
Pair("Shojo", "shojo"), | ||
Pair("Shonen", "shonen"), | ||
Pair("Sobrenatural", "sobrenatural"), | ||
Pair("Vampiros", "vampiros"), | ||
Pair("Yaoi", "yaoi"), | ||
Pair("Yuri", "yuri"), | ||
Pair("Latino", "latino"), | ||
Pair("Espacial", "espacial"), | ||
Pair("Histórico", "historico"), | ||
Pair("Samurai", "samurai"), | ||
Pair("Artes Marciales", "artes-marciales"), | ||
Pair("Demonios", "demonios"), | ||
Pair("Romance", "romance"), | ||
Pair("Dementia", "dementia"), | ||
Pair(" Policía", "policia"), | ||
Pair("Castellano", "castellano"), | ||
Pair("Historia paralela", "historia-paralela"), | ||
Pair("Aenime", "aenime"), | ||
Pair("Blu-ray", "blu-ray"), | ||
Pair("Monogatari", "monogatari"), | ||
) | ||
} | ||
} |