From 60751ea39a0b7be5f38014063f95c285fd5b27da Mon Sep 17 00:00:00 2001 From: nicki <72807749+curche@users.noreply.github.com> Date: Mon, 17 Jan 2022 20:37:02 +0530 Subject: [PATCH] MangaDex: Group Blocking improvements (#10481) * Replace "Abandoned" with "Cancelled" was replaced in the Api few months back as well * Refactor externalURL filtering to use pages attr * Add mangahot to list of external linked groups * Refactor group blocking - Block external linked groups separately This block is now only done in Latest section (uses /chapter) since filtering them out in /manga/ID/feed is done by `createChapter` helper already - No default UUIDs set in groupBlock setting - external linked groups and their UUIDs arent exposed to Users * Increment mangadex.extversioncode * Remove unneeded empty string check for ch.attr.externalUrl Co-authored-by: Mitchell Syer Co-authored-by: Mitchell Syer --- src/all/mangadex/build.gradle | 2 +- .../extension/all/mangadex/MDConstants.kt | 5 +++-- .../tachiyomi/extension/all/mangadex/MangaDex.kt | 10 +++++----- .../extension/all/mangadex/MangaDexFilters.kt | 2 +- .../extension/all/mangadex/MangaDexHelper.kt | 14 +------------- .../extension/all/mangadex/dto/ChapterDto.kt | 1 + 6 files changed, 12 insertions(+), 22 deletions(-) diff --git a/src/all/mangadex/build.gradle b/src/all/mangadex/build.gradle index 2e585d260..4807b1cfe 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 = 151 + extVersionCode = 152 isNsfw = true } diff --git a/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/MDConstants.kt b/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/MDConstants.kt index f01c30b09..30c822941 100644 --- a/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/MDConstants.kt +++ b/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/MDConstants.kt @@ -81,12 +81,13 @@ object MDConstants { return "${originalLanguagePref}_$dexLang" } - private const val blockedGroupsPref = "blockedGroups" private const val groupMangaPlus = "4f1de6a2-f0c5-4ac5-bce5-02c7dbb67deb" private const val groupComikey = "8d8ecf83-8d42-4f8c-add8-60963f9f28d9" private const val groupBilibili = "06a9fecb-b608-4f19-b93c-7caab06b7f44" private const val groupAzuki = "5fed0576-8b94-4f9a-b6a7-08eecd69800d" - const val blockedGroupsPrefDefaults = "$groupMangaPlus, $groupComikey, $groupBilibili, $groupAzuki" + private const val groupMangaHot = "319c1b10-cbd0-4f55-a46e-c4ee17e65139" + val defaultBlockedGroups = setOf(groupMangaPlus, groupComikey, groupBilibili, groupAzuki, groupMangaHot) + private const val blockedGroupsPref = "blockedGroups" fun getBlockedGroupsPrefKey(dexLang: String): String { return "${blockedGroupsPref}_$dexLang" } 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 588d95c7d..807c220fd 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 @@ -174,9 +174,11 @@ abstract class MangaDex(override val lang: String, val dexLang: String) : MDConstants.getContentRatingPrefKey(dexLang), MDConstants.contentRatingPrefDefaults )?.forEach { addQueryParameter("contentRating[]", it) } + MDConstants.defaultBlockedGroups.forEach { + addQueryParameter("excludedGroups[]", it) + } preferences.getString( - MDConstants.getBlockedGroupsPrefKey(dexLang), - MDConstants.blockedGroupsPrefDefaults + MDConstants.getBlockedGroupsPrefKey(dexLang), "" )?.split(",")?.sorted()?.forEach { if (it.isNotEmpty()) addQueryParameter("excludedGroups[]", it.trim()) } preferences.getString( MDConstants.getBlockedUploaderPrefKey(dexLang), @@ -335,8 +337,7 @@ abstract class MangaDex(override val lang: String, val dexLang: String) : addQueryParameter("contentRating[]", "erotica") addQueryParameter("contentRating[]", "pornographic") preferences.getString( - MDConstants.getBlockedGroupsPrefKey(dexLang), - MDConstants.blockedGroupsPrefDefaults + MDConstants.getBlockedGroupsPrefKey(dexLang), "" )?.split(",")?.sorted()?.forEach { if (it.isNotEmpty()) addQueryParameter("excludedGroups[]", it.trim()) } preferences.getString( MDConstants.getBlockedUploaderPrefKey(dexLang), @@ -523,7 +524,6 @@ abstract class MangaDex(override val lang: String, val dexLang: String) : title = "Block Groups by UUID" summary = "Chapters from blocked groups will not show up in Latest or Manga feed.\n" + "Enter as a Comma-separated list of group UUIDs" - setDefaultValue(MDConstants.blockedGroupsPrefDefaults) setOnPreferenceChangeListener { _, newValue -> val groupsBlocked = newValue.toString() .split(",") diff --git a/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/MangaDexFilters.kt b/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/MangaDexFilters.kt index f4d2d28a1..f3d6afcd1 100644 --- a/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/MangaDexFilters.kt +++ b/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/MangaDexFilters.kt @@ -68,7 +68,7 @@ class MangaDexFilters { Status("Ongoing"), Status("Completed"), Status("Hiatus"), - Status("Abandoned"), + Status("Cancelled"), ) private class ContentRating(name: String) : Filter.CheckBox(name) 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 043b935a6..41ecf24c2 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 @@ -112,8 +112,6 @@ class MangaDexHelper() { val USE_CACHE = CacheControl.Builder() .maxStale(Integer.MAX_VALUE, TimeUnit.SECONDS) .build() - - private const val BILIBILI_URL = "bilibilicomics.com" } // Check the token map to see if the md@home host is still valid @@ -328,17 +326,7 @@ class MangaDexHelper() { } } - if (!attr.externalUrl.isNullOrEmpty() && !attr.externalUrl.contains(BILIBILI_URL)) { - return null - } - - // Bilibili special check. If it's a Bilibili chapter and the - // publishAt date is < now, it can be read on MD. - if ( - !attr.externalUrl.isNullOrEmpty() && - attr.externalUrl.contains(BILIBILI_URL) && - parseDate(attr.publishAt) >= Date().time - ) { + if (attr.externalUrl != null && attr.pages == 0) { return null } 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 35826bda2..7a203ac97 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 @@ -29,6 +29,7 @@ data class ChapterAttributesDto( val title: String?, val volume: String?, val chapter: String?, + val pages: Int, val publishAt: String, val externalUrl: String?, )