From e046d8b4c81947f9545bd7407c78792e310a0159 Mon Sep 17 00:00:00 2001 From: Mike <51273546+SnakeDoc83@users.noreply.github.com> Date: Fri, 24 Apr 2020 08:27:50 -0400 Subject: [PATCH] Foolslide - add English HNI-Scantrad (#2796) Foolslide - add English HNI-Scantrad --- src/all/foolslide/build.gradle | 2 +- .../extension/all/foolslide/FoolSlide.kt | 19 +++++----- .../all/foolslide/FoolSlideFactory.kt | 37 ++++++++++++++++++- 3 files changed, 45 insertions(+), 13 deletions(-) diff --git a/src/all/foolslide/build.gradle b/src/all/foolslide/build.gradle index 6ce959ec5..c82ba1164 100644 --- a/src/all/foolslide/build.gradle +++ b/src/all/foolslide/build.gradle @@ -5,7 +5,7 @@ ext { appName = 'Tachiyomi: FoolSlide (multiple sources)' pkgNameSuffix = 'all.foolslide' extClass = '.FoolSlideFactory' - extVersionCode = 39 + extVersionCode = 40 libVersion = '1.2' } diff --git a/src/all/foolslide/src/eu/kanade/tachiyomi/extension/all/foolslide/FoolSlide.kt b/src/all/foolslide/src/eu/kanade/tachiyomi/extension/all/foolslide/FoolSlide.kt index c525f868f..8d93baf9f 100644 --- a/src/all/foolslide/src/eu/kanade/tachiyomi/extension/all/foolslide/FoolSlide.kt +++ b/src/all/foolslide/src/eu/kanade/tachiyomi/extension/all/foolslide/FoolSlide.kt @@ -115,22 +115,21 @@ abstract class FoolSlide( // if there's no image on the details page, get the first page of the first chapter fun getDetailsThumbnail(document: Document, urlSelector: String = chapterUrlSelector): String? { - return document.select("div.thumbnail img").firstOrNull()?.attr("abs:src") ?: + return document.select("div.thumbnail img, table.thumb img").firstOrNull()?.attr("abs:src") ?: document.select(chapterListSelector()).last().select(urlSelector).attr("abs:href") .let { url -> client.newCall(allowAdult(GET(url, headers))).execute() } .let { response -> pageListParse(response).first().imageUrl } } override fun mangaDetailsParse(document: Document): SManga { - val infoElement = document.select(mangaDetailsInfoSelector).first().text() - - val manga = SManga.create() - manga.author = infoElement.substringAfter("Author:").substringBefore("Artist:") - manga.artist = infoElement.substringAfter("Artist:").substringBefore("Synopsis:") - manga.description = infoElement.substringAfter("Synopsis:") - manga.thumbnail_url = getDetailsThumbnail(document) - - return manga + return SManga.create().apply { + document.select(mangaDetailsInfoSelector).firstOrNull()?.text()?.let { infoElement -> + author = infoElement.substringAfter("Author:").substringBefore("Artist:") + artist = infoElement.substringAfter("Artist:").substringBefore("Synopsis:") + description = infoElement.substringAfter("Synopsis:") + } + thumbnail_url = getDetailsThumbnail(document) + } } /** diff --git a/src/all/foolslide/src/eu/kanade/tachiyomi/extension/all/foolslide/FoolSlideFactory.kt b/src/all/foolslide/src/eu/kanade/tachiyomi/extension/all/foolslide/FoolSlideFactory.kt index 3c235e006..6145be7a7 100644 --- a/src/all/foolslide/src/eu/kanade/tachiyomi/extension/all/foolslide/FoolSlideFactory.kt +++ b/src/all/foolslide/src/eu/kanade/tachiyomi/extension/all/foolslide/FoolSlideFactory.kt @@ -1,17 +1,19 @@ package eu.kanade.tachiyomi.extension.all.foolslide -import android.util.Base64 import com.github.salomonbrys.kotson.get import com.google.gson.JsonParser import eu.kanade.tachiyomi.network.GET import eu.kanade.tachiyomi.source.Source import eu.kanade.tachiyomi.source.SourceFactory +import eu.kanade.tachiyomi.source.model.FilterList import eu.kanade.tachiyomi.source.model.Page import eu.kanade.tachiyomi.source.model.SChapter import eu.kanade.tachiyomi.source.model.SManga import okhttp3.Request +import okhttp3.Response import org.json.JSONObject import org.jsoup.nodes.Document +import org.jsoup.nodes.Element class FoolSlideFactory : SourceFactory { override fun createSources(): List = listOf( @@ -40,7 +42,8 @@ class FoolSlideFactory : SourceFactory { KirishimaFansub(), PowerMangaIT(), BaixarHentai(), - HNIScantrad() + HNIScantrad(), + HNIScantradEN() ) } @@ -149,3 +152,33 @@ class BaixarHentai : FoolSlide("Baixar Hentai", "https://leitura.baixarhentai.ne } class HNIScantrad : FoolSlide("HNI-Scantrad", "https://hni-scantrad.com", "fr", "/lel") + +class HNIScantradEN : FoolSlide("HNI-Scantrad", "https://hni-scantrad.com", "en", "/eng/lel") { + override val supportsLatest = false + override fun popularMangaRequest(page: Int) = GET(baseUrl + urlModifier, headers) + override fun popularMangaSelector() = "div.listed" + override fun popularMangaFromElement(element: Element): SManga { + return SManga.create().apply { + element.select("a:has(h3)").let { + title = it.text() + setUrlWithoutDomain(it.attr("abs:href")) + } + thumbnail_url = element.select("img").attr("abs:src") + } + } + override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request = GET("$baseUrl$urlModifier/?manga=${query.replace(" ", "+")}") + override fun searchMangaSelector(): String = popularMangaSelector() + override fun searchMangaFromElement(element: Element): SManga = popularMangaFromElement(element) + override fun chapterListSelector() = "div.theList > a" + override fun chapterFromElement(element: Element): SChapter { + return SChapter.create().apply { + name = element.select("div.chapter b").text() + setUrlWithoutDomain(element.attr("abs:href")) + } + } + override fun pageListParse(response: Response): List { + return Regex("""imageArray\[\d+]='(.*)'""").findAll(response.body()!!.string()).toList().mapIndexed { i, mr -> + Page(i, "", "$baseUrl$urlModifier/${mr.groupValues[1]}") + } + } +}