annotate src/services/anilist.cc @ 137:69db40272acd

dep/animia: [WIP] huge refactor this WILL NOT compile, because lots of code has been changed and every API in the original codebase has been removed. note that this api setup is not exactly permanent...
author Paper <mrpapersonic@gmail.com>
date Fri, 10 Nov 2023 13:52:47 -0500
parents 275da698697d
children 9b10175be389
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
1 #include "services/anilist.h"
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
2 #include "core/anime.h"
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
3 #include "core/anime_db.h"
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
4 #include "core/config.h"
76
3364fadc8a36 *: format source code
Paper <mrpapersonic@gmail.com>
parents: 75
diff changeset
5 #include "core/http.h"
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
6 #include "core/json.h"
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
7 #include "core/session.h"
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
8 #include "core/strings.h"
15
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
9 #include "gui/translate/anilist.h"
77
6f7385bd334c *: update
Paper <mrpapersonic@gmail.com>
parents: 76
diff changeset
10 #include <QByteArray>
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
11 #include <QDesktopServices>
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
12 #include <QInputDialog>
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
13 #include <QLineEdit>
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
14 #include <QMessageBox>
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
15 #include <QUrl>
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
16 #include <chrono>
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
17 #include <exception>
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
18 #define CLIENT_ID "13706"
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
19
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 63
diff changeset
20 using namespace nlohmann::literals::json_literals;
11
fc1bf97c528b *: use C++11 standard
Paper <mrpapersonic@gmail.com>
parents: 10
diff changeset
21
63
3d2decf093bb *: fix many clang warnings
Paper <mrpapersonic@gmail.com>
parents: 52
diff changeset
22 namespace Services {
3d2decf093bb *: fix many clang warnings
Paper <mrpapersonic@gmail.com>
parents: 52
diff changeset
23 namespace AniList {
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
24
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
25 class Account {
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
26 public:
120
275da698697d config: template-ify INI
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
27 std::string Username() const { return session.config.auth.anilist.username; }
275da698697d config: template-ify INI
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
28 void SetUsername(std::string const& username) { session.config.auth.anilist.username = username; }
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
29
120
275da698697d config: template-ify INI
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
30 int UserId() const { return session.config.auth.anilist.user_id; }
275da698697d config: template-ify INI
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
31 void SetUserId(const int id) { session.config.auth.anilist.user_id = id; }
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
32
120
275da698697d config: template-ify INI
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
33 std::string AuthToken() const { return session.config.auth.anilist.auth_token; }
275da698697d config: template-ify INI
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
34 void SetAuthToken(std::string const& auth_token) { session.config.auth.anilist.auth_token = auth_token; }
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
35
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
36 bool Authenticated() const { return !AuthToken().empty(); }
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
37 };
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
38
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
39 static Account account;
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
40
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
41 std::string SendRequest(std::string data) {
76
3364fadc8a36 *: format source code
Paper <mrpapersonic@gmail.com>
parents: 75
diff changeset
42 std::vector<std::string> headers = {"Authorization: Bearer " + account.AuthToken(), "Accept: application/json",
3364fadc8a36 *: format source code
Paper <mrpapersonic@gmail.com>
parents: 75
diff changeset
43 "Content-Type: application/json"};
77
6f7385bd334c *: update
Paper <mrpapersonic@gmail.com>
parents: 76
diff changeset
44 return Strings::ToUtf8String(HTTP::Post("https://graphql.anilist.co", data, headers));
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
45 }
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
46
15
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
47 void ParseListStatus(std::string status, Anime::Anime& anime) {
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
48 std::unordered_map<std::string, Anime::ListStatus> map = {
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
49 {"CURRENT", Anime::ListStatus::CURRENT },
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
50 {"PLANNING", Anime::ListStatus::PLANNING },
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
51 {"COMPLETED", Anime::ListStatus::COMPLETED},
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
52 {"DROPPED", Anime::ListStatus::DROPPED },
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
53 {"PAUSED", Anime::ListStatus::PAUSED }
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
54 };
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
55
15
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
56 if (status == "REPEATING") {
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
57 anime.SetUserIsRewatching(true);
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
58 anime.SetUserStatus(Anime::ListStatus::CURRENT);
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
59 return;
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
60 }
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
61
47
d8eb763e6661 information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents: 44
diff changeset
62 if (map.find(status) == map.end()) {
15
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
63 anime.SetUserStatus(Anime::ListStatus::NOT_IN_LIST);
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
64 return;
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
65 }
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
66
15
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
67 anime.SetUserStatus(map[status]);
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
68 }
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
69
15
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
70 std::string ListStatusToString(const Anime::Anime& anime) {
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
71 if (anime.GetUserIsRewatching())
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
72 return "REWATCHING";
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
73
70
64e5f427c6a2 services/anilist: remove unordered_map usage for enum classes
Paper <mrpapersonic@gmail.com>
parents: 66
diff changeset
74 switch (anime.GetUserStatus()) {
76
3364fadc8a36 *: format source code
Paper <mrpapersonic@gmail.com>
parents: 75
diff changeset
75 case Anime::ListStatus::PLANNING: return "PLANNING";
3364fadc8a36 *: format source code
Paper <mrpapersonic@gmail.com>
parents: 75
diff changeset
76 case Anime::ListStatus::COMPLETED: return "COMPLETED";
3364fadc8a36 *: format source code
Paper <mrpapersonic@gmail.com>
parents: 75
diff changeset
77 case Anime::ListStatus::DROPPED: return "DROPPED";
3364fadc8a36 *: format source code
Paper <mrpapersonic@gmail.com>
parents: 75
diff changeset
78 case Anime::ListStatus::PAUSED: return "PAUSED";
3364fadc8a36 *: format source code
Paper <mrpapersonic@gmail.com>
parents: 75
diff changeset
79 default: break;
70
64e5f427c6a2 services/anilist: remove unordered_map usage for enum classes
Paper <mrpapersonic@gmail.com>
parents: 66
diff changeset
80 }
64e5f427c6a2 services/anilist: remove unordered_map usage for enum classes
Paper <mrpapersonic@gmail.com>
parents: 66
diff changeset
81 return "CURRENT";
15
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
82 }
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
83
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
84 Date ParseDate(const nlohmann::json& json) {
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
85 Date date;
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 63
diff changeset
86 /* JSON for Modern C++ warns here. I'm not too sure why, this code works when I set the
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 63
diff changeset
87 standard to C++17 :/ */
11
fc1bf97c528b *: use C++11 standard
Paper <mrpapersonic@gmail.com>
parents: 10
diff changeset
88 if (json.contains("/year"_json_pointer) && json.at("/year"_json_pointer).is_number())
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
89 date.SetYear(JSON::GetInt(json, "/year"_json_pointer));
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
90 else
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
91 date.VoidYear();
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
92
11
fc1bf97c528b *: use C++11 standard
Paper <mrpapersonic@gmail.com>
parents: 10
diff changeset
93 if (json.contains("/month"_json_pointer) && json.at("/month"_json_pointer).is_number())
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
94 date.SetMonth(JSON::GetInt(json, "/month"_json_pointer));
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
95 else
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
96 date.VoidMonth();
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
97
11
fc1bf97c528b *: use C++11 standard
Paper <mrpapersonic@gmail.com>
parents: 10
diff changeset
98 if (json.contains("/day"_json_pointer) && json.at("/day"_json_pointer).is_number())
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
99 date.SetDay(JSON::GetInt(json, "/day"_json_pointer));
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
100 else
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
101 date.VoidDay();
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
102 return date;
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
103 }
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
104
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
105 void ParseTitle(const nlohmann::json& json, Anime::Anime& anime) {
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
106 anime.SetNativeTitle(JSON::GetString(json, "/native"_json_pointer));
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
107 anime.SetEnglishTitle(JSON::GetString(json, "/english"_json_pointer));
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
108 anime.SetRomajiTitle(JSON::GetString(json, "/romaji"_json_pointer));
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
109 }
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
110
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
111 int ParseMediaJson(const nlohmann::json& json) {
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
112 int id = JSON::GetInt(json, "/id"_json_pointer);
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
113 if (!id)
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
114 return 0;
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
115 Anime::Anime& anime = Anime::db.items[id];
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
116 anime.SetId(id);
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
117
11
fc1bf97c528b *: use C++11 standard
Paper <mrpapersonic@gmail.com>
parents: 10
diff changeset
118 ParseTitle(json.at("/title"_json_pointer), anime);
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
119
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
120 anime.SetEpisodes(JSON::GetInt(json, "/episodes"_json_pointer));
15
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
121 anime.SetFormat(Translate::AniList::ToSeriesFormat(JSON::GetString(json, "/format"_json_pointer)));
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
122
15
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
123 anime.SetAiringStatus(Translate::AniList::ToSeriesStatus(JSON::GetString(json, "/status"_json_pointer)));
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
124
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
125 anime.SetAirDate(ParseDate(json["/startDate"_json_pointer]));
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
126
66
6481c5aed3e1 posters: add poster widget...
Paper <mrpapersonic@gmail.com>
parents: 65
diff changeset
127 anime.SetPosterUrl(JSON::GetString(json, "/coverImage/large"_json_pointer));
6481c5aed3e1 posters: add poster widget...
Paper <mrpapersonic@gmail.com>
parents: 65
diff changeset
128
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
129 anime.SetAudienceScore(JSON::GetInt(json, "/averageScore"_json_pointer));
15
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
130 anime.SetSeason(Translate::AniList::ToSeriesSeason(JSON::GetString(json, "/season"_json_pointer)));
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
131 anime.SetDuration(JSON::GetInt(json, "/duration"_json_pointer));
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
132 anime.SetSynopsis(Strings::TextifySynopsis(JSON::GetString(json, "/description"_json_pointer)));
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
133
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
134 if (json.contains("/genres"_json_pointer) && json["/genres"_json_pointer].is_array())
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
135 anime.SetGenres(json["/genres"_json_pointer].get<std::vector<std::string>>());
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
136 if (json.contains("/synonyms"_json_pointer) && json["/synonyms"_json_pointer].is_array())
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
137 anime.SetTitleSynonyms(json["/synonyms"_json_pointer].get<std::vector<std::string>>());
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
138 return id;
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
139 }
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
140
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
141 int ParseListItem(const nlohmann::json& json) {
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
142 int id = ParseMediaJson(json["media"]);
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
143
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
144 Anime::Anime& anime = Anime::db.items[id];
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
145
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
146 anime.AddToUserList();
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
147
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
148 anime.SetUserScore(JSON::GetInt(json, "/score"_json_pointer));
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
149 anime.SetUserProgress(JSON::GetInt(json, "/progress"_json_pointer));
15
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
150 ParseListStatus(JSON::GetString(json, "/status"_json_pointer), anime);
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
151 anime.SetUserNotes(JSON::GetString(json, "/notes"_json_pointer));
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
152
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
153 anime.SetUserDateStarted(ParseDate(json["/startedAt"_json_pointer]));
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
154 anime.SetUserDateCompleted(ParseDate(json["/completedAt"_json_pointer]));
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
155
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
156 anime.SetUserTimeUpdated(JSON::GetInt(json, "/updatedAt"_json_pointer));
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
157
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
158 return id;
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
159 }
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
160
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
161 int ParseList(const nlohmann::json& json) {
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
162 for (const auto& entry : json["entries"].items()) {
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
163 ParseListItem(entry.value());
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
164 }
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
165 return 1;
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
166 }
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
167
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
168 int GetAnimeList() {
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
169 /* NOTE: these should be in the qrc file */
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
170 const std::string query = "query ($id: Int) {\n"
15
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
171 " MediaListCollection (userId: $id, type: ANIME) {\n"
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
172 " lists {\n"
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
173 " name\n"
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
174 " entries {\n"
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
175 " score\n"
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
176 " notes\n"
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
177 " status\n"
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
178 " progress\n"
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
179 " startedAt {\n"
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
180 " year\n"
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
181 " month\n"
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
182 " day\n"
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
183 " }\n"
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
184 " completedAt {\n"
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
185 " year\n"
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
186 " month\n"
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
187 " day\n"
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
188 " }\n"
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
189 " updatedAt\n"
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
190 " media {\n"
66
6481c5aed3e1 posters: add poster widget...
Paper <mrpapersonic@gmail.com>
parents: 65
diff changeset
191 " coverImage {\n"
6481c5aed3e1 posters: add poster widget...
Paper <mrpapersonic@gmail.com>
parents: 65
diff changeset
192 " large\n"
6481c5aed3e1 posters: add poster widget...
Paper <mrpapersonic@gmail.com>
parents: 65
diff changeset
193 " }\n"
15
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
194 " id\n"
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
195 " title {\n"
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
196 " romaji\n"
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
197 " english\n"
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
198 " native\n"
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
199 " }\n"
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
200 " format\n"
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
201 " status\n"
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
202 " averageScore\n"
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
203 " season\n"
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
204 " startDate {\n"
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
205 " year\n"
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
206 " month\n"
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
207 " day\n"
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
208 " }\n"
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
209 " genres\n"
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
210 " episodes\n"
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
211 " duration\n"
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
212 " synonyms\n"
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
213 " description(asHtml: false)\n"
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
214 " }\n"
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
215 " }\n"
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
216 " }\n"
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
217 " }\n"
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
218 "}\n";
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
219 // clang-format off
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
220 nlohmann::json json = {
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
221 {"query", query},
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
222 {"variables", {
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
223 {"id", account.UserId()}
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
224 }}
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
225 };
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
226 // clang-format on
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
227 /* TODO: do a try catch here, catch any json errors and then call
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
228 Authorize() if needed */
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
229 auto res = nlohmann::json::parse(SendRequest(json.dump()));
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
230 /* TODO: make sure that we actually need the wstring converter and see
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
231 if we can just get wide strings back from nlohmann::json */
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
232 for (const auto& list : res["data"]["MediaListCollection"]["lists"].items()) {
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
233 ParseList(list.value());
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
234 }
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
235 return 1;
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
236 }
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
237
52
0c4138de2ea7 anime list: we are finally read-write
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
238 int UpdateAnimeEntry(int id) {
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
239 /**
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
240 * possible values:
15
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
241 *
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
242 * int mediaId,
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
243 * MediaListStatus status,
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
244 * float score,
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
245 * int scoreRaw,
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
246 * int progress,
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
247 * int progressVolumes,
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
248 * int repeat,
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
249 * int priority,
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
250 * bool private,
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
251 * string notes,
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
252 * bool hiddenFromStatusLists,
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
253 * string[] customLists,
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
254 * float[] advancedScores,
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
255 * Date startedAt,
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
256 * Date completedAt
15
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
257 **/
52
0c4138de2ea7 anime list: we are finally read-write
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
258 Anime::Anime& anime = Anime::db.items[id];
77
6f7385bd334c *: update
Paper <mrpapersonic@gmail.com>
parents: 76
diff changeset
259 const std::string query = "mutation ($media_id: Int, $progress: Int, $status: MediaListStatus, $score: Int, "
6f7385bd334c *: update
Paper <mrpapersonic@gmail.com>
parents: 76
diff changeset
260 "$notes: String, $start: FuzzyDateInput, $comp: FuzzyDateInput) {\n"
6f7385bd334c *: update
Paper <mrpapersonic@gmail.com>
parents: 76
diff changeset
261 " SaveMediaListEntry (mediaId: $media_id, progress: $progress, status: $status, "
6f7385bd334c *: update
Paper <mrpapersonic@gmail.com>
parents: 76
diff changeset
262 "scoreRaw: $score, notes: $notes, startedAt: $start, completedAt: $comp) {\n"
6f7385bd334c *: update
Paper <mrpapersonic@gmail.com>
parents: 76
diff changeset
263 " id\n"
6f7385bd334c *: update
Paper <mrpapersonic@gmail.com>
parents: 76
diff changeset
264 " }\n"
6f7385bd334c *: update
Paper <mrpapersonic@gmail.com>
parents: 76
diff changeset
265 "}\n";
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
266 // clang-format off
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
267 nlohmann::json json = {
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
268 {"query", query},
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
269 {"variables", {
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
270 {"media_id", anime.GetId()},
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
271 {"progress", anime.GetUserProgress()},
15
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
272 {"status", ListStatusToString(anime)},
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
273 {"score", anime.GetUserScore()},
77
6f7385bd334c *: update
Paper <mrpapersonic@gmail.com>
parents: 76
diff changeset
274 {"notes", anime.GetUserNotes()},
6f7385bd334c *: update
Paper <mrpapersonic@gmail.com>
parents: 76
diff changeset
275 {"start", anime.GetUserDateStarted().GetAsAniListJson()},
6f7385bd334c *: update
Paper <mrpapersonic@gmail.com>
parents: 76
diff changeset
276 {"comp", anime.GetUserDateCompleted().GetAsAniListJson()}
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
277 }}
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
278 };
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
279 // clang-format on
52
0c4138de2ea7 anime list: we are finally read-write
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
280 auto ret = nlohmann::json::parse(SendRequest(json.dump()));
0c4138de2ea7 anime list: we are finally read-write
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
281 return JSON::GetInt(ret, "/data/SaveMediaListEntry/id"_json_pointer);
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
282 }
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
283
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
284 int ParseUser(const nlohmann::json& json) {
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
285 account.SetUsername(JSON::GetString(json, "/name"_json_pointer));
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
286 account.SetUserId(JSON::GetInt(json, "/id"_json_pointer));
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
287 return account.UserId();
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
288 }
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
289
44
619cbd6e69f9 filesystem: fix CreateDirectories function
Paper <mrpapersonic@gmail.com>
parents: 36
diff changeset
290 bool AuthorizeUser() {
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
291 /* Prompt for PIN */
36
2743011a6042 *: mass update
Paper <mrpapersonic@gmail.com>
parents: 15
diff changeset
292 QDesktopServices::openUrl(
2743011a6042 *: mass update
Paper <mrpapersonic@gmail.com>
parents: 15
diff changeset
293 QUrl("https://anilist.co/api/v2/oauth/authorize?client_id=" CLIENT_ID "&response_type=token"));
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
294 bool ok;
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
295 QString token = QInputDialog::getText(
36
2743011a6042 *: mass update
Paper <mrpapersonic@gmail.com>
parents: 15
diff changeset
296 0, "Credentials needed!", "Please enter the code given to you after logging in to AniList:", QLineEdit::Normal,
2743011a6042 *: mass update
Paper <mrpapersonic@gmail.com>
parents: 15
diff changeset
297 "", &ok);
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
298 if (ok && !token.isEmpty())
65
26721c28bf22 *: avoid usage of (to|from)StdString
Paper <mrpapersonic@gmail.com>
parents: 64
diff changeset
299 account.SetAuthToken(Strings::ToUtf8String(token));
15
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
300 else // fail
44
619cbd6e69f9 filesystem: fix CreateDirectories function
Paper <mrpapersonic@gmail.com>
parents: 36
diff changeset
301 return false;
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
302 const std::string query = "query {\n"
15
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
303 " Viewer {\n"
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
304 " id\n"
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
305 " name\n"
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
306 " mediaListOptions {\n"
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
307 " scoreFormat\n"
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
308 " }\n"
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
309 " }\n"
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 11
diff changeset
310 "}\n";
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
311 nlohmann::json json = {
63
3d2decf093bb *: fix many clang warnings
Paper <mrpapersonic@gmail.com>
parents: 52
diff changeset
312 {"query", query}
3d2decf093bb *: fix many clang warnings
Paper <mrpapersonic@gmail.com>
parents: 52
diff changeset
313 };
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
314 auto ret = nlohmann::json::parse(SendRequest(json.dump()));
74
5ccb99bfa605 fix regressions on macOS
Paper <mrpapersonic@gmail.com>
parents: 70
diff changeset
315 ParseUser(ret["data"]["Viewer"]);
44
619cbd6e69f9 filesystem: fix CreateDirectories function
Paper <mrpapersonic@gmail.com>
parents: 36
diff changeset
316 return true;
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
317 }
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
318
63
3d2decf093bb *: fix many clang warnings
Paper <mrpapersonic@gmail.com>
parents: 52
diff changeset
319 } // namespace AniList
3d2decf093bb *: fix many clang warnings
Paper <mrpapersonic@gmail.com>
parents: 52
diff changeset
320 } // namespace Services