Update Mangadex to new `chapterListDto` and `MangaListDto` following deprecation (#9046)
* update chapterListDto * update MangaListDto * increment md.extvercode
This commit is contained in:
parent
9901f97b5d
commit
fb87b363e6
|
@ -6,7 +6,7 @@ ext {
|
||||||
extName = 'MangaDex'
|
extName = 'MangaDex'
|
||||||
pkgNameSuffix = 'all.mangadex'
|
pkgNameSuffix = 'all.mangadex'
|
||||||
extClass = '.MangaDexFactory'
|
extClass = '.MangaDexFactory'
|
||||||
extVersionCode = 134
|
extVersionCode = 135
|
||||||
containsNsfw = true
|
containsNsfw = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -133,11 +133,11 @@ abstract class MangaDex(override val lang: String, val dexLang: String) :
|
||||||
|
|
||||||
val coverSuffix = preferences.getString(MDConstants.getCoverQualityPreferenceKey(dexLang), "")
|
val coverSuffix = preferences.getString(MDConstants.getCoverQualityPreferenceKey(dexLang), "")
|
||||||
|
|
||||||
val mangaList = mangaListDto.results.map { mangaDto ->
|
val mangaList = mangaListDto.data.map { mangaDataDto ->
|
||||||
val fileName = mangaDto.data.relationships.firstOrNull { relationshipDto ->
|
val fileName = mangaDataDto.relationships.firstOrNull { relationshipDto ->
|
||||||
relationshipDto.type.equals(MDConstants.coverArt, true)
|
relationshipDto.type.equals(MDConstants.coverArt, true)
|
||||||
}?.attributes?.fileName
|
}?.attributes?.fileName
|
||||||
helper.createBasicManga(mangaDto, fileName, coverSuffix)
|
helper.createBasicManga(mangaDataDto, fileName, coverSuffix)
|
||||||
}
|
}
|
||||||
|
|
||||||
return MangasPage(mangaList, hasMoreResults)
|
return MangasPage(mangaList, hasMoreResults)
|
||||||
|
@ -148,7 +148,7 @@ abstract class MangaDex(override val lang: String, val dexLang: String) :
|
||||||
val chapterListDto = helper.json.decodeFromString<ChapterListDto>(response.body!!.string())
|
val chapterListDto = helper.json.decodeFromString<ChapterListDto>(response.body!!.string())
|
||||||
val hasMoreResults = chapterListDto.limit + chapterListDto.offset < chapterListDto.total
|
val hasMoreResults = chapterListDto.limit + chapterListDto.offset < chapterListDto.total
|
||||||
|
|
||||||
val mangaIds = chapterListDto.results.map { it.data.relationships }.flatten()
|
val mangaIds = chapterListDto.data.map { it.relationships }.flatten()
|
||||||
.filter { it.type == MDConstants.manga }.map { it.id }.distinct()
|
.filter { it.type == MDConstants.manga }.map { it.id }.distinct()
|
||||||
|
|
||||||
val mangaUrl = MDConstants.apiMangaUrl.toHttpUrlOrNull()!!.newBuilder().apply {
|
val mangaUrl = MDConstants.apiMangaUrl.toHttpUrlOrNull()!!.newBuilder().apply {
|
||||||
|
@ -176,16 +176,16 @@ abstract class MangaDex(override val lang: String, val dexLang: String) :
|
||||||
val mangaResponse = client.newCall(GET(mangaUrl, headers, CacheControl.FORCE_NETWORK)).execute()
|
val mangaResponse = client.newCall(GET(mangaUrl, headers, CacheControl.FORCE_NETWORK)).execute()
|
||||||
val mangaListDto = helper.json.decodeFromString<MangaListDto>(mangaResponse.body!!.string())
|
val mangaListDto = helper.json.decodeFromString<MangaListDto>(mangaResponse.body!!.string())
|
||||||
|
|
||||||
val mangaDtoMap = mangaListDto.results.associateBy({ it.data.id }, { it })
|
val mangaDtoMap = mangaListDto.data.associateBy({ it.id }, { it })
|
||||||
|
|
||||||
val coverSuffix = preferences.getString(MDConstants.getCoverQualityPreferenceKey(dexLang), "")
|
val coverSuffix = preferences.getString(MDConstants.getCoverQualityPreferenceKey(dexLang), "")
|
||||||
|
|
||||||
val mangaList = mangaIds.mapNotNull { mangaDtoMap[it] }.map { mangaDto ->
|
val mangaList = mangaIds.mapNotNull { mangaDtoMap[it] }.map { mangaDataDto ->
|
||||||
val fileName = mangaDto.data.relationships.firstOrNull { relationshipDto ->
|
val fileName = mangaDataDto.relationships.firstOrNull { relationshipDto ->
|
||||||
relationshipDto.type.equals(MDConstants.coverArt, true)
|
relationshipDto.type.equals(MDConstants.coverArt, true)
|
||||||
relationshipDto.type.equals(MDConstants.coverArt, true)
|
relationshipDto.type.equals(MDConstants.coverArt, true)
|
||||||
}?.attributes?.fileName
|
}?.attributes?.fileName
|
||||||
helper.createBasicManga(mangaDto, fileName, coverSuffix)
|
helper.createBasicManga(mangaDataDto, fileName, coverSuffix)
|
||||||
}
|
}
|
||||||
|
|
||||||
return MangasPage(mangaList, hasMoreResults)
|
return MangasPage(mangaList, hasMoreResults)
|
||||||
|
@ -318,7 +318,7 @@ abstract class MangaDex(override val lang: String, val dexLang: String) :
|
||||||
val shortLang = lang.substringBefore("-")
|
val shortLang = lang.substringBefore("-")
|
||||||
|
|
||||||
val coverSuffix = preferences.getString(MDConstants.getCoverQualityPreferenceKey(dexLang), "")
|
val coverSuffix = preferences.getString(MDConstants.getCoverQualityPreferenceKey(dexLang), "")
|
||||||
return helper.createManga(manga, fetchSimpleChapterList(manga, shortLang), shortLang, coverSuffix)
|
return helper.createManga(manga.data, fetchSimpleChapterList(manga, shortLang), shortLang, coverSuffix)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -374,7 +374,7 @@ abstract class MangaDex(override val lang: String, val dexLang: String) :
|
||||||
try {
|
try {
|
||||||
val chapterListResponse = helper.json.decodeFromString<ChapterListDto>(response.body!!.string())
|
val chapterListResponse = helper.json.decodeFromString<ChapterListDto>(response.body!!.string())
|
||||||
|
|
||||||
val chapterListResults = chapterListResponse.results.toMutableList()
|
val chapterListResults = chapterListResponse.data.toMutableList()
|
||||||
|
|
||||||
val mangaId =
|
val mangaId =
|
||||||
response.request.url.toString().substringBefore("/feed")
|
response.request.url.toString().substringBefore("/feed")
|
||||||
|
@ -392,7 +392,7 @@ abstract class MangaDex(override val lang: String, val dexLang: String) :
|
||||||
val newResponse =
|
val newResponse =
|
||||||
client.newCall(actualChapterListRequest(mangaId, offset)).execute()
|
client.newCall(actualChapterListRequest(mangaId, offset)).execute()
|
||||||
val newChapterList = helper.json.decodeFromString<ChapterListDto>(newResponse.body!!.string())
|
val newChapterList = helper.json.decodeFromString<ChapterListDto>(newResponse.body!!.string())
|
||||||
chapterListResults.addAll(newChapterList.results)
|
chapterListResults.addAll(newChapterList.data)
|
||||||
hasMoreResults = (limit + offset) < newChapterList.total
|
hasMoreResults = (limit + offset) < newChapterList.total
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,9 +2,9 @@ package eu.kanade.tachiyomi.extension.all.mangadex
|
||||||
|
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import eu.kanade.tachiyomi.extension.all.mangadex.dto.AtHomeDto
|
import eu.kanade.tachiyomi.extension.all.mangadex.dto.AtHomeDto
|
||||||
import eu.kanade.tachiyomi.extension.all.mangadex.dto.ChapterDto
|
import eu.kanade.tachiyomi.extension.all.mangadex.dto.ChapterDataDto
|
||||||
import eu.kanade.tachiyomi.extension.all.mangadex.dto.MangaAttributesDto
|
import eu.kanade.tachiyomi.extension.all.mangadex.dto.MangaAttributesDto
|
||||||
import eu.kanade.tachiyomi.extension.all.mangadex.dto.MangaDto
|
import eu.kanade.tachiyomi.extension.all.mangadex.dto.MangaDataDto
|
||||||
import eu.kanade.tachiyomi.extension.all.mangadex.dto.asMdMap
|
import eu.kanade.tachiyomi.extension.all.mangadex.dto.asMdMap
|
||||||
import eu.kanade.tachiyomi.network.GET
|
import eu.kanade.tachiyomi.network.GET
|
||||||
import eu.kanade.tachiyomi.source.model.Page
|
import eu.kanade.tachiyomi.source.model.Page
|
||||||
|
@ -166,15 +166,15 @@ class MangaDexHelper() {
|
||||||
/**
|
/**
|
||||||
* create an SManga from json element only basic elements
|
* create an SManga from json element only basic elements
|
||||||
*/
|
*/
|
||||||
fun createBasicManga(mangaDto: MangaDto, coverFileName: String?, coverSuffix: String?): SManga {
|
fun createBasicManga(mangaDataDto: MangaDataDto, coverFileName: String?, coverSuffix: String?): SManga {
|
||||||
return SManga.create().apply {
|
return SManga.create().apply {
|
||||||
url = "/manga/${mangaDto.data.id}"
|
url = "/manga/${mangaDataDto.id}"
|
||||||
title = cleanString(mangaDto.data.attributes.title.asMdMap()["en"] ?: "")
|
title = cleanString(mangaDataDto.attributes.title.asMdMap()["en"] ?: "")
|
||||||
|
|
||||||
coverFileName?.let {
|
coverFileName?.let {
|
||||||
thumbnail_url = when (coverSuffix != null && coverSuffix != "") {
|
thumbnail_url = when (coverSuffix != null && coverSuffix != "") {
|
||||||
true -> "${MDConstants.cdnUrl}/covers/${mangaDto.data.id}/$coverFileName$coverSuffix"
|
true -> "${MDConstants.cdnUrl}/covers/${mangaDataDto.id}/$coverFileName$coverSuffix"
|
||||||
else -> "${MDConstants.cdnUrl}/covers/${mangaDto.data.id}/$coverFileName"
|
else -> "${MDConstants.cdnUrl}/covers/${mangaDataDto.id}/$coverFileName"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -183,10 +183,9 @@ class MangaDexHelper() {
|
||||||
/**
|
/**
|
||||||
* Create an SManga from json element with all details
|
* Create an SManga from json element with all details
|
||||||
*/
|
*/
|
||||||
fun createManga(mangaDto: MangaDto, chapters: List<String>, lang: String, coverSuffix: String?): SManga {
|
fun createManga(mangaDataDto: MangaDataDto, chapters: List<String>, lang: String, coverSuffix: String?): SManga {
|
||||||
try {
|
try {
|
||||||
val data = mangaDto.data
|
val attr = mangaDataDto.attributes
|
||||||
val attr = data.attributes
|
|
||||||
|
|
||||||
// things that will go with the genre tags but aren't actually genre
|
// things that will go with the genre tags but aren't actually genre
|
||||||
|
|
||||||
|
@ -204,15 +203,15 @@ class MangaDexHelper() {
|
||||||
Locale(attr.originalLanguage ?: "").displayLanguage
|
Locale(attr.originalLanguage ?: "").displayLanguage
|
||||||
)
|
)
|
||||||
|
|
||||||
val authors = mangaDto.data.relationships.filter { relationshipDto ->
|
val authors = mangaDataDto.relationships.filter { relationshipDto ->
|
||||||
relationshipDto.type.equals(MDConstants.author, true)
|
relationshipDto.type.equals(MDConstants.author, true)
|
||||||
}.mapNotNull { it.attributes!!.name }.distinct()
|
}.mapNotNull { it.attributes!!.name }.distinct()
|
||||||
|
|
||||||
val artists = mangaDto.data.relationships.filter { relationshipDto ->
|
val artists = mangaDataDto.relationships.filter { relationshipDto ->
|
||||||
relationshipDto.type.equals(MDConstants.artist, true)
|
relationshipDto.type.equals(MDConstants.artist, true)
|
||||||
}.mapNotNull { it.attributes!!.name }.distinct()
|
}.mapNotNull { it.attributes!!.name }.distinct()
|
||||||
|
|
||||||
val coverFileName = mangaDto.data.relationships.firstOrNull { relationshipDto ->
|
val coverFileName = mangaDataDto.relationships.firstOrNull { relationshipDto ->
|
||||||
relationshipDto.type.equals(MDConstants.coverArt, true)
|
relationshipDto.type.equals(MDConstants.coverArt, true)
|
||||||
}?.attributes?.fileName
|
}?.attributes?.fileName
|
||||||
|
|
||||||
|
@ -222,7 +221,7 @@ class MangaDexHelper() {
|
||||||
// map ids to tag names
|
// map ids to tag names
|
||||||
val genreList = (
|
val genreList = (
|
||||||
attr.tags
|
attr.tags
|
||||||
.map { it.id }
|
.map { mangaDataDto.id }
|
||||||
.map { dexId ->
|
.map { dexId ->
|
||||||
tags.firstOrNull { it.id == dexId }
|
tags.firstOrNull { it.id == dexId }
|
||||||
}
|
}
|
||||||
|
@ -232,7 +231,7 @@ class MangaDexHelper() {
|
||||||
.filter { it.isNullOrBlank().not() }
|
.filter { it.isNullOrBlank().not() }
|
||||||
|
|
||||||
val desc = attr.description.asMdMap()
|
val desc = attr.description.asMdMap()
|
||||||
return createBasicManga(mangaDto, coverFileName, coverSuffix).apply {
|
return createBasicManga(mangaDataDto, coverFileName, coverSuffix).apply {
|
||||||
description = cleanString(desc[lang] ?: desc["en"] ?: "")
|
description = cleanString(desc[lang] ?: desc["en"] ?: "")
|
||||||
author = authors.joinToString(", ")
|
author = authors.joinToString(", ")
|
||||||
artist = artists.joinToString(", ")
|
artist = artists.joinToString(", ")
|
||||||
|
@ -248,12 +247,11 @@ class MangaDexHelper() {
|
||||||
/**
|
/**
|
||||||
* create the SChapter from json
|
* create the SChapter from json
|
||||||
*/
|
*/
|
||||||
fun createChapter(chapterDto: ChapterDto): SChapter? {
|
fun createChapter(chapterDataDto: ChapterDataDto): SChapter? {
|
||||||
try {
|
try {
|
||||||
val data = chapterDto.data
|
val attr = chapterDataDto.attributes
|
||||||
val attr = data.attributes
|
|
||||||
|
|
||||||
val groups = chapterDto.data.relationships.filter { relationshipDto ->
|
val groups = chapterDataDto.relationships.filter { relationshipDto ->
|
||||||
relationshipDto.type.equals(
|
relationshipDto.type.equals(
|
||||||
MDConstants.scanlator,
|
MDConstants.scanlator,
|
||||||
true
|
true
|
||||||
|
@ -299,7 +297,7 @@ class MangaDexHelper() {
|
||||||
// In future calculate [END] if non mvp api doesnt provide it
|
// In future calculate [END] if non mvp api doesnt provide it
|
||||||
|
|
||||||
return SChapter.create().apply {
|
return SChapter.create().apply {
|
||||||
url = "/chapter/${data.id}"
|
url = "/chapter/${chapterDataDto.id}"
|
||||||
name = cleanString(chapterName.joinToString(" "))
|
name = cleanString(chapterName.joinToString(" "))
|
||||||
date_upload = parseDate(attr.publishAt)
|
date_upload = parseDate(attr.publishAt)
|
||||||
scanlator = groups
|
scanlator = groups
|
||||||
|
|
|
@ -7,7 +7,7 @@ data class ChapterListDto(
|
||||||
val limit: Int,
|
val limit: Int,
|
||||||
val offset: Int,
|
val offset: Int,
|
||||||
val total: Int,
|
val total: Int,
|
||||||
val results: List<ChapterDto>,
|
val data: List<ChapterDataDto>,
|
||||||
)
|
)
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
|
|
|
@ -11,7 +11,7 @@ data class MangaListDto(
|
||||||
val limit: Int,
|
val limit: Int,
|
||||||
val offset: Int,
|
val offset: Int,
|
||||||
val total: Int,
|
val total: Int,
|
||||||
val results: List<MangaDto>,
|
val data: List<MangaDataDto>,
|
||||||
)
|
)
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
|
|
Loading…
Reference in New Issue