From f8ad86da6c23996c328d3c7211b08fef4f1c3119 Mon Sep 17 00:00:00 2001 From: Johannes Joens <34899572+jopejoe1@users.noreply.github.com> Date: Tue, 4 May 2021 01:28:03 +1200 Subject: [PATCH] Patchfriday various updates and fixes (#6805) * Update PatchFriday.kt * Update build.gradle --- src/en/patchfriday/build.gradle | 2 +- .../extension/en/patchfriday/PatchFriday.kt | 44 ++++++++++++++----- 2 files changed, 34 insertions(+), 12 deletions(-) diff --git a/src/en/patchfriday/build.gradle b/src/en/patchfriday/build.gradle index e3e2d2715..f8999f7dd 100644 --- a/src/en/patchfriday/build.gradle +++ b/src/en/patchfriday/build.gradle @@ -5,7 +5,7 @@ ext { extName = 'Patch Friday' pkgNameSuffix = 'en.patchfriday' extClass = '.PatchFriday' - extVersionCode = 1 + extVersionCode = 2 libVersion = '1.2' } diff --git a/src/en/patchfriday/src/eu/kanade/tachiyomi/extension/en/patchfriday/PatchFriday.kt b/src/en/patchfriday/src/eu/kanade/tachiyomi/extension/en/patchfriday/PatchFriday.kt index ea8d130ff..2a73b9b0f 100644 --- a/src/en/patchfriday/src/eu/kanade/tachiyomi/extension/en/patchfriday/PatchFriday.kt +++ b/src/en/patchfriday/src/eu/kanade/tachiyomi/extension/en/patchfriday/PatchFriday.kt @@ -1,6 +1,7 @@ package eu.kanade.tachiyomi.extension.en.patchfriday import eu.kanade.tachiyomi.network.GET +import eu.kanade.tachiyomi.network.asObservableSuccess import eu.kanade.tachiyomi.source.model.FilterList import eu.kanade.tachiyomi.source.model.MangasPage import eu.kanade.tachiyomi.source.model.Page @@ -29,7 +30,10 @@ class PatchFriday : HttpSource() { return SManga.create().apply { initialized = true title = "Patch Friday" + status = SManga.ONGOING url = "" + author = "Patch Friday" + artist = author thumbnail_url = "https://patchfriday.com/patches/68.png" description = "The IT security webcomic" } @@ -69,23 +73,41 @@ class PatchFriday : HttpSource() { // Chapters - override fun chapterListParse(response: Response): List { - val last = response.asJsoup().select("ul.strip_toolbar li a[rel=next]").attr("href") - .removeSurrounding("/").toInt() + override fun fetchChapterList(manga: SManga): Observable> { + return client.newCall(GET("$baseUrl/search/?search=;", headers)) + .asObservableSuccess() + .map { parseChapters(it) } + } - return listOf(1..last).flatten().reversed().map { - SChapter.create().apply { - name = "#$it - " - url = "/$it/" + private fun parseChapters (response: Response): List{ + val chapters = mutableListOf() + var document = response.asJsoup() + var page = document.select("div > div:first-of-type > div:first-of-type > a").attr("abs:href").replace(baseUrl,"").replace("/","").trim().toInt() + while (page > 0) { + val element = document.select("div > div > div:first-of-type > a") + element.forEach { + val chapter = SChapter.create() + chapter.url = it.attr("abs:href").replace(baseUrl,"").trim() + chapter.chapter_number = chapter.url.replace("/", "").trim().toFloat() + chapter.name = "#${chapter.chapter_number.toInt()} - ${it.text()}" + chapter.date_upload = System.currentTimeMillis() + chapters.add(chapter) } + page -= 10 + document = client.newCall(GET("$baseUrl/search/?search=;id=$page", headers)).execute().asJsoup() } + //Add First Chapter becouse for some reason it does not show up in chapter search + chapters.add(SChapter.create().apply { + url = "/1/" + chapter_number = url.replace("/", "").trim().toFloat() + name = "#${chapter_number.toInt()} - The One" + date_upload = System.currentTimeMillis() + }) + return chapters } - override fun prepareNewChapter(chapter: SChapter, manga: SManga) { - val cName = client.newCall(GET(baseUrl + chapter.url)).execute().asJsoup().select("div#strip_title").text() + override fun chapterListParse(response: Response): List = throw UnsupportedOperationException("Not used") - chapter.apply { name += cName } - } // Pages