diff --git a/src/all/mangadex/build.gradle b/src/all/mangadex/build.gradle index 41b38de89..d885267f6 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 = 132 + extVersionCode = 133 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 c930d9662..1f10b3f1e 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 @@ -134,7 +134,7 @@ 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.relationships.firstOrNull { relationshipDto -> + val fileName = mangaDto.data.relationships.firstOrNull { relationshipDto -> relationshipDto.type.equals(MDConstants.coverArt, true) }?.attributes?.fileName helper.createBasicManga(mangaDto, fileName, coverSuffix) @@ -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.relationships }.flatten() + val mangaIds = chapterListDto.results.map { it.data.relationships }.flatten() .filter { it.type == MDConstants.manga }.map { it.id }.distinct() val mangaUrl = MDConstants.apiMangaUrl.toHttpUrlOrNull()!!.newBuilder().apply { @@ -167,17 +167,6 @@ abstract class MangaDex(override val lang: String, val dexLang: String) : if (preferences.getBoolean(MDConstants.getContentRatingPornographicPrefKey(dexLang), false)) { addQueryParameter("contentRating[]", "pornographic") } - if (preferences.getBoolean(MDConstants.getOriginalLanguageJapanesePref(dexLang), false)) { - addQueryParameter("originalLanguage[]", "ja") - } - // dex has zh and zh-hk for chinese manhua - if (preferences.getBoolean(MDConstants.getOriginalLanguageChinesePref(dexLang), false)) { - addQueryParameter("originalLanguage[]", "zh") - addQueryParameter("originalLanguage[]", "zh-hk") - } - if (preferences.getBoolean(MDConstants.getOriginalLanguageKoreanPref(dexLang), false)) { - addQueryParameter("originalLanguage[]", "ko") - } mangaIds.forEach { id -> addQueryParameter("ids[]", id) @@ -192,7 +181,8 @@ abstract class MangaDex(override val lang: String, val dexLang: String) : val coverSuffix = preferences.getString(MDConstants.getCoverQualityPreferenceKey(dexLang), "") val mangaList = mangaIds.mapNotNull { mangaDtoMap[it] }.map { mangaDto -> - val fileName = mangaDto.relationships.firstOrNull { relationshipDto -> + val fileName = mangaDto.data.relationships.firstOrNull { relationshipDto -> + relationshipDto.type.equals(MDConstants.coverArt, true) relationshipDto.type.equals(MDConstants.coverArt, true) }?.attributes?.fileName helper.createBasicManga(mangaDto, fileName, coverSuffix) @@ -201,12 +191,23 @@ abstract class MangaDex(override val lang: String, val dexLang: String) : return MangasPage(mangaList, hasMoreResults) } override fun latestUpdatesRequest(page: Int): Request { - val url = MDConstants.apiChapterUrl.toHttpUrlOrNull()!!.newBuilder() - .addQueryParameter("offset", helper.getLatestChapterOffset(page)) - .addQueryParameter("limit", MDConstants.latestChapterLimit.toString()) - .addQueryParameter("translatedLanguage[]", dexLang) - .addQueryParameter("order[publishAt]", "desc") - .build().toString() + val url = MDConstants.apiChapterUrl.toHttpUrlOrNull()!!.newBuilder().apply { + addQueryParameter("offset", helper.getLatestChapterOffset(page)) + addQueryParameter("limit", MDConstants.latestChapterLimit.toString()) + addQueryParameter("translatedLanguage[]", dexLang) + addQueryParameter("order[publishAt]", "desc") + if (preferences.getBoolean(MDConstants.getOriginalLanguageJapanesePref(dexLang), false)) { + addQueryParameter("originalLanguage[]", "ja") + } + // dex has zh and zh-hk for chinese manhua + if (preferences.getBoolean(MDConstants.getOriginalLanguageChinesePref(dexLang), false)) { + addQueryParameter("originalLanguage[]", "zh") + addQueryParameter("originalLanguage[]", "zh-hk") + } + if (preferences.getBoolean(MDConstants.getOriginalLanguageKoreanPref(dexLang), false)) { + addQueryParameter("originalLanguage[]", "ko") + } + }.build().toString() return GET(url, headers, CacheControl.FORCE_NETWORK) } @@ -229,7 +230,7 @@ abstract class MangaDex(override val lang: String, val dexLang: String) : throw Exception("Unable to process Chapter request. HTTP code: ${response.code}") } - helper.json.decodeFromString(response.body!!.string()).relationships + helper.json.decodeFromString(response.body!!.string()).data.relationships .find { it.type == MDConstants.manga }!!.id 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 977bcea95..e4f13d4ac 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 @@ -204,15 +204,15 @@ class MangaDexHelper() { Locale(attr.originalLanguage ?: "").displayLanguage ) - val authors = mangaDto.relationships.filter { relationshipDto -> + val authors = mangaDto.data.relationships.filter { relationshipDto -> relationshipDto.type.equals(MDConstants.author, true) }.mapNotNull { it.attributes!!.name }.distinct() - val artists = mangaDto.relationships.filter { relationshipDto -> + val artists = mangaDto.data.relationships.filter { relationshipDto -> relationshipDto.type.equals(MDConstants.artist, true) }.mapNotNull { it.attributes!!.name }.distinct() - val coverFileName = mangaDto.relationships.firstOrNull { relationshipDto -> + val coverFileName = mangaDto.data.relationships.firstOrNull { relationshipDto -> relationshipDto.type.equals(MDConstants.coverArt, true) }?.attributes?.fileName @@ -253,7 +253,7 @@ class MangaDexHelper() { val data = chapterDto.data val attr = data.attributes - val groups = chapterDto.relationships.filter { relationshipDto -> + val groups = chapterDto.data.relationships.filter { relationshipDto -> relationshipDto.type.equals( MDConstants.scanlator, true 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 e1ebb753b..28db2d6af 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 @@ -14,7 +14,6 @@ data class ChapterListDto( data class ChapterDto( val result: String, val data: ChapterDataDto, - val relationships: List, ) @Serializable @@ -22,6 +21,7 @@ data class ChapterDataDto( val id: String, val type: String, val attributes: ChapterAttributesDto, + val relationships: 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 ebfdc89d3..e93f85d15 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 @@ -18,7 +18,6 @@ data class MangaListDto( data class MangaDto( val result: String, val data: MangaDataDto, - val relationships: List, ) @Serializable @@ -39,6 +38,7 @@ data class MangaDataDto( val id: String, val type: String, val attributes: MangaAttributesDto, + val relationships: List, ) @Serializable