Mercurial > minori
diff src/services/anilist.cpp @ 77:6f7385bd334c
*: update
formatted all source files, no more subclassing QThread... many other
changes :)
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Fri, 06 Oct 2023 06:18:53 -0400 |
parents | 3364fadc8a36 |
children |
line wrap: on
line diff
--- a/src/services/anilist.cpp Wed Oct 04 01:46:33 2023 -0400 +++ b/src/services/anilist.cpp Fri Oct 06 06:18:53 2023 -0400 @@ -7,6 +7,7 @@ #include "core/session.h" #include "core/strings.h" #include "gui/translate/anilist.h" +#include <QByteArray> #include <QDesktopServices> #include <QInputDialog> #include <QLineEdit> @@ -40,7 +41,7 @@ std::string SendRequest(std::string data) { std::vector<std::string> headers = {"Authorization: Bearer " + account.AuthToken(), "Accept: application/json", "Content-Type: application/json"}; - return HTTP::PerformBasicPostRequest("https://graphql.anilist.co", data, headers); + return Strings::ToUtf8String(HTTP::Post("https://graphql.anilist.co", data, headers)); } void ParseListStatus(std::string status, Anime::Anime& anime) { @@ -255,13 +256,13 @@ * Date completedAt **/ Anime::Anime& anime = Anime::db.items[id]; - const std::string query = - "mutation ($media_id: Int, $progress: Int, $status: MediaListStatus, $score: Int, $notes: String) {\n" - " SaveMediaListEntry (mediaId: $media_id, progress: $progress, status: $status, scoreRaw: $score, notes: " - "$notes) {\n" - " id\n" - " }\n" - "}\n"; + const std::string query = "mutation ($media_id: Int, $progress: Int, $status: MediaListStatus, $score: Int, " + "$notes: String, $start: FuzzyDateInput, $comp: FuzzyDateInput) {\n" + " SaveMediaListEntry (mediaId: $media_id, progress: $progress, status: $status, " + "scoreRaw: $score, notes: $notes, startedAt: $start, completedAt: $comp) {\n" + " id\n" + " }\n" + "}\n"; // clang-format off nlohmann::json json = { {"query", query}, @@ -270,7 +271,9 @@ {"progress", anime.GetUserProgress()}, {"status", ListStatusToString(anime)}, {"score", anime.GetUserScore()}, - {"notes", anime.GetUserNotes()} + {"notes", anime.GetUserNotes()}, + {"start", anime.GetUserDateStarted().GetAsAniListJson()}, + {"comp", anime.GetUserDateCompleted().GetAsAniListJson()} }} }; // clang-format on