Skip to content

Commit

Permalink
Merge pull request #37 from Dark25/HomeCine
Browse files Browse the repository at this point in the history
feat(es/HomeCine) added genres in the filter
  • Loading branch information
Dark25 authored Aug 14, 2024
2 parents ce17d68 + bfd9188 commit 6f6515f
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/es/homecine/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ext {
extName = 'HomeCine'
extClass = '.HomeCine'
extVersionCode = 1
extVersionCode = 2
}

apply from: "$rootDir/common.gradle"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,12 @@ class HomeCine : ConfigurableAnimeSource, AnimeHttpSource() {
override fun searchAnimeRequest(page: Int, query: String, filters: AnimeFilterList): Request {
val filterList = if (filters.isEmpty()) getFilterList() else filters
val genreFilter = filterList.find { it is GenreFilter } as GenreFilter
val typeFilter = filterList.find { it is Type } as Type

return when {
query.isNotBlank() -> GET("$baseUrl/page/$page/?s=$query", headers)
genreFilter.state != 0 -> GET("$baseUrl/${genreFilter.toUriPart()}/page/$page", headers)
typeFilter.state != 0 -> GET("$baseUrl/${typeFilter.toUriPart()}/page/$page", headers)
else -> popularAnimeRequest(page)
}
}
Expand Down Expand Up @@ -173,18 +175,60 @@ class HomeCine : ConfigurableAnimeSource, AnimeHttpSource() {

override fun getFilterList(): AnimeFilterList = AnimeFilterList(
AnimeFilter.Header("La busqueda por texto ignora el filtro"),
Type(),
GenreFilter(),

)

private class GenreFilter : UriPartFilter(
"Género",
private class Type : UriPartFilter(
"Tipo",
arrayOf(
Pair("<Seleccionar>", ""),
Pair("Películas", "peliculas"),
Pair("Series", "series"),
),
)

private class GenreFilter : UriPartFilter(
"Género",
arrayOf(
Pair("<Seleccionar>", ""),
Pair("Acción", "genre/accion"),
Pair("Action & Adventure", "genre/action-adventure"),
Pair("Animación", "genre/animacion"),
Pair("Aventura", "genre/aventura"),
Pair("Bélica", "genre/belica"),
Pair("Ciencia Ficción", "genre/ciencia-ficcion"),
Pair("Comedia", "genre/comedia"),
Pair("Películas de Comedia", "genre/peliculas-de-comedia"),
Pair("Crimen", "genre/crimen"),
Pair("Documentales", "genre/documentales"),
Pair("Documental", "genre/documental"),
Pair("Drama", "genre/drama"),
Pair("Familia", "genre/familia"),
Pair("Fantasía", "genre/fantasia"),
Pair("Guerra", "genre/guerra"),
Pair("Historia", "genre/historia"),
Pair("Kids", "genre/kids"),
Pair("Misterio", "genre/misterio"),
Pair("Música", "genre/musica"),
Pair("News", "genre/news"),
Pair("Película de la Televisión", "genre/pelicula-de-la-television"),
Pair("Película de TV", "genre/pelicula-de-tv"),
Pair("Reality", "genre/reality"),
Pair("Romance", "genre/romance"),
Pair("Sci-Fi & Fantasy", "genre/sci-fi-fantasy"),
Pair("Soap", "genre/soap"),
Pair("Supervivencia", "genre/supervivencia"),
Pair("Suspense", "genre/suspense"),
Pair("Talk", "genre/talk"),
Pair("Terror", "genre/terror"),
Pair("Uncategorized", "genre/uncategorized"),
Pair("War & Politics", "genre/war-politics"),
Pair("Western", "genre/western"),
),
)

private open class UriPartFilter(displayName: String, val vals: Array<Pair<String, String>>) :
AnimeFilter.Select<String>(displayName, vals.map { it.first }.toTypedArray()) {
fun toUriPart() = vals[state].second
Expand Down

0 comments on commit 6f6515f

Please sign in to comment.