comparison src/services/anilist.cc @ 183:01d259b9c89f

pages/torrents.cc: parse feed descriptions separately services/anilist.cc: use constexpr STL string_view for HTTP queries
author Paper <mrpapersonic@gmail.com>
date Mon, 04 Dec 2023 13:40:42 -0500
parents 9b10175be389
children 09492158bcc5
comparison
equal deleted inserted replaced
182:c413e475f496 183:01d259b9c89f
175 if (!account.IsValid()) { 175 if (!account.IsValid()) {
176 std::cerr << "AniList: Account isn't valid!" << std::endl; 176 std::cerr << "AniList: Account isn't valid!" << std::endl;
177 return 0; 177 return 0;
178 } 178 }
179 179
180 /* NOTE: these should be in the qrc file */ 180 /* NOTE: these really ought to be in the qrc file */
181 const std::string query = "query ($id: Int) {\n" 181 constexpr std::string_view query = "query ($id: Int) {\n"
182 " MediaListCollection (userId: $id, type: ANIME) {\n" 182 " MediaListCollection (userId: $id, type: ANIME) {\n"
183 " lists {\n" 183 " lists {\n"
184 " name\n" 184 " name\n"
185 " entries {\n" 185 " entries {\n"
186 " score\n" 186 " score\n"
263 * float[] advancedScores, 263 * float[] advancedScores,
264 * Date startedAt, 264 * Date startedAt,
265 * Date completedAt 265 * Date completedAt
266 **/ 266 **/
267 Anime::Anime& anime = Anime::db.items[id]; 267 Anime::Anime& anime = Anime::db.items[id];
268 const std::string query = "mutation ($media_id: Int, $progress: Int, $status: MediaListStatus, $score: Int, " 268 constexpr std::string_view query = "mutation ($media_id: Int, $progress: Int, $status: MediaListStatus, $score: Int, "
269 "$notes: String, $start: FuzzyDateInput, $comp: FuzzyDateInput) {\n" 269 "$notes: String, $start: FuzzyDateInput, $comp: FuzzyDateInput) {\n"
270 " SaveMediaListEntry (mediaId: $media_id, progress: $progress, status: $status, " 270 " SaveMediaListEntry (mediaId: $media_id, progress: $progress, status: $status, "
271 "scoreRaw: $score, notes: $notes, startedAt: $start, completedAt: $comp) {\n" 271 "scoreRaw: $score, notes: $notes, startedAt: $start, completedAt: $comp) {\n"
272 " id\n" 272 " id\n"
273 " }\n" 273 " }\n"
311 if (!ok || token.isEmpty()) 311 if (!ok || token.isEmpty())
312 return false; 312 return false;
313 313
314 account.SetAuthToken(Strings::ToUtf8String(token)); 314 account.SetAuthToken(Strings::ToUtf8String(token));
315 315
316 const std::string query = "query {\n" 316 constexpr std::string_view query = "query {\n"
317 " Viewer {\n" 317 " Viewer {\n"
318 " id\n" 318 " id\n"
319 " name\n" 319 " name\n"
320 " mediaListOptions {\n" 320 " mediaListOptions {\n"
321 " scoreFormat\n" // this will be used... eventually 321 " scoreFormat\n" // this will be used... eventually