From aa224e18d6da29b4cb1bd9dac881a7b96ec815c6 Mon Sep 17 00:00:00 2001 From: rtlow <37086221+rtlow@users.noreply.github.com> Date: Wed, 10 Jan 2024 11:33:40 -0800 Subject: [PATCH] Improve Dynasty Scans (#113) --- src/en/dynasty/build.gradle | 2 +- .../extension/en/dynasty/DynastyAnthologies.kt | 4 +++- .../extension/en/dynasty/DynastyChapters.kt | 10 +--------- .../extension/en/dynasty/DynastyDoujins.kt | 5 +++-- .../extension/en/dynasty/DynastyIssues.kt | 4 +++- .../extension/en/dynasty/DynastyScans.kt | 17 ++++++++--------- .../extension/en/dynasty/DynastySeries.kt | 4 +++- 7 files changed, 22 insertions(+), 24 deletions(-) diff --git a/src/en/dynasty/build.gradle b/src/en/dynasty/build.gradle index 0304ee4ed..36786276b 100644 --- a/src/en/dynasty/build.gradle +++ b/src/en/dynasty/build.gradle @@ -6,7 +6,7 @@ ext { extName = 'Dynasty' pkgNameSuffix = 'en.dynasty' extClass = '.DynastyFactory' - extVersionCode = 21 + extVersionCode = 22 } apply from: "$rootDir/common.gradle" diff --git a/src/en/dynasty/src/eu/kanade/tachiyomi/extension/en/dynasty/DynastyAnthologies.kt b/src/en/dynasty/src/eu/kanade/tachiyomi/extension/en/dynasty/DynastyAnthologies.kt index 33fa33c21..f2ec2c796 100644 --- a/src/en/dynasty/src/eu/kanade/tachiyomi/extension/en/dynasty/DynastyAnthologies.kt +++ b/src/en/dynasty/src/eu/kanade/tachiyomi/extension/en/dynasty/DynastyAnthologies.kt @@ -12,7 +12,9 @@ class DynastyAnthologies : DynastyScans() { override val searchPrefix = "anthologies" - override fun popularMangaInitialUrl() = "$baseUrl/anthologies?view=cover" + override val categoryPrefix = "Anthology" + + override fun popularMangaInitialUrl() = "" override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request { return GET("$baseUrl/search?q=$query&classes%5B%5D=Anthology&sort=&page=$page", headers) diff --git a/src/en/dynasty/src/eu/kanade/tachiyomi/extension/en/dynasty/DynastyChapters.kt b/src/en/dynasty/src/eu/kanade/tachiyomi/extension/en/dynasty/DynastyChapters.kt index 0bf0dc5cf..2d933665f 100644 --- a/src/en/dynasty/src/eu/kanade/tachiyomi/extension/en/dynasty/DynastyChapters.kt +++ b/src/en/dynasty/src/eu/kanade/tachiyomi/extension/en/dynasty/DynastyChapters.kt @@ -13,9 +13,9 @@ import org.jsoup.nodes.Element class DynastyChapters : DynastyScans() { override val name = "Dynasty-Chapters" override val searchPrefix = "chapters" + override val categoryPrefix = "Chapter" override fun popularMangaInitialUrl() = "" - private fun popularMangaInitialUrl(page: Int) = "$baseUrl/search?q=&classes%5B%5D=Chapter&page=$page=$&sort=" private fun latestUpdatesInitialUrl(page: Int) = "$baseUrl/search?q=&classes%5B%5D=Chapter&page=$page=$&sort=created_at" override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request { @@ -76,23 +76,15 @@ class DynastyChapters : DynastyScans() { return chapter } - override fun popularMangaRequest(page: Int): Request { - return GET(popularMangaInitialUrl(page), headers) - } - override fun latestUpdatesRequest(page: Int): Request { return GET(latestUpdatesInitialUrl(page), headers) } - override fun popularMangaNextPageSelector() = searchMangaNextPageSelector() override fun latestUpdatesNextPageSelector() = searchMangaNextPageSelector() - override fun popularMangaSelector() = searchMangaSelector() override fun latestUpdatesSelector() = searchMangaSelector() - override fun popularMangaFromElement(element: Element) = searchMangaFromElement(element) override fun latestUpdatesFromElement(element: Element) = searchMangaFromElement(element) - override fun popularMangaParse(response: Response) = searchMangaParse(response) override fun latestUpdatesParse(response: Response) = searchMangaParse(response) } diff --git a/src/en/dynasty/src/eu/kanade/tachiyomi/extension/en/dynasty/DynastyDoujins.kt b/src/en/dynasty/src/eu/kanade/tachiyomi/extension/en/dynasty/DynastyDoujins.kt index d4c9014a7..cd18e178e 100644 --- a/src/en/dynasty/src/eu/kanade/tachiyomi/extension/en/dynasty/DynastyDoujins.kt +++ b/src/en/dynasty/src/eu/kanade/tachiyomi/extension/en/dynasty/DynastyDoujins.kt @@ -17,7 +17,8 @@ class DynastyDoujins : DynastyScans() { override val searchPrefix = "doujins" - override fun popularMangaInitialUrl() = "$baseUrl/doujins?view=cover" + override val categoryPrefix = "Doujin" + override fun popularMangaInitialUrl() = "" override fun popularMangaFromElement(element: Element): SManga { return super.popularMangaFromElement(element).apply { @@ -51,7 +52,7 @@ class DynastyDoujins : DynastyScans() { override fun chapterListParse(response: Response): List { val document = response.asJsoup() - val chapters = document.select(chapterListSelector()).map { chapterFromElement(it) }.toMutableList() + val chapters = try { document.select(chapterListSelector()).map { chapterFromElement(it) }.toMutableList() } catch (e: IndexOutOfBoundsException) { mutableListOf() } document.select("a.thumbnail img").let { images -> if (images.isNotEmpty()) { diff --git a/src/en/dynasty/src/eu/kanade/tachiyomi/extension/en/dynasty/DynastyIssues.kt b/src/en/dynasty/src/eu/kanade/tachiyomi/extension/en/dynasty/DynastyIssues.kt index c91c6af84..2fbe9a604 100644 --- a/src/en/dynasty/src/eu/kanade/tachiyomi/extension/en/dynasty/DynastyIssues.kt +++ b/src/en/dynasty/src/eu/kanade/tachiyomi/extension/en/dynasty/DynastyIssues.kt @@ -12,7 +12,9 @@ class DynastyIssues : DynastyScans() { override val searchPrefix = "issues" - override fun popularMangaInitialUrl() = "$baseUrl/issues?view=cover" + override val categoryPrefix = "Issue" + + override fun popularMangaInitialUrl() = "" override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request { return GET("$baseUrl/search?q=$query&classes%5B%5D=Issue&sort=&page=$page", headers) diff --git a/src/en/dynasty/src/eu/kanade/tachiyomi/extension/en/dynasty/DynastyScans.kt b/src/en/dynasty/src/eu/kanade/tachiyomi/extension/en/dynasty/DynastyScans.kt index f43dd81c1..26aece566 100644 --- a/src/en/dynasty/src/eu/kanade/tachiyomi/extension/en/dynasty/DynastyScans.kt +++ b/src/en/dynasty/src/eu/kanade/tachiyomi/extension/en/dynasty/DynastyScans.kt @@ -39,6 +39,8 @@ abstract class DynastyScans : ParsedHttpSource() { open val searchPrefix = "" + open val categoryPrefix = "" + private var parent: List = ArrayList() private var list = InternalList(ArrayList(), "") @@ -49,11 +51,13 @@ abstract class DynastyScans : ParsedHttpSource() { private val json: Json by injectLazy() + protected fun popularMangaInitialUrl(page: Int) = "$baseUrl/search?q=&classes%5B%5D=$categoryPrefix&page=$page=$&sort=" + override fun popularMangaRequest(page: Int): Request { - return GET(popularMangaInitialUrl(), headers) + return GET(popularMangaInitialUrl(page), headers) } - override fun popularMangaSelector() = "ul.thumbnails > li.span2" + override fun popularMangaSelector() = searchMangaSelector() override fun popularMangaFromElement(element: Element): SManga { val manga = SManga.create() @@ -62,12 +66,7 @@ abstract class DynastyScans : ParsedHttpSource() { return manga } - override fun popularMangaParse(response: Response): MangasPage { - val mangas = response.asJsoup().select(popularMangaSelector()).map { element -> - popularMangaFromElement(element) - } - return MangasPage(mangas, false) - } + override fun popularMangaParse(response: Response) = searchMangaParse(response) override fun fetchSearchManga(page: Int, query: String, filters: FilterList): Observable { if (query.startsWith("manga:")) { @@ -249,7 +248,7 @@ abstract class DynastyScans : ParsedHttpSource() { data class Validate(val _isManga: Boolean, val _pos: Int) - override fun popularMangaNextPageSelector() = "" + override fun popularMangaNextPageSelector() = searchMangaNextPageSelector() override fun latestUpdatesSelector() = "" override fun latestUpdatesNextPageSelector() = "" override fun imageUrlParse(document: Document): String = "" diff --git a/src/en/dynasty/src/eu/kanade/tachiyomi/extension/en/dynasty/DynastySeries.kt b/src/en/dynasty/src/eu/kanade/tachiyomi/extension/en/dynasty/DynastySeries.kt index 4f4c18ec8..bba2a24ca 100644 --- a/src/en/dynasty/src/eu/kanade/tachiyomi/extension/en/dynasty/DynastySeries.kt +++ b/src/en/dynasty/src/eu/kanade/tachiyomi/extension/en/dynasty/DynastySeries.kt @@ -14,7 +14,9 @@ class DynastySeries : DynastyScans() { override val searchPrefix = "series" - override fun popularMangaInitialUrl() = "$baseUrl/series?view=cover" + override val categoryPrefix = "Series" + + override fun popularMangaInitialUrl() = "" override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request { return GET("$baseUrl/search?q=$query&classes%5B%5D=Series&sort=&page=$page", headers)