Skip to content

Commit

Permalink
Add Edens Fairy (#2530)
Browse files Browse the repository at this point in the history
* Add Edens Fairy

* Add type filter

* Fix message

* Change message

* Sort genres
  • Loading branch information
choppeh authored and cuong-tran committed Apr 23, 2024
1 parent 7d0bc1f commit 9cf3412
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/es/eflee/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
ext {
extName = 'Edens Fairy'
extClass = '.Eflee'
themePkg = 'zeistmanga'
baseUrl = 'https://www.eflee.co'
overrideVersionCode = 0
}

apply from: "$rootDir/common.gradle"
Binary file added src/es/eflee/res/mipmap-hdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/es/eflee/res/mipmap-mdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/es/eflee/res/mipmap-xhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/es/eflee/res/mipmap-xxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/es/eflee/res/mipmap-xxxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
79 changes: 79 additions & 0 deletions src/es/eflee/src/eu/kanade/tachiyomi/extension/es/eflee/Eflee.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package eu.kanade.tachiyomi.extension.es.eflee

import eu.kanade.tachiyomi.multisrc.zeistmanga.Genre
import eu.kanade.tachiyomi.multisrc.zeistmanga.GenreList
import eu.kanade.tachiyomi.multisrc.zeistmanga.Type
import eu.kanade.tachiyomi.multisrc.zeistmanga.ZeistManga
import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.source.model.Filter
import eu.kanade.tachiyomi.source.model.FilterList
import eu.kanade.tachiyomi.util.asJsoup
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import org.jsoup.nodes.Document

class Eflee : ZeistManga(
"Edens Fairy",
"https://www.eflee.co",
"es",
) {
override val popularMangaSelector = "#PopularPosts3 article"
override val popularMangaSelectorTitle = ".post-title a"
override val popularMangaSelectorUrl = popularMangaSelectorTitle

override val useNewChapterFeed = true
override val chapterCategory = "Cap"

override val hasFilters = true
override val hasLanguageFilter = false
override val hasGenreFilter = false
override val hasStatusFilter = false

private var genresList: List<Genre> = emptyList()
private var fetchGenresAttempts: Int = 0

override fun getFilterList(): FilterList {
CoroutineScope(Dispatchers.IO).launch { fetchGenres() }
val filters = super.getFilterList().list.toMutableList()
if (genresList.isNotEmpty()) {
filters += GenreList(
title = "Generos",
genres = genresList,
)
} else {
filters += listOf(
Filter.Separator(),
Filter.Header("Presione 'Restablecer' para intentar mostrar los géneros"),
)
}
return FilterList(filters)
}

override fun getTypeList(): List<Type> = listOf(
Type("Todos", ""),
Type("Manga", "Manga"),
Type("Manhua", "Manhua"),
Type("Manhwa", "Manhwa"),
)

private fun fetchGenres() {
if (fetchGenresAttempts < 3 && genresList.isEmpty()) {
try {
genresList = client.newCall(GET(baseUrl, headers)).execute()
.use { parseGenres(it.asJsoup()) }
.sortedBy { it.value }
} catch (_: Exception) {
} finally {
fetchGenresAttempts++
}
}
}

private fun parseGenres(document: Document): List<Genre> {
return document.select(".filters .filter:first-child input:not(.hidden)")
.map { element ->
Genre(element.attr("id"), element.attr("value"))
}
}
}

0 comments on commit 9cf3412

Please sign in to comment.