Tweak MangaDex status handling to match Neko and SY behavior. (#12123)

This commit is contained in:
Alessandro Jean 2022-06-07 21:47:10 -03:00 committed by GitHub
parent 1de4b7e286
commit b197d624f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 15 deletions

View File

@ -6,7 +6,7 @@ ext {
extName = 'MangaDex'
pkgNameSuffix = 'all.mangadex'
extClass = '.MangaDexFactory'
extVersionCode = 162
extVersionCode = 163
isNsfw = true
}

View File

@ -86,27 +86,26 @@ class MangaDexHelper(private val lang: String) {
}
/**
* Maps dex status to tachi status
* Maps dex status to Tachi status.
* Adapted from the MangaDex handler from TachiyomiSY.
*/
fun getPublicationStatus(attr: MangaAttributesDto, chapters: List<String>): Int {
return when (attr.status) {
null -> SManga.UNKNOWN
val tempStatus = when (attr.status) {
"ongoing" -> SManga.ONGOING
"completed", "cancelled" -> doubleCheckChapters(attr, chapters)
"hiatus" -> SManga.ONGOING
"cancelled" -> SManga.CANCELLED
"completed" -> SManga.PUBLISHING_FINISHED
"hiatus" -> SManga.ON_HIATUS
else -> SManga.UNKNOWN
}
}
/**
* if the manga is 'completed' or 'cancelled' then it'll have a lastChapter in the manga obj.
* if the simple list of chapters contains that lastChapter, then we can consider it completed.
*/
private fun doubleCheckChapters(attr: MangaAttributesDto, chapters: List<String>): Int {
return if (chapters.contains(attr.lastChapter))
val publishedOrCancelled = tempStatus == SManga.PUBLISHING_FINISHED ||
tempStatus == SManga.CANCELLED
return if (chapters.contains(attr.lastChapter) && publishedOrCancelled) {
SManga.COMPLETED
else
SManga.UNKNOWN
} else {
tempStatus
}
}
fun parseDate(dateAsString: String): Long =