Make GoDa multisrc and add sources (#3318)

This commit is contained in:
stevenyomi 2024-06-01 12:25:44 +08:00 committed by GitHub
parent fb4eb99065
commit 64f7ed5645
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
19 changed files with 53 additions and 26 deletions

View File

@ -0,0 +1,5 @@
plugins {
id("lib-multisrc")
}
baseVersionCode = 1

View File

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

Before

Width:  |  Height:  |  Size: 5.2 KiB

After

Width:  |  Height:  |  Size: 5.2 KiB

View File

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 6.7 KiB

View File

@ -1,4 +1,4 @@
package eu.kanade.tachiyomi.extension.zh.baozimhorg package eu.kanade.tachiyomi.multisrc.goda
import eu.kanade.tachiyomi.network.GET import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.source.model.Filter import eu.kanade.tachiyomi.source.model.Filter
@ -13,10 +13,11 @@ import okhttp3.HttpUrl.Companion.toHttpUrl
import okhttp3.Request import okhttp3.Request
import okhttp3.Response import okhttp3.Response
import org.jsoup.nodes.Document import org.jsoup.nodes.Document
import org.jsoup.nodes.Element
import org.jsoup.nodes.Entities import org.jsoup.nodes.Entities
import rx.Observable import rx.Observable
open class BaozimhOrg( open class GoDa(
override val name: String, override val name: String,
override val baseUrl: String, override val baseUrl: String,
override val lang: String, override val lang: String,
@ -77,29 +78,33 @@ open class BaozimhOrg(
return GET(getMangaUrl(manga), headers) return GET(getMangaUrl(manga), headers)
} }
private fun Document.getMangaId() = selectFirst("#mangachapters")!!.attr("data-mid") private fun Element.getMangaId() = selectFirst("#mangachapters")!!.attr("data-mid")
override fun mangaDetailsParse(response: Response) = SManga.create().apply { override fun mangaDetailsParse(response: Response) = SManga.create().apply {
val document = response.asJsoup() val document = response.asJsoup().selectFirst("main")!!
val titleElement = document.selectFirst("h1")!! val titleElement = document.selectFirst("h1")!!
val elements = titleElement.parent()!!.parent()!!.children() val elements = titleElement.parent()!!.parent()!!.children()
check(elements.size == 6) check(elements.size == 6)
title = titleElement.ownText() title = titleElement.ownText()
status = SManga.UNKNOWN // Everything is marked as ongoing status = when (titleElement.child(0).text()) {
"連載中", "Ongoing" -> SManga.ONGOING
"完結" -> SManga.COMPLETED
else -> SManga.UNKNOWN
}
author = Entities.unescape(elements[1].children().drop(1).joinToString { it.text().removeSuffix(" ,") }) author = Entities.unescape(elements[1].children().drop(1).joinToString { it.text().removeSuffix(" ,") })
genre = buildList { genre = buildList {
elements[2].children().drop(1).mapTo(this) { it.text().removeSuffix(" ,") } elements[2].children().drop(1).mapTo(this) { it.text().removeSuffix(" ,") }
elements[3].children().mapTo(this) { it.text().removePrefix("#") } elements[3].children().mapTo(this) { it.text().removePrefix("#") }
}.joinToString() }.joinToString()
description = elements[4].text() + "\n\nID: ${document.getMangaId()}" description = (elements[4].text() + "\n\nID: ${document.getMangaId()}").trim()
thumbnail_url = document.selectFirst("img.object-cover")!!.attr("src") thumbnail_url = document.selectFirst("img.object-cover")!!.attr("src")
} }
override fun fetchChapterList(manga: SManga): Observable<List<SChapter>> = Observable.fromCallable { override fun fetchChapterList(manga: SManga): Observable<List<SChapter>> = Observable.fromCallable {
val mangaId = manga.description val mangaId = manga.description
?.substringAfterLast("\nID: ", "") ?.substringAfterLast("ID: ", "")
?.takeIf { it.isNotEmpty() && it.all(Character::isDigit) } ?.takeIf { it.toIntOrNull() != null }
?: client.newCall(mangaDetailsRequest(manga)).execute().asJsoup().getMangaId() ?: client.newCall(mangaDetailsRequest(manga)).execute().asJsoup().getMangaId()
fetchChapterList(mangaId) fetchChapterList(mangaId)
@ -125,8 +130,8 @@ open class BaozimhOrg(
override fun pageListRequest(chapter: SChapter): Request { override fun pageListRequest(chapter: SChapter): Request {
val id = chapter.url.substringAfterLast('#', "") val id = chapter.url.substringAfterLast('#', "")
val mangaId = id.substringBefore('/') val mangaId = id.substringBefore('/', "")
val chapterId = id.substringAfter('/') val chapterId = id.substringAfter('/', "")
return pageListRequest(mangaId, chapterId) return pageListRequest(mangaId, chapterId)
} }
@ -134,8 +139,8 @@ open class BaozimhOrg(
override fun pageListParse(response: Response): List<Page> { override fun pageListParse(response: Response): List<Page> {
val document = response.asJsoup() val document = response.asJsoup()
return document.select("noscript > img").mapIndexed { index, element -> return document.select("#chapcontent > div > img").mapIndexed { index, element ->
Page(index, imageUrl = element.attr("src")) Page(index, imageUrl = element.attr("data-src").ifEmpty { element.attr("src") })
} }
} }

8
src/en/goda/build.gradle Normal file
View File

@ -0,0 +1,8 @@
ext {
extName = 'Goda'
extClass = '.Goda'
themePkg = 'goda'
overrideVersionCode = 0
}
apply from: "$rootDir/common.gradle"

View File

@ -0,0 +1,5 @@
package eu.kanade.tachiyomi.extension.en.goda
import eu.kanade.tachiyomi.multisrc.goda.GoDa
class Goda : GoDa("Goda", "https://manhuascans.org", "en")

View File

@ -1,7 +1,8 @@
ext { ext {
extName = 'GoDa' extName = 'GoDa'
extClass = '.GoDaManhua' extClass = '.GoDaManhua'
extVersionCode = 29 themePkg = 'goda'
overrideVersionCode = 29
} }
apply from: "$rootDir/common.gradle" apply from: "$rootDir/common.gradle"

View File

@ -1,12 +0,0 @@
package eu.kanade.tachiyomi.extension.zh.baozimhorg
import eu.kanade.tachiyomi.source.SourceFactory
// This is not used because ideally the extension language should be updated to "Multi" (all).
// Chinese users don't receive status updates from Discord, so I'll keep the package name unchanged for now.
class GoDaFactory : SourceFactory {
override fun createSources() = listOf(
GoDaManhua(),
BaozimhOrg("Goda", "https://manhuascans.org", "en"),
)
}

View File

@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.extension.zh.baozimhorg
import android.app.Application import android.app.Application
import androidx.preference.ListPreference import androidx.preference.ListPreference
import androidx.preference.PreferenceScreen import androidx.preference.PreferenceScreen
import eu.kanade.tachiyomi.multisrc.goda.GoDa
import eu.kanade.tachiyomi.network.GET import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.source.ConfigurableSource import eu.kanade.tachiyomi.source.ConfigurableSource
import eu.kanade.tachiyomi.source.model.Page import eu.kanade.tachiyomi.source.model.Page
@ -16,7 +17,7 @@ import okio.IOException
import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get import uy.kohesive.injekt.api.get
class GoDaManhua : BaozimhOrg("GoDa漫画", "", "zh"), ConfigurableSource { class GoDaManhua : GoDa("GoDa漫画", "", "zh"), ConfigurableSource {
override val id get() = 774030471139699415 override val id get() = 774030471139699415

View File

@ -0,0 +1,9 @@
ext {
extName = '18Manhua'
extClass = '.EighteenManhua'
themePkg = 'goda'
overrideVersionCode = 0
isNsfw = true
}
apply from: "$rootDir/common.gradle"

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

View File

@ -0,0 +1,5 @@
package eu.kanade.tachiyomi.extension.zh.eighteenmanhua
import eu.kanade.tachiyomi.multisrc.goda.GoDa
class EighteenManhua : GoDa("18漫画", "https://18mh.org", "zh")