comparison src/services/anilist.cc @ 185:62e336597bb7

anime list: add support for different score formats
author Paper <mrpapersonic@gmail.com>
date Tue, 05 Dec 2023 13:45:23 -0500
parents 09492158bcc5
children 9613d72b097e
comparison
equal deleted inserted replaced
184:09492158bcc5 185:62e336597bb7
16 #include <chrono> 16 #include <chrono>
17 #include <exception> 17 #include <exception>
18 18
19 #include <iostream> 19 #include <iostream>
20 20
21 #define CLIENT_ID "13706"
22
23 using namespace nlohmann::literals::json_literals; 21 using namespace nlohmann::literals::json_literals;
24 22
25 namespace Services { 23 namespace Services {
26 namespace AniList { 24 namespace AniList {
25
26 constexpr int CLIENT_ID = 13706;
27 27
28 class Account { 28 class Account {
29 public: 29 public:
30 std::string Username() const { return session.config.auth.anilist.username; } 30 std::string Username() const { return session.config.auth.anilist.username; }
31 void SetUsername(std::string const& username) { session.config.auth.anilist.username = username; } 31 void SetUsername(std::string const& username) { session.config.auth.anilist.username = username; }
303 } 303 }
304 304
305 bool AuthorizeUser() { 305 bool AuthorizeUser() {
306 /* Prompt for PIN */ 306 /* Prompt for PIN */
307 QDesktopServices::openUrl( 307 QDesktopServices::openUrl(
308 QUrl("https://anilist.co/api/v2/oauth/authorize?client_id=" CLIENT_ID "&response_type=token")); 308 QUrl(Strings::ToQString("https://anilist.co/api/v2/oauth/authorize?client_id=" + std::to_string(CLIENT_ID) + "&response_type=token")));
309 309
310 bool ok; 310 bool ok;
311 QString token = QInputDialog::getText( 311 QString token = QInputDialog::getText(
312 0, "Credentials needed!", "Please enter the code given to you after logging in to AniList:", QLineEdit::Normal, 312 0, "Credentials needed!", "Please enter the code given to you after logging in to AniList:", QLineEdit::Normal,
313 "", &ok); 313 "", &ok);