Fix CatManga manga list (#9596)

This commit is contained in:
Ivan Iskandar 2021-10-23 18:36:33 +07:00 committed by GitHub
parent 551cc08849
commit a676a1ba55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 43 additions and 51 deletions

View File

@ -6,7 +6,7 @@ ext {
extName = 'CatManga' extName = 'CatManga'
pkgNameSuffix = "en.catmanga" pkgNameSuffix = "en.catmanga"
extClass = '.CatManga' extClass = '.CatManga'
extVersionCode = 6 extVersionCode = 7
} }
apply from: "$rootDir/common.gradle" apply from: "$rootDir/common.gradle"

View File

@ -8,13 +8,13 @@ data class CatSeries(
val alt_titles: List<String>, val alt_titles: List<String>,
val authors: List<String>, val authors: List<String>,
val genres: List<String>, val genres: List<String>,
val chapters: List<CatSeriesChapter>, val chapters: List<CatSeriesChapter>? = null,
val title: String, val title: String,
val series_id: String, val series_id: String,
val description: String, val description: String,
val status: String, val status: String,
val cover_art: CatSeriesCover, val cover_art: CatSeriesCover,
val all_covers: List<CatSeriesCover> val all_covers: List<CatSeriesCover>? = null
) { ) {
fun toSManga() = this.let { series -> fun toSManga() = this.let { series ->
SManga.create().apply { SManga.create().apply {
@ -30,9 +30,6 @@ data class CatSeries(
else -> SManga.UNKNOWN else -> SManga.UNKNOWN
} }
if (chapters.isEmpty()) {
description = "[COMING SOON] $description"
}
if (alt_titles.isNotEmpty()) { if (alt_titles.isNotEmpty()) {
description += "\n\nAlternative titles:\n" description += "\n\nAlternative titles:\n"
alt_titles.forEach { alt_titles.forEach {

View File

@ -40,6 +40,11 @@ class CatManga : HttpSource() {
override fun searchMangaRequest(page: Int, query: String, filters: FilterList) = allSeriesRequest override fun searchMangaRequest(page: Int, query: String, filters: FilterList) = allSeriesRequest
override fun chapterListRequest(manga: SManga): Request {
val seriesId = manga.url.substringAfter("/series/")
return GET("$baseUrl/api/series/$seriesId")
}
override fun fetchSearchManga(page: Int, query: String, filters: FilterList): Observable<MangasPage> { override fun fetchSearchManga(page: Int, query: String, filters: FilterList): Observable<MangasPage> {
return client.newCall(searchMangaRequest(page, query, filters)) return client.newCall(searchMangaRequest(page, query, filters))
.asObservableSuccess() .asObservableSuccess()
@ -69,16 +74,11 @@ class CatManga : HttpSource() {
} }
} }
override fun fetchChapterList(manga: SManga): Observable<List<SChapter>> { override fun chapterListParse(response: Response): List<SChapter> {
val seriesId = manga.url.substringAfter("/series/") val series = json.decodeFromString<CatSeries>(response.body!!.string())
return client.newCall(allSeriesRequest) val seriesPrefs = application.getSharedPreferences("source_${id}_time_found:${series.series_id}", 0)
.asObservableSuccess()
.map { response ->
val seriesPrefs = application.getSharedPreferences("source_${id}_time_found:$seriesId", 0)
val seriesPrefsEditor = seriesPrefs.edit() val seriesPrefsEditor = seriesPrefs.edit()
val chapters = json.decodeFromString<List<CatSeries>>(response.body!!.string()) val chapters = series.chapters!!
.find { it.series_id == seriesId }!!
.chapters
.asReversed() .asReversed()
.map { chapter -> .map { chapter ->
val title = chapter.title ?: "" val title = chapter.title ?: ""
@ -86,7 +86,7 @@ class CatManga : HttpSource() {
val numberUrl = chapter.number.chapterNumberToUrlPath() val numberUrl = chapter.number.chapterNumberToUrlPath()
val displayNumber = chapter.display_number ?: numberUrl val displayNumber = chapter.display_number ?: numberUrl
SChapter.create().apply { SChapter.create().apply {
url = "${manga.url}/$numberUrl" url = "/series/${series.series_id}/$numberUrl"
chapter_number = chapter.number chapter_number = chapter.number
scanlator = groups scanlator = groups
@ -111,8 +111,7 @@ class CatManga : HttpSource() {
} }
} }
seriesPrefsEditor.apply() seriesPrefsEditor.apply()
chapters return chapters
}
} }
override fun popularMangaParse(response: Response): MangasPage { override fun popularMangaParse(response: Response): MangasPage {
@ -166,10 +165,6 @@ class CatManga : HttpSource() {
throw UnsupportedOperationException("Not used.") throw UnsupportedOperationException("Not used.")
} }
override fun chapterListParse(response: Response): List<SChapter> {
throw UnsupportedOperationException("Not used.")
}
override fun searchMangaParse(response: Response): MangasPage { override fun searchMangaParse(response: Response): MangasPage {
throw UnsupportedOperationException("Not used.") throw UnsupportedOperationException("Not used.")
} }