Update DragonBallMultiverse to new site layout ()

* update link to manga

Closes https://github.com/tachiyomiorg/tachiyomi-extensions/issues/8568

* bump dbm.extvercode

* add more titles to ext

* add fetchMangaDetails override

so that refreshing manga works

* update chapterListSelector

so that it works on all titles, old and new

* refactor parsing chapter lists

since the selector was changed

* remember chapter currentTimeMillis

kind of a hack for setting `chapter.date_upload` cleverly so that it
doesn't update itself during library update
refer tachiyomiorg@50859e7

* refactor chapterFromElement again

because name inside SChapter.create().apply{} was ambiguous. made it
explicit to `chapter.name`

* fix value set to `chapter.chapter_number`

* revert chapterListParse

remembering currentTimeInMillis doesn't really work for now. Can just
add it if requested later

This commit reverts 459057829

* remove unused add override for chapterFromElement()

* create absolute links instead of fetching them

so that I can set the chapter names correctly
This commit is contained in:
nicki 2021-09-08 05:17:22 +05:30 committed by GitHub
parent 9e19be80bb
commit f91e5f6b41
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 32 deletions
src/all/dragonball_multiverse
build.gradle
src/eu/kanade/tachiyomi/extension/all/dragonball_multiverse

@ -5,7 +5,7 @@ ext {
extName = 'Dragon Ball Multiverse'
pkgNameSuffix = 'all.dragonball_multiverse'
extClass = '.DbMFactory'
extVersionCode = 2
extVersionCode = 3
libVersion = '1.2'
}

@ -6,7 +6,6 @@ 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 eu.kanade.tachiyomi.util.asJsoup
import okhttp3.Request
import okhttp3.Response
import org.jsoup.nodes.Document
@ -21,34 +20,19 @@ abstract class DbMultiverse(override val lang: String, private val internalLang:
override val baseUrl = "https://www.dragonball-multiverse.com"
override val supportsLatest = false
private fun chapterFromElement(element: Element, name: String): SChapter {
override fun chapterFromElement(element: Element): SChapter {
val chapter = SChapter.create()
chapter.setUrlWithoutDomain(element.attr("abs:href"))
chapter.name = name + element.text().let { num ->
if (num.contains("-")) {
"Pages $num"
} else {
"Page $num"
}
}
val href = element.attr("href")
chapter.url = "$baseUrl/$internalLang/$href"
chapter.name = href.substringBefore(".html").replace("-", " ")
return chapter
}
override fun chapterListSelector(): String = "div.cadrelect.chapters a[href*=page-]"
override fun chapterListSelector(): String = ".cadrelect.chapters p a[href*=-]"
override fun chapterListParse(response: Response): List<SChapter> {
val chapters = mutableListOf<SChapter>()
val document = response.asJsoup()
document.select("div[ch]").forEach { container ->
container.select(chapterListSelector()).mapIndexed { i, chapter ->
// Each page is its own chapter, add chapter name when a first page is mapped
val name = if (i == 0) container.select("h4").text() + " - " else ""
chapters.add(chapterFromElement(chapter, name))
}
}
return chapters.reversed()
return super.chapterListParse(response).reversed()
}
override fun pageListParse(document: Document): List<Page> {
@ -57,21 +41,33 @@ abstract class DbMultiverse(override val lang: String, private val internalLang:
}
}
override fun mangaDetailsParse(document: Document): SManga = createManga(document)
override fun fetchPopularManga(page: Int): Observable<MangasPage> {
return Observable.just(MangasPage(listOf(createManga(null)), hasNextPage = false))
// site hosts three titles that can be read by the app
return listOf("page", "strip", "namekseijin")
.map { createManga(it) }
.let { Observable.just(MangasPage(it, hasNextPage = false)) }
}
private fun createManga(document: Document?) = SManga.create().apply {
title = name
private fun createManga(type: String) = SManga.create().apply {
title = when (type) {
"comic" -> "DB Multiverse"
"namekseijin" -> "Namekseijin Densetsu"
"strip" -> "Minicomic"
else -> name
}
status = SManga.ONGOING
url = "/$internalLang/chapters.html"
url = "/$internalLang/chapters.html?comic=$type"
description = "Dragon Ball Multiverse (DBM) is a free online comic, made by a whole team of fans. It's our personal sequel to DBZ."
thumbnail_url = document?.select("div[ch=\"1\"] img")?.attr("abs:src")
thumbnail_url = "$baseUrl/imgs/read/$type.jpg"
}
override fun chapterFromElement(element: Element): SChapter = throw UnsupportedOperationException()
override fun fetchMangaDetails(manga: SManga): Observable<SManga> {
return manga.apply {
initialized = true
}.let { Observable.just(it) }
}
override fun mangaDetailsParse(document: Document): SManga = throw Exception("Not Used")
override fun imageUrlParse(document: Document): String = throw UnsupportedOperationException()