diff --git a/src/en/hentaifox/build.gradle b/src/en/hentaifox/build.gradle new file mode 100644 index 000000000..864440fcf --- /dev/null +++ b/src/en/hentaifox/build.gradle @@ -0,0 +1,12 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' + +ext { + appName = 'Tachiyomi: HentaiFox' + pkgNameSuffix = 'en.hentaifox' + extClass = '.HentaiFox' + extVersionCode = 1 + libVersion = '1.2' +} + +apply from: "$rootDir/common.gradle" diff --git a/src/en/hentaifox/res/mipmap-hdpi/ic_launcher.png b/src/en/hentaifox/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 000000000..1514ae044 Binary files /dev/null and b/src/en/hentaifox/res/mipmap-hdpi/ic_launcher.png differ diff --git a/src/en/hentaifox/res/mipmap-mdpi/ic_launcher.png b/src/en/hentaifox/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 000000000..691dc5d19 Binary files /dev/null and b/src/en/hentaifox/res/mipmap-mdpi/ic_launcher.png differ diff --git a/src/en/hentaifox/res/mipmap-xhdpi/ic_launcher.png b/src/en/hentaifox/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 000000000..e909daf35 Binary files /dev/null and b/src/en/hentaifox/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/src/en/hentaifox/res/mipmap-xxhdpi/ic_launcher.png b/src/en/hentaifox/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 000000000..95a9109be Binary files /dev/null and b/src/en/hentaifox/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/src/en/hentaifox/res/mipmap-xxxhdpi/ic_launcher.png b/src/en/hentaifox/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 000000000..a17b2d047 Binary files /dev/null and b/src/en/hentaifox/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/src/en/hentaifox/res/web_hi_res_512.png b/src/en/hentaifox/res/web_hi_res_512.png new file mode 100644 index 000000000..16b468882 Binary files /dev/null and b/src/en/hentaifox/res/web_hi_res_512.png differ diff --git a/src/en/hentaifox/src/eu/kanade/tachiyomi/extension/en/hentaifox/HentaiFox.kt b/src/en/hentaifox/src/eu/kanade/tachiyomi/extension/en/hentaifox/HentaiFox.kt new file mode 100644 index 000000000..52581b914 --- /dev/null +++ b/src/en/hentaifox/src/eu/kanade/tachiyomi/extension/en/hentaifox/HentaiFox.kt @@ -0,0 +1,201 @@ +package eu.kanade.tachiyomi.extension.en.hentaifox + +import eu.kanade.tachiyomi.network.GET +import eu.kanade.tachiyomi.source.model.* +import eu.kanade.tachiyomi.source.online.ParsedHttpSource +import eu.kanade.tachiyomi.util.asJsoup +import okhttp3.OkHttpClient +import okhttp3.Request +import okhttp3.Response +import org.jsoup.nodes.Document +import org.jsoup.nodes.Element +import rx.Observable + +class HentaiFox : ParsedHttpSource() { + + override val name = "HentaiFox" + + override val baseUrl = "https://hentaifox.com" + + override val lang = "en" + + override val supportsLatest = false + + override val client: OkHttpClient = network.cloudflareClient + + // Popular + + override fun popularMangaRequest(page: Int): Request { + return GET("$baseUrl/pag/$page/", headers) + } + + override fun popularMangaSelector() = "div.thumb" + + override fun popularMangaFromElement(element: Element): SManga { + return SManga.create().apply { + element.select("h2 a").let { + title = it.text() + setUrlWithoutDomain(it.attr("href")) + } + thumbnail_url = element.select("img").first().attr("abs:src") + } + } + + override fun popularMangaNextPageSelector() = "li.page-item:last-of-type:not(.disabled)" + + // Latest + + override fun latestUpdatesRequest(page: Int): Request = throw UnsupportedOperationException("Not used") + + override fun latestUpdatesParse(response: Response): MangasPage = throw UnsupportedOperationException("Not used") + + override fun latestUpdatesSelector() = throw UnsupportedOperationException("Not used") + + override fun latestUpdatesFromElement(element: Element): SManga = throw UnsupportedOperationException("Not used") + + override fun latestUpdatesNextPageSelector() = throw UnsupportedOperationException("Not used") + + // Search + + override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request { + return if (query.isNotEmpty()) { + GET("$baseUrl/search/?q=$query&page=$page", headers) + } else { + var url = "$baseUrl/tag/" + + filters.forEach { filter -> + when (filter) { + is GenreFilter -> { + url += "${filter.toUriPart()}/" + } + } + } + GET(url, headers) + } + } + + override fun searchMangaSelector() = popularMangaSelector() + + override fun searchMangaFromElement(element: Element): SManga = popularMangaFromElement(element) + + override fun searchMangaNextPageSelector() = popularMangaNextPageSelector() + + // Details + + override fun mangaDetailsParse(document: Document): SManga { + return document.select("div.gallery_top").let { info -> + SManga.create().apply { + title = info.select("h1").text() + genre = info.select("ul.tags a").joinToString { it.ownText() } + artist = info.select("ul.artists a").joinToString { it.ownText() } + thumbnail_url = info.select("img").attr("abs:src") + description = info.select("ul.parodies a") + .let { e -> if (e.isNotEmpty()) "Parodies: ${e.joinToString { it.ownText() }}\n\n" else "" } + description += info.select("ul.characters a") + .let { e -> if (e.isNotEmpty()) "Characters: ${e.joinToString { it.ownText() }}\n\n" else "" } + description += info.select("ul.groups a") + .let { e -> if (e.isNotEmpty()) "Groups: ${e.joinToString { it.ownText() }}\n\n" else "" } + } + } + } + + // Chapters + + override fun chapterListParse(response: Response): List { + return listOf(SChapter.create().apply { + name = "Chapter" + // page path with a marker at the end + url = "${response.request().url().toString().replace("/gallery/", "/g/")}#" + // number of pages + url+= response.asJsoup().select("[id=load_pages]").attr("value") + }) + } + + override fun chapterListSelector() = throw UnsupportedOperationException("Not used") + + override fun chapterFromElement(element: Element): SChapter = throw UnsupportedOperationException("Not used") + + // Pages + + override fun fetchPageList(chapter: SChapter): Observable> { + // split the "url" to get the page path and number of pages + return chapter.url.split("#").let { list -> + Observable.just(listOf(1 .. list[1].toInt()).flatten().map { Page(it, list[0] + "$it/") }) + } + } + + override fun imageUrlParse(document: Document): String { + return document.select("img#gimg").attr("abs:src") + } + + override fun pageListParse(document: Document): List = throw UnsupportedOperationException("Not used") + + // Filters + + override fun getFilterList() = FilterList( + Filter.Header("NOTE: Ignored if using text search!"), + Filter.Separator(), + GenreFilter() + ) + + // Top 50 tags + private class GenreFilter : UriPartFilter("Category", arrayOf( + Pair("