diff --git a/src/all/mangadex/build.gradle b/src/all/mangadex/build.gradle index d2e1602d5..51b7cd92c 100644 --- a/src/all/mangadex/build.gradle +++ b/src/all/mangadex/build.gradle @@ -6,7 +6,7 @@ ext { extName = 'MangaDex' pkgNameSuffix = 'all.mangadex' extClass = '.MangaDexFactory' - extVersionCode = 134 + extVersionCode = 135 containsNsfw = true } diff --git a/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/MangaDex.kt b/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/MangaDex.kt index ff3137d12..167cd422f 100644 --- a/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/MangaDex.kt +++ b/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/MangaDex.kt @@ -133,11 +133,11 @@ abstract class MangaDex(override val lang: String, val dexLang: String) : val coverSuffix = preferences.getString(MDConstants.getCoverQualityPreferenceKey(dexLang), "") - val mangaList = mangaListDto.results.map { mangaDto -> - val fileName = mangaDto.data.relationships.firstOrNull { relationshipDto -> + val mangaList = mangaListDto.data.map { mangaDataDto -> + val fileName = mangaDataDto.relationships.firstOrNull { relationshipDto -> relationshipDto.type.equals(MDConstants.coverArt, true) }?.attributes?.fileName - helper.createBasicManga(mangaDto, fileName, coverSuffix) + helper.createBasicManga(mangaDataDto, fileName, coverSuffix) } return MangasPage(mangaList, hasMoreResults) @@ -148,7 +148,7 @@ abstract class MangaDex(override val lang: String, val dexLang: String) : val chapterListDto = helper.json.decodeFromString(response.body!!.string()) 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() 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 mangaListDto = helper.json.decodeFromString(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 mangaList = mangaIds.mapNotNull { mangaDtoMap[it] }.map { mangaDto -> - val fileName = mangaDto.data.relationships.firstOrNull { relationshipDto -> + val mangaList = mangaIds.mapNotNull { mangaDtoMap[it] }.map { mangaDataDto -> + val fileName = mangaDataDto.relationships.firstOrNull { relationshipDto -> relationshipDto.type.equals(MDConstants.coverArt, true) relationshipDto.type.equals(MDConstants.coverArt, true) }?.attributes?.fileName - helper.createBasicManga(mangaDto, fileName, coverSuffix) + helper.createBasicManga(mangaDataDto, fileName, coverSuffix) } return MangasPage(mangaList, hasMoreResults) @@ -318,7 +318,7 @@ abstract class MangaDex(override val lang: String, val dexLang: String) : val shortLang = lang.substringBefore("-") 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 { val chapterListResponse = helper.json.decodeFromString(response.body!!.string()) - val chapterListResults = chapterListResponse.results.toMutableList() + val chapterListResults = chapterListResponse.data.toMutableList() val mangaId = response.request.url.toString().substringBefore("/feed") @@ -392,7 +392,7 @@ abstract class MangaDex(override val lang: String, val dexLang: String) : val newResponse = client.newCall(actualChapterListRequest(mangaId, offset)).execute() val newChapterList = helper.json.decodeFromString(newResponse.body!!.string()) - chapterListResults.addAll(newChapterList.results) + chapterListResults.addAll(newChapterList.data) hasMoreResults = (limit + offset) < newChapterList.total } diff --git a/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/MangaDexHelper.kt b/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/MangaDexHelper.kt index e4f13d4ac..a734b79f5 100644 --- a/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/MangaDexHelper.kt +++ b/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/MangaDexHelper.kt @@ -2,9 +2,9 @@ package eu.kanade.tachiyomi.extension.all.mangadex import android.util.Log 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.MangaDto +import eu.kanade.tachiyomi.extension.all.mangadex.dto.MangaDataDto import eu.kanade.tachiyomi.extension.all.mangadex.dto.asMdMap import eu.kanade.tachiyomi.network.GET import eu.kanade.tachiyomi.source.model.Page @@ -166,15 +166,15 @@ class MangaDexHelper() { /** * 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 { - url = "/manga/${mangaDto.data.id}" - title = cleanString(mangaDto.data.attributes.title.asMdMap()["en"] ?: "") + url = "/manga/${mangaDataDto.id}" + title = cleanString(mangaDataDto.attributes.title.asMdMap()["en"] ?: "") coverFileName?.let { thumbnail_url = when (coverSuffix != null && coverSuffix != "") { - true -> "${MDConstants.cdnUrl}/covers/${mangaDto.data.id}/$coverFileName$coverSuffix" - else -> "${MDConstants.cdnUrl}/covers/${mangaDto.data.id}/$coverFileName" + true -> "${MDConstants.cdnUrl}/covers/${mangaDataDto.id}/$coverFileName$coverSuffix" + else -> "${MDConstants.cdnUrl}/covers/${mangaDataDto.id}/$coverFileName" } } } @@ -183,10 +183,9 @@ class MangaDexHelper() { /** * Create an SManga from json element with all details */ - fun createManga(mangaDto: MangaDto, chapters: List, lang: String, coverSuffix: String?): SManga { + fun createManga(mangaDataDto: MangaDataDto, chapters: List, lang: String, coverSuffix: String?): SManga { try { - val data = mangaDto.data - val attr = data.attributes + val attr = mangaDataDto.attributes // things that will go with the genre tags but aren't actually genre @@ -204,15 +203,15 @@ class MangaDexHelper() { Locale(attr.originalLanguage ?: "").displayLanguage ) - val authors = mangaDto.data.relationships.filter { relationshipDto -> + val authors = mangaDataDto.relationships.filter { relationshipDto -> relationshipDto.type.equals(MDConstants.author, true) }.mapNotNull { it.attributes!!.name }.distinct() - val artists = mangaDto.data.relationships.filter { relationshipDto -> + val artists = mangaDataDto.relationships.filter { relationshipDto -> relationshipDto.type.equals(MDConstants.artist, true) }.mapNotNull { it.attributes!!.name }.distinct() - val coverFileName = mangaDto.data.relationships.firstOrNull { relationshipDto -> + val coverFileName = mangaDataDto.relationships.firstOrNull { relationshipDto -> relationshipDto.type.equals(MDConstants.coverArt, true) }?.attributes?.fileName @@ -222,7 +221,7 @@ class MangaDexHelper() { // map ids to tag names val genreList = ( attr.tags - .map { it.id } + .map { mangaDataDto.id } .map { dexId -> tags.firstOrNull { it.id == dexId } } @@ -232,7 +231,7 @@ class MangaDexHelper() { .filter { it.isNullOrBlank().not() } val desc = attr.description.asMdMap() - return createBasicManga(mangaDto, coverFileName, coverSuffix).apply { + return createBasicManga(mangaDataDto, coverFileName, coverSuffix).apply { description = cleanString(desc[lang] ?: desc["en"] ?: "") author = authors.joinToString(", ") artist = artists.joinToString(", ") @@ -248,12 +247,11 @@ class MangaDexHelper() { /** * create the SChapter from json */ - fun createChapter(chapterDto: ChapterDto): SChapter? { + fun createChapter(chapterDataDto: ChapterDataDto): SChapter? { try { - val data = chapterDto.data - val attr = data.attributes + val attr = chapterDataDto.attributes - val groups = chapterDto.data.relationships.filter { relationshipDto -> + val groups = chapterDataDto.relationships.filter { relationshipDto -> relationshipDto.type.equals( MDConstants.scanlator, true @@ -299,7 +297,7 @@ class MangaDexHelper() { // In future calculate [END] if non mvp api doesnt provide it return SChapter.create().apply { - url = "/chapter/${data.id}" + url = "/chapter/${chapterDataDto.id}" name = cleanString(chapterName.joinToString(" ")) date_upload = parseDate(attr.publishAt) scanlator = groups diff --git a/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/dto/ChapterDto.kt b/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/dto/ChapterDto.kt index 28db2d6af..05aebaa9c 100644 --- a/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/dto/ChapterDto.kt +++ b/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/dto/ChapterDto.kt @@ -7,7 +7,7 @@ data class ChapterListDto( val limit: Int, val offset: Int, val total: Int, - val results: List, + val data: List, ) @Serializable diff --git a/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/dto/MangaDto.kt b/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/dto/MangaDto.kt index e93f85d15..0eb7e4cc1 100644 --- a/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/dto/MangaDto.kt +++ b/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/dto/MangaDto.kt @@ -11,7 +11,7 @@ data class MangaListDto( val limit: Int, val offset: Int, val total: Int, - val results: List, + val data: List, ) @Serializable