diff --git a/src/de/wiemanga/build.gradle b/src/de/wiemanga/build.gradle index d09fd542d..12a8450c7 100644 --- a/src/de/wiemanga/build.gradle +++ b/src/de/wiemanga/build.gradle @@ -5,7 +5,7 @@ ext { appName = 'Tachiyomi: WieManga' pkgNameSuffix = 'de.wiemanga' extClass = '.WieManga' - extVersionCode = 3 + extVersionCode = 4 libVersion = '1.2' } diff --git a/src/de/wiemanga/src/eu/kanade/tachiyomi/extension/de/wiemanga/WieManga.kt b/src/de/wiemanga/src/eu/kanade/tachiyomi/extension/de/wiemanga/WieManga.kt index 786fd7649..4d2443251 100644 --- a/src/de/wiemanga/src/eu/kanade/tachiyomi/extension/de/wiemanga/WieManga.kt +++ b/src/de/wiemanga/src/eu/kanade/tachiyomi/extension/de/wiemanga/WieManga.kt @@ -6,10 +6,13 @@ import eu.kanade.tachiyomi.source.model.Page import eu.kanade.tachiyomi.source.model.SChapter import eu.kanade.tachiyomi.source.model.SManga import eu.kanade.tachiyomi.source.online.ParsedHttpSource +import okhttp3.Headers +import okhttp3.OkHttpClient import okhttp3.Request import org.jsoup.nodes.Document import org.jsoup.nodes.Element import java.text.SimpleDateFormat +import java.util.Locale class WieManga : ParsedHttpSource() { @@ -23,9 +26,11 @@ class WieManga : ParsedHttpSource() { override val supportsLatest = true - private fun imageHeader(refer: String) = super.headersBuilder() - .add("Referer", refer) - .build() + override val client: OkHttpClient = network.cloudflareClient + + override fun headersBuilder(): Headers.Builder = super.headersBuilder() + .add("Accept-Language", "en-US,en;q=0.5") + .add("Referer", baseUrl) override fun popularMangaSelector() = ".booklist td > div" @@ -40,23 +45,22 @@ class WieManga : ParsedHttpSource() { } override fun popularMangaFromElement(element: Element): SManga { - val image = element.select("dt img") - val title = element.select("dd a:first-child") - val manga = SManga.create() - manga.setUrlWithoutDomain(title.attr("href")) - manga.title = title.text() - manga.thumbnail_url = image.attr("src") + + element.select("dd a:first-child").let { + manga.setUrlWithoutDomain(it.attr("href")) + manga.title = it.text() + } + manga.thumbnail_url = element.select("dt img").attr("abs:src") + return manga } - override fun latestUpdatesFromElement(element: Element): SManga { - return popularMangaFromElement(element) - } + override fun latestUpdatesFromElement(element: Element): SManga = popularMangaFromElement(element) - override fun popularMangaNextPageSelector() = null + override fun popularMangaNextPageSelector(): String? = null - override fun latestUpdatesNextPageSelector() = null + override fun latestUpdatesNextPageSelector(): String? = null override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request { return GET("$baseUrl/search/?wd=$query", headers) @@ -65,51 +69,57 @@ class WieManga : ParsedHttpSource() { override fun searchMangaSelector() = ".searchresult td > div" override fun searchMangaFromElement(element: Element): SManga { - val image = element.select(".resultimg img") - val title = element.select(".resultbookname") - val manga = SManga.create() - manga.setUrlWithoutDomain(title.attr("href")) - manga.title = title.text() - manga.thumbnail_url = image.attr("src") + + element.select(".resultbookname").let { + manga.setUrlWithoutDomain(it.attr("href")) + manga.title = it.text() + } + manga.thumbnail_url = element.select(".resultimg img").attr("abs:src") + return manga } override fun searchMangaNextPageSelector() = ".pagetor a.l" override fun mangaDetailsParse(document: Document): SManga { - val imageElement = document.select(".bookmessgae tr > td:nth-child(1)").first() - val infoElement = document.select(".bookmessgae tr > td:nth-child(2)").first() - val manga = SManga.create() - manga.author = infoElement.select("dd:nth-of-type(2) a").first()?.text() - manga.artist = infoElement.select("dd:nth-of-type(3) a").first()?.text() - manga.description = infoElement.select("dl > dt:last-child").first()?.text()?.replaceFirst("Beschreibung", "") - manga.thumbnail_url = imageElement.select("img").first()?.attr("src") - if (manga.author == "RSS") - manga.author = null + document.select("div.bookmessgae").let { details -> + manga.author = details.select("dd:contains(Autor:) a").text() + manga.artist = details.select("dd:contains(Zeichner:) a").text() + manga.genre = details.select("dd:contains(Genre:) a").joinToString { it.text() } + manga.description = details.select("dt").first()?.ownText() + manga.thumbnail_url = details.select("div.bookfrontpage img").attr("abs:src") + manga.status = parseStatus(details.select("dd:contains(Status:) a").text()) + } - if (manga.artist == "RSS") - manga.artist = null return manga } + private fun parseStatus(status: String?) = when { + status == null -> SManga.UNKNOWN + status.contains("ongoing", ignoreCase = true) -> SManga.ONGOING + status.contains("finished", ignoreCase = true) -> SManga.COMPLETED + else -> SManga.UNKNOWN + } + override fun chapterListSelector() = ".chapterlist tr:not(:first-child)" override fun chapterFromElement(element: Element): SChapter { - val urlElement = element.select(".col1 a").first() - val dateElement = element.select(".col3 a").first() - val chapter = SChapter.create() - chapter.setUrlWithoutDomain(urlElement.attr("href")) - chapter.name = urlElement.text() - chapter.date_upload = dateElement?.text()?.let { parseChapterDate(it) } ?: 0 + + element.select(".col1 a").first().let { + chapter.setUrlWithoutDomain(it.attr("href")) + chapter.name = it.text() + } + chapter.date_upload = element.select(".col3 a").first()?.text()?.let { parseChapterDate(it) } ?: 0 + return chapter } private fun parseChapterDate(date: String): Long { - return SimpleDateFormat("yyyy-MM-dd hh:mm:ss").parse(date).time + return SimpleDateFormat("yyyy-MM-dd hh:mm:ss", Locale.getDefault()).parse(date).time } override fun pageListParse(document: Document): List { @@ -121,10 +131,8 @@ class WieManga : ParsedHttpSource() { return pages } - override fun imageUrlRequest(page: Page): Request { - return GET(page.url, imageHeader(page.url)) + override fun imageUrlParse(document: Document): String { + return document.select("img#comicpic").first().attr("abs:src") } - override fun imageUrlParse(document: Document) = document.select("img#comicpic").first().attr("src") - -} \ No newline at end of file +}