Mercurial > minori
comparison src/services/anilist.cpp @ 63:3d2decf093bb
*: fix many clang warnings
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Sun, 01 Oct 2023 06:39:47 -0400 |
parents | 0c4138de2ea7 |
children | fe719c109dbc |
comparison
equal
deleted
inserted
replaced
62:4c6dd5999b39 | 63:3d2decf093bb |
---|---|
4 #include "core/config.h" | 4 #include "core/config.h" |
5 #include "core/json.h" | 5 #include "core/json.h" |
6 #include "core/session.h" | 6 #include "core/session.h" |
7 #include "core/strings.h" | 7 #include "core/strings.h" |
8 #include "gui/translate/anilist.h" | 8 #include "gui/translate/anilist.h" |
9 #include <QDebug> | |
9 #include <QDesktopServices> | 10 #include <QDesktopServices> |
10 #include <QInputDialog> | 11 #include <QInputDialog> |
11 #include <QDebug> | |
12 #include <QLineEdit> | 12 #include <QLineEdit> |
13 #include <QMessageBox> | 13 #include <QMessageBox> |
14 #include <QUrl> | 14 #include <QUrl> |
15 #include <chrono> | 15 #include <chrono> |
16 #include <curl/curl.h> | 16 #include <curl/curl.h> |
17 #include <exception> | 17 #include <exception> |
18 #define CLIENT_ID "13706" | 18 #define CLIENT_ID "13706" |
19 | 19 |
20 using nlohmann::literals::operator"" _json_pointer; | 20 using nlohmann::literals::operator"" _json_pointer; |
21 | 21 |
22 namespace Services::AniList { | 22 namespace Services { |
23 namespace AniList { | |
23 | 24 |
24 class Account { | 25 class Account { |
25 public: | 26 public: |
26 std::string Username() const { return session.config.anilist.username; } | 27 std::string Username() const { return session.config.anilist.username; } |
27 void SetUsername(std::string const& username) { session.config.anilist.username = username; } | 28 void SetUsername(std::string const& username) { session.config.anilist.username = username; } |
280 * float[] advancedScores, | 281 * float[] advancedScores, |
281 * Date startedAt, | 282 * Date startedAt, |
282 * Date completedAt | 283 * Date completedAt |
283 **/ | 284 **/ |
284 Anime::Anime& anime = Anime::db.items[id]; | 285 Anime::Anime& anime = Anime::db.items[id]; |
285 const std::string query = "mutation ($media_id: Int, $progress: Int, $status: MediaListStatus, $score: Int, $notes: String) {\n" | 286 const std::string query = |
286 " SaveMediaListEntry (mediaId: $media_id, progress: $progress, status: $status, scoreRaw: $score, notes: $notes) {\n" | 287 "mutation ($media_id: Int, $progress: Int, $status: MediaListStatus, $score: Int, $notes: String) {\n" |
287 " id\n" | 288 " SaveMediaListEntry (mediaId: $media_id, progress: $progress, status: $status, scoreRaw: $score, notes: " |
288 " }\n" | 289 "$notes) {\n" |
289 "}\n"; | 290 " id\n" |
291 " }\n" | |
292 "}\n"; | |
290 // clang-format off | 293 // clang-format off |
291 nlohmann::json json = { | 294 nlohmann::json json = { |
292 {"query", query}, | 295 {"query", query}, |
293 {"variables", { | 296 {"variables", { |
294 {"media_id", anime.GetId()}, | 297 {"media_id", anime.GetId()}, |
329 " scoreFormat\n" | 332 " scoreFormat\n" |
330 " }\n" | 333 " }\n" |
331 " }\n" | 334 " }\n" |
332 "}\n"; | 335 "}\n"; |
333 nlohmann::json json = { | 336 nlohmann::json json = { |
334 {"query", query} | 337 {"query", query} |
335 }; | 338 }; |
336 auto ret = nlohmann::json::parse(SendRequest(json.dump())); | 339 auto ret = nlohmann::json::parse(SendRequest(json.dump())); |
337 ParseUser(json["Viewer"]); | 340 ParseUser(json["Viewer"]); |
338 return true; | 341 return true; |
339 } | 342 } |
340 | 343 |
341 } // namespace Services::AniList | 344 } // namespace AniList |
345 } // namespace Services |