[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'
|
||||
pkgNameSuffix = 'all.mangadex'
|
||||
extClass = '.MangaDexFactory'
|
||||
extVersionCode = 145
|
||||
extVersionCode = 146
|
||||
isNsfw = true
|
||||
}
|
||||
|
||||
|
|
|
@ -15,8 +15,10 @@ object MDConstants {
|
|||
const val manga = "manga"
|
||||
const val coverArt = "cover_art"
|
||||
const val scanlator = "scanlation_group"
|
||||
const val uploader = "user"
|
||||
const val author = "author"
|
||||
const val artist = "artist"
|
||||
const val legacyNoGroupId = "00e03853-1b96-4f41-9542-c71b8692033b"
|
||||
|
||||
const val cdnUrl = "https://uploads.mangadex.org"
|
||||
const val apiUrl = "https://api.mangadex.org"
|
||||
|
|
|
@ -43,7 +43,7 @@ class MangaDexHelper() {
|
|||
* get chapters for manga (aka manga/$id/feed endpoint)
|
||||
*/
|
||||
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
|
||||
|
@ -276,10 +276,19 @@ class MangaDexHelper() {
|
|||
MDConstants.scanlator,
|
||||
true
|
||||
)
|
||||
}.mapNotNull { it.attributes!!.name }
|
||||
}.filterNot { it.id == MDConstants.legacyNoGroupId } // 'no group' left over from MDv3
|
||||
.mapNotNull { it.attributes!!.name }
|
||||
.joinToString(" & ")
|
||||
.replace("no group", "No Group")
|
||||
.ifEmpty { "No Group" }
|
||||
.ifEmpty {
|
||||
// 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>()
|
||||
// Build chapter name
|
||||
|
|
|
@ -31,6 +31,7 @@ data class RelationshipDto(
|
|||
data class IncludesAttributesDto(
|
||||
val name: String? = null,
|
||||
val fileName: String? = null,
|
||||
val username: String? = null
|
||||
)
|
||||
|
||||
@Serializable
|
||||
|
|
Loading…
Reference in New Issue