DMZJ: update URL, extlib 1.4, add chapters (#15834)

This commit is contained in:
stevenyomi 2023-03-26 00:35:25 +08:00 committed by GitHub
parent 50fe3eae7f
commit ad0e62a774
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 23 additions and 15 deletions

View File

@ -6,7 +6,7 @@ ext {
extName = 'DMZJ'
pkgNameSuffix = 'zh.dmzj'
extClass = '.Dmzj'
extVersionCode = 35
extVersionCode = 36
}
apply from: "$rootDir/common.gradle"

View File

@ -10,7 +10,7 @@ import okhttp3.Response
object ApiSearch {
fun textSearchUrl(query: String) =
"http://s.acg.dmzj.com/comicsum/search.php".toHttpUrl().newBuilder()
"http://sacg.idmzj.com/comicsum/search.php".toHttpUrl().newBuilder()
.addQueryParameter("s", query)
.toString()

View File

@ -10,7 +10,7 @@ import okhttp3.Response
object ApiV3 {
private const val v3apiUrl = "https://v3api.dmzj.com"
private const val v3apiUrl = "https://v3api.idmzj.com"
private const val apiUrl = "https://api.dmzj.com"
fun popularMangaUrl(page: Int) = "$v3apiUrl/classify/0/0/${page - 1}.json"
@ -33,7 +33,15 @@ object ApiV3 {
}
fun parseChapterListV1(response: Response): List<SChapter> {
return parseMangaInfoV1(response).data.list.map { it.toSChapter() }
val data = parseMangaInfoV1(response).data
return buildList(data.list.size + data.alone.size) {
data.list.mapTo(this) {
it.toSChapter()
}
data.alone.mapTo(this) {
it.toSChapter().apply { name = "单行本: $name" }
}
}
}
fun chapterCommentsUrl(path: String) = "$v3apiUrl/viewPoint/0/$path.json"
@ -92,7 +100,7 @@ object ApiV3 {
}
@Serializable
class DataDto(val info: MangaDto, val list: List<ChapterDto>)
class DataDto(val info: MangaDto, val list: List<ChapterDto>, val alone: List<ChapterDto>)
@Serializable
class ResponseDto(val data: DataDto)

View File

@ -18,8 +18,8 @@ import kotlin.reflect.typeOf
object ApiV4 {
private const val v4apiUrl = "https://nnv4api.dmzj.com"
private const val imageSmallCDNUrl = "https://imgsmall.dmzj.com"
private const val v4apiUrl = "https://nnv4api.idmzj.com"
private const val imageSmallCDNUrl = "https://imgsmall.idmzj.com"
fun mangaInfoUrl(id: String) = "$v4apiUrl/comic/detail/$id?uid=2665531"

View File

@ -28,7 +28,7 @@ class Dmzj : ConfigurableSource, HttpSource() {
override val lang = "zh"
override val supportsLatest = true
override val name = "动漫之家"
override val baseUrl = "https://m.dmzj.com"
override val baseUrl = "https://m.idmzj.com"
private val preferences: SharedPreferences by lazy {
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
@ -47,7 +47,7 @@ class Dmzj : ConfigurableSource, HttpSource() {
.build()
private fun fetchIdBySlug(slug: String): String {
val request = GET("https://manhua.dmzj.com/$slug/", headers)
val request = GET("https://manhua.idmzj.com/$slug/", headers)
val html = client.newCall(request).execute().body.string()
val start = "g_comic_id = \""
val startIndex = html.indexOf(start) + start.length
@ -133,7 +133,6 @@ class Dmzj : ConfigurableSource, HttpSource() {
throw UnsupportedOperationException()
}
// Bypass mangaDetailsRequest, fetch api url directly
override fun fetchMangaDetails(manga: SManga): Observable<SManga> {
val id = manga.url.extractMangaId()
return Observable.fromCallable { fetchMangaDetails(id) }
@ -147,11 +146,13 @@ class Dmzj : ConfigurableSource, HttpSource() {
return ApiV3.parseMangaDetailsV1(response)
}
// Workaround to allow "Open in browser" use human readable webpage url.
// headers are not needed
override fun mangaDetailsRequest(manga: SManga): Request {
throw UnsupportedOperationException()
}
override fun getMangaUrl(manga: SManga): String {
val cid = manga.url.extractMangaId()
return GET("$baseUrl/info/$cid.html")
return "$baseUrl/info/$cid.html"
}
override fun mangaDetailsParse(response: Response) = SManga.create().apply {
@ -178,8 +179,7 @@ class Dmzj : ConfigurableSource, HttpSource() {
throw UnsupportedOperationException()
}
// for WebView, headers are not needed
override fun pageListRequest(chapter: SChapter) = GET("$baseUrl/view/${chapter.url}.html")
override fun getChapterUrl(chapter: SChapter) = "$baseUrl/view/${chapter.url}.html"
override fun fetchPageList(chapter: SChapter): Observable<List<Page>> {
val path = chapter.url