Skip to content

Commit

Permalink
90: Add Reviews Summary - Verdict/Pros/Cons
Browse files Browse the repository at this point in the history
  • Loading branch information
JICA98 committed Aug 18, 2024
1 parent 7cac6de commit a11462f
Show file tree
Hide file tree
Showing 29 changed files with 784 additions and 30 deletions.
1 change: 0 additions & 1 deletion android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />
<uses-permission android:name="android.permission.USE_EXACT_ALARM" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
Expand Down
67 changes: 58 additions & 9 deletions dal-api/dal_commons/lib/src/model/html/anime/animereviewhtml.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,65 @@ final reactionBoxes = [
"Creative"
];

class ContentReviewSummary with ToJson {
final List<ReviewItem> pros;
final List<ReviewItem> cons;
final String verdict;
ContentReviewSummary(this.pros, this.cons, this.verdict);

factory ContentReviewSummary.fromJson(Map<String, dynamic>? json) {
return json != null
? ContentReviewSummary(
(json['pros'] as List)
.map((e) => ReviewItem.fromJson(e))
.toList(),
(json['cons'] as List)
.map((e) => ReviewItem.fromJson(e))
.toList(),
json['verdict'])
: ContentReviewSummary([], [], '');
}

@override
Map<String, dynamic> toJson() {
return {
"pros": pros.map((e) => e.toJson()).toList(),
"cons": cons.map((e) => e.toJson()).toList(),
"verdict": verdict
};
}
}

class ReviewItem with ToJson {
final String title;
final String description;
ReviewItem({required this.title, required this.description});

@override
Map<String, dynamic> toJson() {
return {
"title": title,
"description": description
};
}

factory ReviewItem.fromJson(Map<String, dynamic>? json) {
return json != null
? ReviewItem(title: json['title'], description: json['description'])
: ReviewItem(title: '', description: '');
}
}

class AnimeReviewHtml with ToJson {
final String ?userName;
final String ?timeAdded;
final String ?userPicture;
final String ?overallRating;
final String ?reviewText;
final List<String> ?tags;
final List<String> ?reactionBox;
bool ?fromCache;
final dal_node.Node ?relatedNode;
final String? userName;
final String? timeAdded;
final String? userPicture;
final String? overallRating;
final String? reviewText;
final List<String>? tags;
final List<String>? reactionBox;
bool? fromCache;
final dal_node.Node? relatedNode;

AnimeReviewHtml({
this.userName,
Expand Down
37 changes: 30 additions & 7 deletions lib/api/dalapi.dart
Original file line number Diff line number Diff line change
Expand Up @@ -403,13 +403,19 @@ class DalApi {

Future<dynamic> _apiGET(String endpoint) async {
final apiURL = await _getAPIBaseUrl();
return MalConnect.getContent('$apiURL/$endpoint',
retryOnFail: false,
withNoHeaders: true,
includeNsfw: false,
headers: {
'Authorization': 'Bearer ${CredMal.apiSecret}',
});
return MalConnect.getContent(
'$apiURL/$endpoint',
retryOnFail: false,
withNoHeaders: true,
includeNsfw: false,
headers: _headers,
);
}

Map<String, String> get _headers {
return {
'Authorization': 'Bearer ${CredMal.apiSecret}',
};
}

Future<AnimeGraph> getAnimeGraph(int id) async {
Expand All @@ -420,6 +426,23 @@ class DalApi {
);
}

Future<ContentReviewSummary?> getReviewsSummary(List<String> reviews) async {
try {
final apiURL = '${await _getAPIBaseUrl()}/reviews';
logDal('Sending reviews to $apiURL');
final response = await http.post(
Uri.parse(apiURL),
headers: _headers,
body: jsonEncode(reviews),
);
final body = response.body;
return ContentReviewSummary.fromJson(jsonDecode(body));
} catch (e) {
logDal(e);
return null;
}
}

Future<String> getSignedImageUrl(String type, String id) async {
final response = await _apiGET('types/$type/images/$id');
return response['signedURL'];
Expand Down
9 changes: 9 additions & 0 deletions lib/generated/intl/messages_ar_EG.dart
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ class MessageLookup extends MessageLookupByLibrary {
"ConfirmNotifPermDesc": MessageLookupByLibrary.simpleMessage(
"هل ترغب في السماح بالإشعارات لهذا التطبيق. يتضمن ذلك إشعارات عند بث حلقة من PTW (خطة المشاهدة) وقائمة المشاهدة."),
"Confusing": MessageLookupByLibrary.simpleMessage("مربك"),
"Cons": MessageLookupByLibrary.simpleMessage("سلبيات"),
"Content_type": MessageLookupByLibrary.simpleMessage("نوع المحتوى"),
"Continue": MessageLookupByLibrary.simpleMessage("استمر؟"),
"ContinueW": MessageLookupByLibrary.simpleMessage("يكمل"),
Expand Down Expand Up @@ -414,6 +415,8 @@ class MessageLookup extends MessageLookupByLibrary {
"Gender_desc": MessageLookupByLibrary.simpleMessage("لا تهتم افتراضيا"),
"Generate_Other_charts":
MessageLookupByLibrary.simpleMessage("إنشاء مخططات أخرى"),
"Generating_Review_Summary":
MessageLookupByLibrary.simpleMessage("إنشاء ملخص المراجعة"),
"Genre": MessageLookupByLibrary.simpleMessage("النوع"),
"Genre_Distribution":
MessageLookupByLibrary.simpleMessage("توزيع النوع"),
Expand Down Expand Up @@ -818,6 +821,7 @@ class MessageLookup extends MessageLookupByLibrary {
"Promo_Videos":
MessageLookupByLibrary.simpleMessage("أشرطة الفيديو الترويجي"),
"Promotional": MessageLookupByLibrary.simpleMessage("الترويجية"),
"Pros": MessageLookupByLibrary.simpleMessage("الايجابيات"),
"Psychological": MessageLookupByLibrary.simpleMessage("نفسي"),
"Published": MessageLookupByLibrary.simpleMessage("نشرت"),
"Published_Manga":
Expand Down Expand Up @@ -895,6 +899,9 @@ class MessageLookup extends MessageLookupByLibrary {
"Review": MessageLookupByLibrary.simpleMessage("إعادة النظر"),
"Review_By": MessageLookupByLibrary.simpleMessage("روجع من قبل"),
"Review_On": MessageLookupByLibrary.simpleMessage("مراجعة على"),
"Review_Summary": MessageLookupByLibrary.simpleMessage("ملخص المراجعة"),
"Review_Summary_Desc": MessageLookupByLibrary.simpleMessage(
"يتم إنشاء حكم المراجعة بواسطة الذكاء الاصطناعي باستخدام المراجعات التالية وقد لا يكون دقيقًا. يرجى قراءة التقييمات لمزيد من المعلومات."),
"Reviews": MessageLookupByLibrary.simpleMessage("تقييم"),
"Rewatch": MessageLookupByLibrary.simpleMessage("إعادف"),
"Rewatching": MessageLookupByLibrary.simpleMessage("إخراج"),
Expand Down Expand Up @@ -1063,6 +1070,7 @@ class MessageLookup extends MessageLookupByLibrary {
"Studios": MessageLookupByLibrary.simpleMessage("استوديوهات"),
"Sub_Category": MessageLookupByLibrary.simpleMessage("تصنيف فرعي"),
"Suggestions": MessageLookupByLibrary.simpleMessage("اقتراحات"),
"Summary": MessageLookupByLibrary.simpleMessage("ملخص"),
"Summer_2007": MessageLookupByLibrary.simpleMessage("صيف 2007."),
"Summer_2008": MessageLookupByLibrary.simpleMessage("صيف 2008."),
"Summer_2009": MessageLookupByLibrary.simpleMessage("صيف 2009."),
Expand Down Expand Up @@ -1198,6 +1206,7 @@ class MessageLookup extends MessageLookupByLibrary {
"Users": MessageLookupByLibrary.simpleMessage("المستخدمين"),
"Value": MessageLookupByLibrary.simpleMessage("قيمة"),
"Vampire": MessageLookupByLibrary.simpleMessage("مصاص دماء"),
"Verdict": MessageLookupByLibrary.simpleMessage("الحكم"),
"Version": MessageLookupByLibrary.simpleMessage("إصدار"),
"Very_Bad": MessageLookupByLibrary.simpleMessage("سيئ جدا"),
"Very_Good": MessageLookupByLibrary.simpleMessage("جيد جدًا"),
Expand Down
10 changes: 10 additions & 0 deletions lib/generated/intl/messages_de_DE.dart
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ class MessageLookup extends MessageLookupByLibrary {
"ConfirmNotifPermDesc": MessageLookupByLibrary.simpleMessage(
"Möchten Sie Benachrichtigungen für diese App zulassen? Dazu gehören Benachrichtigungen, wenn eine Episode von Ihrem PTW (Plan To Watch) und Ihrer Beobachtungsliste ausgestrahlt wird."),
"Confusing": MessageLookupByLibrary.simpleMessage("Verwirrend"),
"Cons": MessageLookupByLibrary.simpleMessage("Nachteile"),
"Content_type": MessageLookupByLibrary.simpleMessage("Inhaltstyp"),
"Continue": MessageLookupByLibrary.simpleMessage("fortsetzen?"),
"ContinueW": MessageLookupByLibrary.simpleMessage("Fortsetzen"),
Expand Down Expand Up @@ -428,6 +429,8 @@ class MessageLookup extends MessageLookupByLibrary {
"Kümmere mich nicht standardmäßig"),
"Generate_Other_charts":
MessageLookupByLibrary.simpleMessage("Andere Diagramme generieren"),
"Generating_Review_Summary": MessageLookupByLibrary.simpleMessage(
"Zusammenfassung der Rezension erstellen"),
"Genre": MessageLookupByLibrary.simpleMessage("Genre"),
"Genre_Distribution":
MessageLookupByLibrary.simpleMessage("Genreverteilung"),
Expand Down Expand Up @@ -842,6 +845,7 @@ class MessageLookup extends MessageLookupByLibrary {
"Der Profilhintergrund wurde erfolgreich festgelegt"),
"Promo_Videos": MessageLookupByLibrary.simpleMessage("Promo-Videos."),
"Promotional": MessageLookupByLibrary.simpleMessage("Werbeartikel"),
"Pros": MessageLookupByLibrary.simpleMessage("Vorteile"),
"Psychological": MessageLookupByLibrary.simpleMessage("Psychologisch"),
"Published": MessageLookupByLibrary.simpleMessage("Veröffentlicht"),
"Published_Manga":
Expand Down Expand Up @@ -920,6 +924,10 @@ class MessageLookup extends MessageLookupByLibrary {
"Review": MessageLookupByLibrary.simpleMessage("Rezension"),
"Review_By": MessageLookupByLibrary.simpleMessage("Überprüfung durch"),
"Review_On": MessageLookupByLibrary.simpleMessage("Rezension an"),
"Review_Summary": MessageLookupByLibrary.simpleMessage(
"Zusammenfassung der Rezension"),
"Review_Summary_Desc": MessageLookupByLibrary.simpleMessage(
"Das Bewertungsurteil wird von KI anhand der folgenden Bewertungen erstellt und ist möglicherweise nicht korrekt. Für weitere Informationen lesen Sie bitte die Bewertungen."),
"Reviews": MessageLookupByLibrary.simpleMessage("Rezensionen"),
"Rewatch": MessageLookupByLibrary.simpleMessage("Wiederverwatschen"),
"Rewatching": MessageLookupByLibrary.simpleMessage("Wiederverwinternd"),
Expand Down Expand Up @@ -1100,6 +1108,7 @@ class MessageLookup extends MessageLookupByLibrary {
"Studios": MessageLookupByLibrary.simpleMessage("Studios"),
"Sub_Category": MessageLookupByLibrary.simpleMessage("Unterkategorie"),
"Suggestions": MessageLookupByLibrary.simpleMessage("Vorschläge"),
"Summary": MessageLookupByLibrary.simpleMessage("Zusammenfassung"),
"Summer_2007": MessageLookupByLibrary.simpleMessage("Sommer 2007."),
"Summer_2008": MessageLookupByLibrary.simpleMessage("Sommer 2008."),
"Summer_2009": MessageLookupByLibrary.simpleMessage("Sommer 2009."),
Expand Down Expand Up @@ -1235,6 +1244,7 @@ class MessageLookup extends MessageLookupByLibrary {
"Users": MessageLookupByLibrary.simpleMessage("Benutzer"),
"Value": MessageLookupByLibrary.simpleMessage("Wert"),
"Vampire": MessageLookupByLibrary.simpleMessage("Vampir"),
"Verdict": MessageLookupByLibrary.simpleMessage("Urteil"),
"Version": MessageLookupByLibrary.simpleMessage("Ausführung"),
"Very_Bad": MessageLookupByLibrary.simpleMessage("Sehr schlecht"),
"Very_Good": MessageLookupByLibrary.simpleMessage("Sehr gut"),
Expand Down
10 changes: 10 additions & 0 deletions lib/generated/intl/messages_en_US.dart
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ class MessageLookup extends MessageLookupByLibrary {
"ConfirmNotifPermDesc": MessageLookupByLibrary.simpleMessage(
"Do you wish to allow notifications for this app. This includes notifications when an episode is aired from your PTW (Plan To Watch) and Watching list."),
"Confusing": MessageLookupByLibrary.simpleMessage("Confusing"),
"Cons": MessageLookupByLibrary.simpleMessage("Cons"),
"Content_type": MessageLookupByLibrary.simpleMessage("Content type"),
"Continue": MessageLookupByLibrary.simpleMessage("continue?"),
"ContinueW": MessageLookupByLibrary.simpleMessage("Continue"),
Expand Down Expand Up @@ -416,6 +417,8 @@ class MessageLookup extends MessageLookupByLibrary {
MessageLookupByLibrary.simpleMessage("Don\'t care by default"),
"Generate_Other_charts":
MessageLookupByLibrary.simpleMessage("Generate Other charts"),
"Generating_Review_Summary":
MessageLookupByLibrary.simpleMessage("Generating Review Summary"),
"Genre": MessageLookupByLibrary.simpleMessage("Genre"),
"Genre_Distribution":
MessageLookupByLibrary.simpleMessage("Genre Distribution"),
Expand Down Expand Up @@ -810,6 +813,7 @@ class MessageLookup extends MessageLookupByLibrary {
"Profile background is set successfully"),
"Promo_Videos": MessageLookupByLibrary.simpleMessage("Promo Videos"),
"Promotional": MessageLookupByLibrary.simpleMessage("Promotional"),
"Pros": MessageLookupByLibrary.simpleMessage("Pros"),
"Psychological": MessageLookupByLibrary.simpleMessage("Psychological"),
"Published": MessageLookupByLibrary.simpleMessage("Published"),
"Published_Manga":
Expand Down Expand Up @@ -887,6 +891,10 @@ class MessageLookup extends MessageLookupByLibrary {
"Review": MessageLookupByLibrary.simpleMessage("Review"),
"Review_By": MessageLookupByLibrary.simpleMessage("Review by"),
"Review_On": MessageLookupByLibrary.simpleMessage("Review on"),
"Review_Summary":
MessageLookupByLibrary.simpleMessage("Review Summary"),
"Review_Summary_Desc": MessageLookupByLibrary.simpleMessage(
"Review Verdict is generated by AI using the following reviews and may not be accurate. Please read the reviews for more information."),
"Reviews": MessageLookupByLibrary.simpleMessage("Reviews"),
"Rewatch": MessageLookupByLibrary.simpleMessage("Rewatch"),
"Rewatching": MessageLookupByLibrary.simpleMessage("Rewatching"),
Expand Down Expand Up @@ -1062,6 +1070,7 @@ class MessageLookup extends MessageLookupByLibrary {
"Studios": MessageLookupByLibrary.simpleMessage("Studios"),
"Sub_Category": MessageLookupByLibrary.simpleMessage("Sub Category"),
"Suggestions": MessageLookupByLibrary.simpleMessage("Suggestions"),
"Summary": MessageLookupByLibrary.simpleMessage("Summary"),
"Summer_2007": MessageLookupByLibrary.simpleMessage("Summer 2007"),
"Summer_2008": MessageLookupByLibrary.simpleMessage("Summer 2008"),
"Summer_2009": MessageLookupByLibrary.simpleMessage("Summer 2009"),
Expand Down Expand Up @@ -1192,6 +1201,7 @@ class MessageLookup extends MessageLookupByLibrary {
"Users": MessageLookupByLibrary.simpleMessage("users"),
"Value": MessageLookupByLibrary.simpleMessage("Value"),
"Vampire": MessageLookupByLibrary.simpleMessage("Vampire"),
"Verdict": MessageLookupByLibrary.simpleMessage("Verdict"),
"Version": MessageLookupByLibrary.simpleMessage("Version"),
"Very_Bad": MessageLookupByLibrary.simpleMessage("Very Bad"),
"Very_Good": MessageLookupByLibrary.simpleMessage("Very Good"),
Expand Down
10 changes: 10 additions & 0 deletions lib/generated/intl/messages_es_ES.dart
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ class MessageLookup extends MessageLookupByLibrary {
"ConfirmNotifPermDesc": MessageLookupByLibrary.simpleMessage(
"¿Desea permitir notificaciones para esta aplicación? Esto incluye notificaciones cuando se transmite un episodio desde su PTW (Plan para mirar) y su lista de observación."),
"Confusing": MessageLookupByLibrary.simpleMessage("Confuso"),
"Cons": MessageLookupByLibrary.simpleMessage("Contras"),
"Content_type":
MessageLookupByLibrary.simpleMessage("Tipo de contenido"),
"Continue": MessageLookupByLibrary.simpleMessage("¿Seguir?"),
Expand Down Expand Up @@ -437,6 +438,8 @@ class MessageLookup extends MessageLookupByLibrary {
MessageLookupByLibrary.simpleMessage("No importa por defecto"),
"Generate_Other_charts":
MessageLookupByLibrary.simpleMessage("Generar otros gráficos"),
"Generating_Review_Summary": MessageLookupByLibrary.simpleMessage(
"Generando resumen de revisión"),
"Genre": MessageLookupByLibrary.simpleMessage("Género"),
"Genre_Distribution":
MessageLookupByLibrary.simpleMessage("Distribución de género"),
Expand Down Expand Up @@ -856,6 +859,7 @@ class MessageLookup extends MessageLookupByLibrary {
"Promo_Videos":
MessageLookupByLibrary.simpleMessage("Videos de promoción"),
"Promotional": MessageLookupByLibrary.simpleMessage("Promocional"),
"Pros": MessageLookupByLibrary.simpleMessage("Ventajas"),
"Psychological": MessageLookupByLibrary.simpleMessage("Psychological"),
"Published": MessageLookupByLibrary.simpleMessage("Published"),
"Published_Manga":
Expand Down Expand Up @@ -936,6 +940,10 @@ class MessageLookup extends MessageLookupByLibrary {
"Review": MessageLookupByLibrary.simpleMessage("Revisar"),
"Review_By": MessageLookupByLibrary.simpleMessage("Revisado por"),
"Review_On": MessageLookupByLibrary.simpleMessage("Revisar en"),
"Review_Summary":
MessageLookupByLibrary.simpleMessage("Resumen de revisión"),
"Review_Summary_Desc": MessageLookupByLibrary.simpleMessage(
"El veredicto de revisión lo genera AI utilizando las siguientes revisiones y puede no ser exacto. Lea las reseñas para obtener más información."),
"Reviews": MessageLookupByLibrary.simpleMessage("Comentarios"),
"Rewatch": MessageLookupByLibrary.simpleMessage("Revestidor"),
"Rewatching": MessageLookupByLibrary.simpleMessage("Revestimiento"),
Expand Down Expand Up @@ -1124,6 +1132,7 @@ class MessageLookup extends MessageLookupByLibrary {
"Studios": MessageLookupByLibrary.simpleMessage("Estudios"),
"Sub_Category": MessageLookupByLibrary.simpleMessage("Subcategoría"),
"Suggestions": MessageLookupByLibrary.simpleMessage("Sugerencias"),
"Summary": MessageLookupByLibrary.simpleMessage("Resumen"),
"Summer_2007":
MessageLookupByLibrary.simpleMessage("2007 de verano de 2007"),
"Summer_2008": MessageLookupByLibrary.simpleMessage("Verano 2008"),
Expand Down Expand Up @@ -1264,6 +1273,7 @@ class MessageLookup extends MessageLookupByLibrary {
"Users": MessageLookupByLibrary.simpleMessage("users"),
"Value": MessageLookupByLibrary.simpleMessage("Valor"),
"Vampire": MessageLookupByLibrary.simpleMessage("Vampire"),
"Verdict": MessageLookupByLibrary.simpleMessage("Veredicto"),
"Version": MessageLookupByLibrary.simpleMessage("Versión"),
"Very_Bad": MessageLookupByLibrary.simpleMessage("Muy mal"),
"Very_Good": MessageLookupByLibrary.simpleMessage("Muy bien"),
Expand Down
Loading

0 comments on commit a11462f

Please sign in to comment.