mangadex filter out mangaplus chapters since it can't open them (#2032)

This commit is contained in:
Carlos 2020-01-09 16:03:51 -05:00 committed by GitHub
parent 2ff980a9f7
commit eaa687aa0b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 2 deletions

View File

@ -5,7 +5,7 @@ ext {
appName = 'Tachiyomi: MangaDex'
pkgNameSuffix = 'all.mangadex'
extClass = '.MangadexFactory'
extVersionCode = 76
extVersionCode = 77
libVersion = '1.2'
}

View File

@ -452,13 +452,28 @@ abstract class Mangadex(
// Skip chapters that don't match the desired language, or are future releases
chapterJson?.forEach { key, jsonElement ->
val chapterElement = jsonElement.asJsonObject
if (chapterElement.get("lang_code").string == internalLang && (chapterElement.get("timestamp").asLong * 1000) <= now) {
if (shouldKeepChapter(chapterElement, now)) {
chapters.add(chapterFromJson(key, chapterElement, finalChapterNumber, status))
}
}
return chapters
}
/**filter out the following chapters
* language doesn't match the chosen language
* future chapters
* chapters from manga plus since they have to be read in mangaplus extension
*
*/
private fun shouldKeepChapter(chapterJson: JsonObject, now: Long): Boolean {
return when {
chapterJson.get("lang_code").string != internalLang -> false
(chapterJson.get("timestamp").asLong * 1000) > now -> false
chapterJson.get("group_id").string == "9097" -> false
else -> true
}
}
private fun chapterFromJson(chapterId: String, chapterJson: JsonObject, finalChapterNumber: String, status: Int): SChapter {
val chapter = SChapter.create()
chapter.url = API_CHAPTER + chapterId