DMZJ: update URL, extlib 1.4, add chapters (#15834)
This commit is contained in:
parent
50fe3eae7f
commit
ad0e62a774
|
@ -6,7 +6,7 @@ ext {
|
||||||
extName = 'DMZJ'
|
extName = 'DMZJ'
|
||||||
pkgNameSuffix = 'zh.dmzj'
|
pkgNameSuffix = 'zh.dmzj'
|
||||||
extClass = '.Dmzj'
|
extClass = '.Dmzj'
|
||||||
extVersionCode = 35
|
extVersionCode = 36
|
||||||
}
|
}
|
||||||
|
|
||||||
apply from: "$rootDir/common.gradle"
|
apply from: "$rootDir/common.gradle"
|
||||||
|
|
|
@ -10,7 +10,7 @@ import okhttp3.Response
|
||||||
object ApiSearch {
|
object ApiSearch {
|
||||||
|
|
||||||
fun textSearchUrl(query: String) =
|
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)
|
.addQueryParameter("s", query)
|
||||||
.toString()
|
.toString()
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ import okhttp3.Response
|
||||||
|
|
||||||
object ApiV3 {
|
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"
|
private const val apiUrl = "https://api.dmzj.com"
|
||||||
|
|
||||||
fun popularMangaUrl(page: Int) = "$v3apiUrl/classify/0/0/${page - 1}.json"
|
fun popularMangaUrl(page: Int) = "$v3apiUrl/classify/0/0/${page - 1}.json"
|
||||||
|
@ -33,7 +33,15 @@ object ApiV3 {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun parseChapterListV1(response: Response): List<SChapter> {
|
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"
|
fun chapterCommentsUrl(path: String) = "$v3apiUrl/viewPoint/0/$path.json"
|
||||||
|
@ -92,7 +100,7 @@ object ApiV3 {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
class DataDto(val info: MangaDto, val list: List<ChapterDto>)
|
class DataDto(val info: MangaDto, val list: List<ChapterDto>, val alone: List<ChapterDto>)
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
class ResponseDto(val data: DataDto)
|
class ResponseDto(val data: DataDto)
|
||||||
|
|
|
@ -18,8 +18,8 @@ import kotlin.reflect.typeOf
|
||||||
|
|
||||||
object ApiV4 {
|
object ApiV4 {
|
||||||
|
|
||||||
private const val v4apiUrl = "https://nnv4api.dmzj.com"
|
private const val v4apiUrl = "https://nnv4api.idmzj.com"
|
||||||
private const val imageSmallCDNUrl = "https://imgsmall.dmzj.com"
|
private const val imageSmallCDNUrl = "https://imgsmall.idmzj.com"
|
||||||
|
|
||||||
fun mangaInfoUrl(id: String) = "$v4apiUrl/comic/detail/$id?uid=2665531"
|
fun mangaInfoUrl(id: String) = "$v4apiUrl/comic/detail/$id?uid=2665531"
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ class Dmzj : ConfigurableSource, HttpSource() {
|
||||||
override val lang = "zh"
|
override val lang = "zh"
|
||||||
override val supportsLatest = true
|
override val supportsLatest = true
|
||||||
override val name = "动漫之家"
|
override val name = "动漫之家"
|
||||||
override val baseUrl = "https://m.dmzj.com"
|
override val baseUrl = "https://m.idmzj.com"
|
||||||
|
|
||||||
private val preferences: SharedPreferences by lazy {
|
private val preferences: SharedPreferences by lazy {
|
||||||
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
|
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
|
||||||
|
@ -47,7 +47,7 @@ class Dmzj : ConfigurableSource, HttpSource() {
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
private fun fetchIdBySlug(slug: String): String {
|
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 html = client.newCall(request).execute().body.string()
|
||||||
val start = "g_comic_id = \""
|
val start = "g_comic_id = \""
|
||||||
val startIndex = html.indexOf(start) + start.length
|
val startIndex = html.indexOf(start) + start.length
|
||||||
|
@ -133,7 +133,6 @@ class Dmzj : ConfigurableSource, HttpSource() {
|
||||||
throw UnsupportedOperationException()
|
throw UnsupportedOperationException()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bypass mangaDetailsRequest, fetch api url directly
|
|
||||||
override fun fetchMangaDetails(manga: SManga): Observable<SManga> {
|
override fun fetchMangaDetails(manga: SManga): Observable<SManga> {
|
||||||
val id = manga.url.extractMangaId()
|
val id = manga.url.extractMangaId()
|
||||||
return Observable.fromCallable { fetchMangaDetails(id) }
|
return Observable.fromCallable { fetchMangaDetails(id) }
|
||||||
|
@ -147,11 +146,13 @@ class Dmzj : ConfigurableSource, HttpSource() {
|
||||||
return ApiV3.parseMangaDetailsV1(response)
|
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 {
|
override fun mangaDetailsRequest(manga: SManga): Request {
|
||||||
|
throw UnsupportedOperationException()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getMangaUrl(manga: SManga): String {
|
||||||
val cid = manga.url.extractMangaId()
|
val cid = manga.url.extractMangaId()
|
||||||
return GET("$baseUrl/info/$cid.html")
|
return "$baseUrl/info/$cid.html"
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun mangaDetailsParse(response: Response) = SManga.create().apply {
|
override fun mangaDetailsParse(response: Response) = SManga.create().apply {
|
||||||
|
@ -178,8 +179,7 @@ class Dmzj : ConfigurableSource, HttpSource() {
|
||||||
throw UnsupportedOperationException()
|
throw UnsupportedOperationException()
|
||||||
}
|
}
|
||||||
|
|
||||||
// for WebView, headers are not needed
|
override fun getChapterUrl(chapter: SChapter) = "$baseUrl/view/${chapter.url}.html"
|
||||||
override fun pageListRequest(chapter: SChapter) = GET("$baseUrl/view/${chapter.url}.html")
|
|
||||||
|
|
||||||
override fun fetchPageList(chapter: SChapter): Observable<List<Page>> {
|
override fun fetchPageList(chapter: SChapter): Observable<List<Page>> {
|
||||||
val path = chapter.url
|
val path = chapter.url
|
||||||
|
|
Loading…
Reference in New Issue