Update DragonBallMultiverse to new site layout (#9006)
* 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:
parent
9e19be80bb
commit
f91e5f6b41
@ -5,7 +5,7 @@ ext {
|
|||||||
extName = 'Dragon Ball Multiverse'
|
extName = 'Dragon Ball Multiverse'
|
||||||
pkgNameSuffix = 'all.dragonball_multiverse'
|
pkgNameSuffix = 'all.dragonball_multiverse'
|
||||||
extClass = '.DbMFactory'
|
extClass = '.DbMFactory'
|
||||||
extVersionCode = 2
|
extVersionCode = 3
|
||||||
libVersion = '1.2'
|
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.SChapter
|
||||||
import eu.kanade.tachiyomi.source.model.SManga
|
import eu.kanade.tachiyomi.source.model.SManga
|
||||||
import eu.kanade.tachiyomi.source.online.ParsedHttpSource
|
import eu.kanade.tachiyomi.source.online.ParsedHttpSource
|
||||||
import eu.kanade.tachiyomi.util.asJsoup
|
|
||||||
import okhttp3.Request
|
import okhttp3.Request
|
||||||
import okhttp3.Response
|
import okhttp3.Response
|
||||||
import org.jsoup.nodes.Document
|
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 baseUrl = "https://www.dragonball-multiverse.com"
|
||||||
override val supportsLatest = false
|
override val supportsLatest = false
|
||||||
|
|
||||||
private fun chapterFromElement(element: Element, name: String): SChapter {
|
override fun chapterFromElement(element: Element): SChapter {
|
||||||
val chapter = SChapter.create()
|
val chapter = SChapter.create()
|
||||||
chapter.setUrlWithoutDomain(element.attr("abs:href"))
|
val href = element.attr("href")
|
||||||
chapter.name = name + element.text().let { num ->
|
chapter.url = "$baseUrl/$internalLang/$href"
|
||||||
if (num.contains("-")) {
|
chapter.name = href.substringBefore(".html").replace("-", " ")
|
||||||
"Pages $num"
|
|
||||||
} else {
|
|
||||||
"Page $num"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return chapter
|
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> {
|
override fun chapterListParse(response: Response): List<SChapter> {
|
||||||
val chapters = mutableListOf<SChapter>()
|
return super.chapterListParse(response).reversed()
|
||||||
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()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun pageListParse(document: Document): List<Page> {
|
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> {
|
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 {
|
private fun createManga(type: String) = SManga.create().apply {
|
||||||
title = name
|
title = when (type) {
|
||||||
|
"comic" -> "DB Multiverse"
|
||||||
|
"namekseijin" -> "Namekseijin Densetsu"
|
||||||
|
"strip" -> "Minicomic"
|
||||||
|
else -> name
|
||||||
|
}
|
||||||
status = SManga.ONGOING
|
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."
|
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()
|
override fun imageUrlParse(document: Document): String = throw UnsupportedOperationException()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user