Skip to content

Commit 123af26

Browse files
committed
Minor refactors
1 parent b0325ba commit 123af26

File tree

2 files changed

+41
-46
lines changed

2 files changed

+41
-46
lines changed

src/es/verpelistop/src/eu/kanade/tachiyomi/animeextension/es/verpelistop/HexloadExtractor.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ class HexloadExtractor(private val client: OkHttpClient, private val headers: He
1818
val id = idRegex.find(url)?.groupValues?.getOrNull(1) ?: return emptyList()
1919

2020
val formBody = FormBody.Builder()
21-
.add("MIME Type", "application/x-www-form-urlencoded; charset=UTF-8")
2221
.add("op", "download3")
2322
.add("id", id)
2423
.add("ajax", "1")
@@ -57,7 +56,7 @@ class HexloadExtractor(private val client: OkHttpClient, private val headers: He
5756
val md5: String?, // "VPHYYxNMLxKIxBZWE9hl+A",
5857
val thumb_url: String?, // "https://46ev7agtixoi.droply.top/i/01264/pbv78rlcsagr_t.jpg",
5958
val content_type: String?, // "video/mp4",
60-
val size: Long, // "3065200640",
59+
val size: Long, // 3065200640"
6160
val image_url: String?, // "https://46ev7agtixoi.droply.top/i/01264/pbv78rlcsagr.jpg",
6261
val folder: String?, // null,
6362
val file_name: String?, // "Avatar Fuego y ceniza LAT.mp4"

src/es/verpelistop/src/eu/kanade/tachiyomi/animeextension/es/verpelistop/VerPelisTop.kt

Lines changed: 40 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class VerPelisTop :
6262
override fun animeDetailsParse(document: Document): SAnime {
6363
val doc = getRealAnimeDoc(document)
6464
val sheader = doc.selectFirst("div.sheader")!!
65-
val genres = GenreFilter().getGenreList().map { it.first }
65+
val genres = GENRE_LIST.map { it.first }
6666
return SAnime.create().apply {
6767
setUrlWithoutDomain(doc.location())
6868
sheader.selectFirst("div.poster > img")!!.let {
@@ -113,10 +113,10 @@ class VerPelisTop :
113113
val frameDoc = client.newCall(GET(iframeSource)).awaitSuccess().useAsJsoup()
114114

115115
return frameDoc.select(".OD li[onclick]")
116-
.map {
117-
val server = it.select("span").text()
118-
val lang = it.select("p").text().substringBefore("-").trim()
119-
val url = it.attr("onclick").substringAfter("('").substringBefore("')")
116+
.map { hoster ->
117+
val server = hoster.select("span").text()
118+
val lang = hoster.select("p").text().substringBefore("-").trim()
119+
val url = hoster.attr("onclick").substringAfter("('").substringBefore("')")
120120
val matched = conventions.firstOrNull { (_, names) -> names.any { it.lowercase() in url.lowercase() } }?.first
121121
Pair(url, matched) to Pair(lang, server)
122122
}
@@ -162,49 +162,14 @@ class VerPelisTop :
162162
override val fetchGenres = false
163163

164164
override fun getFilterList(): AnimeFilterList = AnimeFilterList(
165-
AnimeFilter.Header("La búsqueda por texto ignora el filtro de año"),
165+
AnimeFilter.Header("La búsqueda por texto ignora el filtro de género"),
166166
GenreFilter(),
167167
)
168168

169-
private class GenreFilter :
170-
UriPartFilter(
171-
"Géneros",
172-
arrayOf(
173-
Pair("<seleccionar>", ""),
174-
Pair("accion", "genero/accion"),
175-
Pair("amazon prime", "genero/amazon-prime"),
176-
Pair("animacion", "genero/animacion"),
177-
Pair("aventura", "genero/aventura"),
178-
Pair("biografia", "genero/biografia"),
179-
Pair("ciencia ficcion", "genero/ciencia-ficcion"),
180-
Pair("comedia", "genero/comedia"),
181-
Pair("corto", "genero/corto"),
182-
Pair("crimen", "genero/crimen"),
183-
Pair("deporte", "genero/deporte"),
184-
Pair("disney", "genero/disney"),
185-
Pair("documentales", "genero/documentales"),
186-
Pair("drama", "genero/drama"),
187-
Pair("familia", "genero/familia"),
188-
Pair("fantasia", "genero/fantasia"),
189-
Pair("hbo", "genero/hbo"),
190-
Pair("historia", "genero/historia"),
191-
Pair("horror", "genero/horror"),
192-
Pair("marvel", "genero/marvel"),
193-
Pair("misterio", "genero/misterio"),
194-
Pair("musica", "genero/musica"),
195-
Pair("netflix", "genero/netflix"),
196-
Pair("reality", "genero/reality"),
197-
Pair("romance", "genero/romance"),
198-
Pair("suspenso", "genero/suspenso"),
199-
Pair("terror", "genero/terror"),
200-
Pair("thriller", "genero/thriller"),
201-
),
202-
)
169+
private class GenreFilter : UriPartFilter("Géneros", GENRE_LIST)
203170

204171
open class UriPartFilter(displayName: String, val vals: Array<Pair<String, String>>) : AnimeFilter.Select<String>(displayName, vals.map { it.first }.toTypedArray()) {
205172
fun toUriPart() = vals[state].second
206-
207-
fun getGenreList() = vals
208173
}
209174

210175
override fun searchAnimeRequest(page: Int, query: String, filters: AnimeFilterList): Request {
@@ -255,7 +220,7 @@ class VerPelisTop :
255220
private fun String.redirectHgCloudHgLink(): String {
256221
return hgCloudLinkDomains.firstOrNull(::contains)?.let {
257222
val redirectingDomain = hgCloudLinkRedirected.random()
258-
return replace(it, redirectingDomain)
223+
replace(it, redirectingDomain)
259224
} ?: this
260225
}
261226

@@ -272,7 +237,7 @@ class VerPelisTop :
272237
val server = preferences.getString(PREF_SERVER_KEY, PREF_SERVER_DEFAULT)!!
273238
return sortedWith(
274239
compareBy(
275-
{ it.quality.contains(lang) },
240+
{ it.quality.contains(lang, true) },
276241
{ it.quality.contains(server, true) },
277242
{ it.quality.contains(quality) },
278243
),
@@ -290,5 +255,36 @@ class VerPelisTop :
290255
private val PREF_LANG_ENTRIES = arrayOf("Sub", "Latino", "Castellano")
291256
private val SERVER_LIST = arrayOf("VidHide", "StreamTape", "Uqload", "HexLoad", "StreamWish", "FileMoon")
292257
private val PREF_SERVER_DEFAULT = SERVER_LIST.first()
258+
259+
val GENRE_LIST = arrayOf(
260+
Pair("<seleccionar>", ""),
261+
Pair("accion", "genero/accion"),
262+
Pair("amazon prime", "genero/amazon-prime"),
263+
Pair("animacion", "genero/animacion"),
264+
Pair("aventura", "genero/aventura"),
265+
Pair("biografia", "genero/biografia"),
266+
Pair("ciencia ficcion", "genero/ciencia-ficcion"),
267+
Pair("comedia", "genero/comedia"),
268+
Pair("corto", "genero/corto"),
269+
Pair("crimen", "genero/crimen"),
270+
Pair("deporte", "genero/deporte"),
271+
Pair("disney", "genero/disney"),
272+
Pair("documentales", "genero/documentales"),
273+
Pair("drama", "genero/drama"),
274+
Pair("familia", "genero/familia"),
275+
Pair("fantasia", "genero/fantasia"),
276+
Pair("hbo", "genero/hbo"),
277+
Pair("historia", "genero/historia"),
278+
Pair("horror", "genero/horror"),
279+
Pair("marvel", "genero/marvel"),
280+
Pair("misterio", "genero/misterio"),
281+
Pair("musica", "genero/musica"),
282+
Pair("netflix", "genero/netflix"),
283+
Pair("reality", "genero/reality"),
284+
Pair("romance", "genero/romance"),
285+
Pair("suspenso", "genero/suspenso"),
286+
Pair("terror", "genero/terror"),
287+
Pair("thriller", "genero/thriller"),
288+
)
293289
}
294290
}

0 commit comments

Comments
 (0)