diff --git a/lib/sources/src/all/mangadex/model/chapter.dart b/lib/sources/src/all/mangadex/model/chapter.dart index 90a3afc..4ee2bb1 100644 --- a/lib/sources/src/all/mangadex/model/chapter.dart +++ b/lib/sources/src/all/mangadex/model/chapter.dart @@ -95,14 +95,29 @@ class Attributes { class Relationships { String? id; String? type; - - Relationships({ - this.id, - this.type, - }); + RAttributes? attributes; + Relationships({this.id, this.type, this.attributes}); Relationships.fromJson(Map json) { id = json['id']; type = json['type']; + // log(json['attributes'].toString()); + attributes = json['attributes'] != null + ? RAttributes.fromJson(json['attributes']) + : null; + } +} + +class RAttributes { + String? name; + String? username; + RAttributes({ + this.name, + this.username, + }); + + RAttributes.fromJson(Map json) { + name = json['name']; + username = json['username']; } } diff --git a/lib/sources/src/all/mangadex/src/mangadex.dart b/lib/sources/src/all/mangadex/src/mangadex.dart index bdfcfb0..a0aa6fc 100644 --- a/lib/sources/src/all/mangadex/src/mangadex.dart +++ b/lib/sources/src/all/mangadex/src/mangadex.dart @@ -137,7 +137,6 @@ class MangaDex extends MangaYomiServices { var limit = chapterListResponse.limit!; var offset = chapterListResponse.offset!; var hasMoreResults = (limit + offset) < chapterListResponse.total!; - while (hasMoreResults) { offset += limit; var newRequest = @@ -150,6 +149,30 @@ class MangaDex extends MangaYomiServices { } for (var chapterData in chapterListResults!) { + List scan = []; + var groups = chapterData.relationships! + .where((element) => element.id != legacyNoGroupId) + .toList(); + for (var element in groups) { + scan.add( + element.attributes != null ? element.attributes!.name ?? "" : ""); + } + final scann = scan.join(" ").trim(); + if (scann.isEmpty) { + scan = []; + for (var element in groups) { + scan.add(element.attributes != null + ? element.attributes!.username != null + ? "Uploaded by ${element.attributes!.username}" + : "" + : ""); + } + } + if (scann.isEmpty) { + scan = []; + scan.add("No Group"); + } + List chapName = []; var chapAttr = chapterData.attributes!; if (chapAttr.volume != null && chapAttr.volume!.isNotEmpty) { @@ -167,6 +190,7 @@ class MangaDex extends MangaYomiServices { if (chapName.isEmpty) { chapName.add("Oneshot"); } + scanlators.add(scan.join(" ").trim()); chapterUrl.add("/chapter/${chapterData.id}"); chapterTitle.add(chapName.join(" ")); chapterDate.add(parseDate(chapAttr.publishAt!, source)); diff --git a/lib/sources/src/all/mangadex/src/utils/utils.dart b/lib/sources/src/all/mangadex/src/utils/utils.dart index 4e86276..2e2aeb3 100644 --- a/lib/sources/src/all/mangadex/src/utils/utils.dart +++ b/lib/sources/src/all/mangadex/src/utils/utils.dart @@ -87,3 +87,4 @@ Status getPublicationStatus(Aggregate? aggregate, mdx_detail.Attributes attr) { const tagAnthologyUuid = "51d83883-4103-437c-b4b1-731cb73d786c"; const tagOneShotUuid = "0234a31e-a729-4e28-9d6a-3f87c4966b9e"; +const legacyNoGroupId = "00e03853-1b96-4f41-9542-c71b8692033b";