DB Multiverse update (#1778)

DB Multiverse update
This commit is contained in:
Mike 2019-11-13 20:54:40 -05:00 committed by arkon
parent bb75ae36e7
commit 8c7f09bc28
2 changed files with 33 additions and 16 deletions

View File

@ -5,7 +5,7 @@ ext {
appName = 'Tachiyomi: Dragon Ball Multiverse'
pkgNameSuffix = 'en.dragonball_multiverse'
extClass = '.DbMultiverse'
extVersionCode = 1
extVersionCode = 2
libVersion = '1.2'
}

View File

@ -6,7 +6,9 @@ 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
import org.jsoup.nodes.Element
import rx.Observable
@ -18,16 +20,14 @@ open class DbMultiverse : ParsedHttpSource() {
override val supportsLatest = false
override val lang = "en"
override fun chapterFromElement(element: Element): SChapter {
val chapterUrl = element.attr("href")
private fun chapterFromElement(element: Element, name: String): SChapter {
val chapter = SChapter.create()
chapter.url = "/en/$chapterUrl"
chapter.name = element.text().let { name ->
if (name.contains("-")) {
"Pages $name"
chapter.setUrlWithoutDomain(element.attr("abs:href"))
chapter.name = name + element.text().let { num ->
if (num.contains("-")) {
"Pages $num"
} else {
"Page $name"
"Page $num"
}
}
return chapter
@ -35,26 +35,43 @@ open class DbMultiverse : ParsedHttpSource() {
override fun chapterListSelector(): String = "div.cadrelect.chapters a[href*=page-]"
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()
}
override fun pageListParse(document: Document): List<Page> {
return document.select("img[src*=/final/]").mapIndexed { index, element ->
Page(index, "", baseUrl + element.attr("src"))
return document.select("div#h_read img").mapIndexed { index, element ->
Page(index, "", element.attr("abs:src"))
}
}
override fun mangaDetailsParse(document: Document): SManga = createManga()
override fun mangaDetailsParse(document: Document): SManga = createManga(document)
override fun fetchPopularManga(page: Int): Observable<MangasPage> {
return Observable.just(MangasPage(listOf(createManga()), hasNextPage = false))
return Observable.just(MangasPage(listOf(createManga(null)), hasNextPage = false))
}
private fun createManga() = SManga.create().apply {
private fun createManga(document: Document?) = SManga.create().apply {
title = name
status = SManga.ONGOING
url = "/en/chapters.html"
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 = "$baseUrl/en/pages/final/0000.jpg"
thumbnail_url = document?.select("div[ch=\"1\"] img")?.attr("abs:src")
}
override fun chapterFromElement(element: Element): SChapter = throw UnsupportedOperationException()
override fun imageUrlParse(document: Document): String = throw UnsupportedOperationException()
override fun popularMangaFromElement(element: Element): SManga = throw UnsupportedOperationException()
@ -82,4 +99,4 @@ open class DbMultiverse : ParsedHttpSource() {
override fun latestUpdatesRequest(page: Int): Request = throw UnsupportedOperationException()
override fun latestUpdatesSelector(): String = throw UnsupportedOperationException()
}
}