Mercurial > minori
comparison src/services/anilist.cpp @ 44:619cbd6e69f9
filesystem: fix CreateDirectories function
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Fri, 22 Sep 2023 13:52:11 -0400 |
parents | 2743011a6042 |
children | d8eb763e6661 |
comparison
equal
deleted
inserted
replaced
43:eb9a78345ecb | 44:619cbd6e69f9 |
---|---|
307 account.SetUsername(JSON::GetString(json, "/name"_json_pointer)); | 307 account.SetUsername(JSON::GetString(json, "/name"_json_pointer)); |
308 account.SetUserId(JSON::GetInt(json, "/id"_json_pointer)); | 308 account.SetUserId(JSON::GetInt(json, "/id"_json_pointer)); |
309 return account.UserId(); | 309 return account.UserId(); |
310 } | 310 } |
311 | 311 |
312 int AuthorizeUser() { | 312 bool AuthorizeUser() { |
313 /* Prompt for PIN */ | 313 /* Prompt for PIN */ |
314 QDesktopServices::openUrl( | 314 QDesktopServices::openUrl( |
315 QUrl("https://anilist.co/api/v2/oauth/authorize?client_id=" CLIENT_ID "&response_type=token")); | 315 QUrl("https://anilist.co/api/v2/oauth/authorize?client_id=" CLIENT_ID "&response_type=token")); |
316 bool ok; | 316 bool ok; |
317 QString token = QInputDialog::getText( | 317 QString token = QInputDialog::getText( |
318 0, "Credentials needed!", "Please enter the code given to you after logging in to AniList:", QLineEdit::Normal, | 318 0, "Credentials needed!", "Please enter the code given to you after logging in to AniList:", QLineEdit::Normal, |
319 "", &ok); | 319 "", &ok); |
320 if (ok && !token.isEmpty()) | 320 if (ok && !token.isEmpty()) |
321 account.SetAuthToken(token.toStdString()); | 321 account.SetAuthToken(token.toStdString()); |
322 else // fail | 322 else // fail |
323 return 0; | 323 return false; |
324 const std::string query = "query {\n" | 324 const std::string query = "query {\n" |
325 " Viewer {\n" | 325 " Viewer {\n" |
326 " id\n" | 326 " id\n" |
327 " name\n" | 327 " name\n" |
328 " mediaListOptions {\n" | 328 " mediaListOptions {\n" |
329 " scoreFormat\n" | 329 " scoreFormat\n" |
330 " }\n" | 330 " }\n" |
331 " }\n" | 331 " }\n" |
332 "}\n"; | 332 "}\n"; |
333 nlohmann::json json = { | 333 nlohmann::json json = { |
334 {"query", query} | 334 {"query", query} |
335 }; | 335 }; |
336 auto ret = nlohmann::json::parse(SendRequest(json.dump())); | 336 auto ret = nlohmann::json::parse(SendRequest(json.dump())); |
337 ParseUser(json["Viewer"]); | 337 ParseUser(json["Viewer"]); |
338 return 1; | 338 return true; |
339 } | 339 } |
340 | 340 |
341 } // namespace Services::AniList | 341 } // namespace Services::AniList |