Mangadex: View all Manga by a Group (+handle group links) (#10060)

* search Manga from a group using their id

* add group deeplink support

* linting

* increment mangadex.extVersionCode

* respect `dexLang`

eg: MangaDex (EN) needn't show a group's non-EN releases

* you cannot use filters on chapter endpoint

fixes HTTP 400 while trying to filter on chapter endpoint

* rewrite to use /manga endpoint instead of /chapter

ends up removing a lot of stuff I had previously but that's a good thing

* add check for valid UUID

if a UUID wasn't being provided, then the group queryParameter wouldn't
work and end up throwing Error 400. Might as well prevent that
This commit is contained in:
nicki 2021-12-14 00:38:33 +05:30 committed by GitHub
parent 024e84b6f7
commit b210902b2c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 35 additions and 11 deletions

View File

@ -38,6 +38,14 @@
android:host="www.mangadex.org" android:host="www.mangadex.org"
android:pathPattern="/chapter/..*" android:pathPattern="/chapter/..*"
android:scheme="https" /> android:scheme="https" />
<data
android:host="mangadex.org"
android:pathPattern="/group/..*"
android:scheme="https" />
<data
android:host="www.mangadex.org"
android:pathPattern="/group/..*"
android:scheme="https" />
</intent-filter> </intent-filter>
</activity> </activity>
</application> </application>

View File

@ -6,7 +6,7 @@ ext {
extName = 'MangaDex' extName = 'MangaDex'
pkgNameSuffix = 'all.mangadex' pkgNameSuffix = 'all.mangadex'
extClass = '.MangaDexFactory' extClass = '.MangaDexFactory'
extVersionCode = 146 extVersionCode = 147
isNsfw = true isNsfw = true
} }

View File

@ -34,6 +34,7 @@ object MDConstants {
const val prefixIdSearch = "id:" const val prefixIdSearch = "id:"
const val prefixChSearch = "ch:" const val prefixChSearch = "ch:"
const val prefixGrpSearch = "grp:"
const val coverQualityPref = "thumbnailQuality" const val coverQualityPref = "thumbnailQuality"

View File

@ -216,17 +216,30 @@ abstract class MangaDex(override val lang: String, val dexLang: String) :
return GET(url, headers, CacheControl.FORCE_NETWORK) return GET(url, headers, CacheControl.FORCE_NETWORK)
} }
val tempUrl = MDConstants.apiMangaUrl.toHttpUrl().newBuilder() val tempUrl = MDConstants.apiMangaUrl.toHttpUrl().newBuilder().apply {
tempUrl.apply {
addQueryParameter("limit", MDConstants.mangaLimit.toString()) addQueryParameter("limit", MDConstants.mangaLimit.toString())
addQueryParameter("offset", (helper.getMangaListOffset(page))) addQueryParameter("offset", (helper.getMangaListOffset(page)))
addQueryParameter("includes[]", MDConstants.coverArt) addQueryParameter("includes[]", MDConstants.coverArt)
}
if (query.startsWith(MDConstants.prefixGrpSearch)) {
val groupID = query.removePrefix(MDConstants.prefixGrpSearch)
if (!helper.containsUuid(groupID)) {
throw Exception("Not a valid group ID")
}
tempUrl.apply {
addQueryParameter("group", groupID)
}
}
else {
tempUrl.apply {
val actualQuery = query.replace(MDConstants.whitespaceRegex, " ") val actualQuery = query.replace(MDConstants.whitespaceRegex, " ")
if (actualQuery.isNotBlank()) { if (actualQuery.isNotBlank()) {
addQueryParameter("title", actualQuery) addQueryParameter("title", actualQuery)
} }
} }
}
val finalUrl = helper.mdFilters.addFiltersToUrl(tempUrl, filters) val finalUrl = helper.mdFilters.addFiltersToUrl(tempUrl, filters)

View File

@ -25,10 +25,12 @@ class MangadexUrlActivity : Activity() {
val titleid = pathSegments[1] val titleid = pathSegments[1]
val mainIntent = Intent().apply { val mainIntent = Intent().apply {
action = "eu.kanade.tachiyomi.SEARCH" action = "eu.kanade.tachiyomi.SEARCH"
if (pathSegments[0].equals("chapter")) { with(pathSegments[0]) {
putExtra("query", "${MDConstants.prefixChSearch}$titleid") when {
} else { equals("chapter") -> putExtra("query", "${MDConstants.prefixChSearch}$titleid")
putExtra("query", "${MDConstants.prefixIdSearch}$titleid") equals("group") -> putExtra("query", "${MDConstants.prefixGrpSearch}$titleid")
else -> putExtra("query", "${MDConstants.prefixIdSearch}$titleid")
}
} }
putExtra("filter", packageName) putExtra("filter", packageName)
} }