[Mangadex] Fallback to uploader name for uploads that are missing group info entirely (#10023)
This also filters out the legacy MDv3 'no group' entity
This commit is contained in:
parent
ef491c08ea
commit
bc39d9ae8f
|
@ -6,7 +6,7 @@ ext {
|
||||||
extName = 'MangaDex'
|
extName = 'MangaDex'
|
||||||
pkgNameSuffix = 'all.mangadex'
|
pkgNameSuffix = 'all.mangadex'
|
||||||
extClass = '.MangaDexFactory'
|
extClass = '.MangaDexFactory'
|
||||||
extVersionCode = 145
|
extVersionCode = 146
|
||||||
isNsfw = true
|
isNsfw = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,8 +15,10 @@ object MDConstants {
|
||||||
const val manga = "manga"
|
const val manga = "manga"
|
||||||
const val coverArt = "cover_art"
|
const val coverArt = "cover_art"
|
||||||
const val scanlator = "scanlation_group"
|
const val scanlator = "scanlation_group"
|
||||||
|
const val uploader = "user"
|
||||||
const val author = "author"
|
const val author = "author"
|
||||||
const val artist = "artist"
|
const val artist = "artist"
|
||||||
|
const val legacyNoGroupId = "00e03853-1b96-4f41-9542-c71b8692033b"
|
||||||
|
|
||||||
const val cdnUrl = "https://uploads.mangadex.org"
|
const val cdnUrl = "https://uploads.mangadex.org"
|
||||||
const val apiUrl = "https://api.mangadex.org"
|
const val apiUrl = "https://api.mangadex.org"
|
||||||
|
|
|
@ -43,7 +43,7 @@ class MangaDexHelper() {
|
||||||
* get chapters for manga (aka manga/$id/feed endpoint)
|
* get chapters for manga (aka manga/$id/feed endpoint)
|
||||||
*/
|
*/
|
||||||
fun getChapterEndpoint(mangaId: String, offset: Int, langCode: String) =
|
fun getChapterEndpoint(mangaId: String, offset: Int, langCode: String) =
|
||||||
"${MDConstants.apiMangaUrl}/$mangaId/feed?includes[]=${MDConstants.scanlator}&limit=500&offset=$offset&translatedLanguage[]=$langCode&order[volume]=desc&order[chapter]=desc"
|
"${MDConstants.apiMangaUrl}/$mangaId/feed?includes[]=${MDConstants.scanlator}&includes[]=${MDConstants.uploader}&limit=500&offset=$offset&translatedLanguage[]=$langCode&order[volume]=desc&order[chapter]=desc"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the manga url is a valid uuid
|
* Check if the manga url is a valid uuid
|
||||||
|
@ -276,10 +276,19 @@ class MangaDexHelper() {
|
||||||
MDConstants.scanlator,
|
MDConstants.scanlator,
|
||||||
true
|
true
|
||||||
)
|
)
|
||||||
}.mapNotNull { it.attributes!!.name }
|
}.filterNot { it.id == MDConstants.legacyNoGroupId } // 'no group' left over from MDv3
|
||||||
|
.mapNotNull { it.attributes!!.name }
|
||||||
.joinToString(" & ")
|
.joinToString(" & ")
|
||||||
.replace("no group", "No Group")
|
.ifEmpty {
|
||||||
.ifEmpty { "No Group" }
|
// fall back to uploader name if no group
|
||||||
|
val users = chapterDataDto.relationships.filter { relationshipDto ->
|
||||||
|
relationshipDto.type.equals(
|
||||||
|
MDConstants.uploader,
|
||||||
|
true
|
||||||
|
)
|
||||||
|
}.mapNotNull { it.attributes!!.username }
|
||||||
|
users.joinToString(" & ", if (users.isNotEmpty()) "Uploaded by " else "")
|
||||||
|
}.ifEmpty { "No Group" } // "No Group" as final resort
|
||||||
|
|
||||||
val chapterName = mutableListOf<String>()
|
val chapterName = mutableListOf<String>()
|
||||||
// Build chapter name
|
// Build chapter name
|
||||||
|
|
|
@ -31,6 +31,7 @@ data class RelationshipDto(
|
||||||
data class IncludesAttributesDto(
|
data class IncludesAttributesDto(
|
||||||
val name: String? = null,
|
val name: String? = null,
|
||||||
val fileName: String? = null,
|
val fileName: String? = null,
|
||||||
|
val username: String? = null
|
||||||
)
|
)
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
|
|
Loading…
Reference in New Issue