comparison src/services/anilist.cpp @ 76:3364fadc8a36

*: format source code
author Paper <mrpapersonic@gmail.com>
date Wed, 04 Oct 2023 01:46:33 -0400
parents d3e9310598b1
children 6f7385bd334c
comparison
equal deleted inserted replaced
75:d3e9310598b1 76:3364fadc8a36
1 #include "services/anilist.h" 1 #include "services/anilist.h"
2 #include "core/anime.h" 2 #include "core/anime.h"
3 #include "core/anime_db.h" 3 #include "core/anime_db.h"
4 #include "core/config.h" 4 #include "core/config.h"
5 #include "core/http.h"
5 #include "core/json.h" 6 #include "core/json.h"
6 #include "core/http.h"
7 #include "core/session.h" 7 #include "core/session.h"
8 #include "core/strings.h" 8 #include "core/strings.h"
9 #include "gui/translate/anilist.h" 9 #include "gui/translate/anilist.h"
10 #include <QDesktopServices> 10 #include <QDesktopServices>
11 #include <QInputDialog> 11 #include <QInputDialog>
36 }; 36 };
37 37
38 static Account account; 38 static Account account;
39 39
40 std::string SendRequest(std::string data) { 40 std::string SendRequest(std::string data) {
41 std::vector<std::string> headers = { 41 std::vector<std::string> headers = {"Authorization: Bearer " + account.AuthToken(), "Accept: application/json",
42 "Authorization: Bearer " + account.AuthToken(), 42 "Content-Type: application/json"};
43 "Accept: application/json",
44 "Content-Type: application/json"
45 };
46 return HTTP::PerformBasicPostRequest("https://graphql.anilist.co", data, headers); 43 return HTTP::PerformBasicPostRequest("https://graphql.anilist.co", data, headers);
47 } 44 }
48 45
49 void ParseListStatus(std::string status, Anime::Anime& anime) { 46 void ParseListStatus(std::string status, Anime::Anime& anime) {
50 std::unordered_map<std::string, Anime::ListStatus> map = { 47 std::unordered_map<std::string, Anime::ListStatus> map = {
72 std::string ListStatusToString(const Anime::Anime& anime) { 69 std::string ListStatusToString(const Anime::Anime& anime) {
73 if (anime.GetUserIsRewatching()) 70 if (anime.GetUserIsRewatching())
74 return "REWATCHING"; 71 return "REWATCHING";
75 72
76 switch (anime.GetUserStatus()) { 73 switch (anime.GetUserStatus()) {
77 case Anime::ListStatus::PLANNING: 74 case Anime::ListStatus::PLANNING: return "PLANNING";
78 return "PLANNING"; 75 case Anime::ListStatus::COMPLETED: return "COMPLETED";
79 case Anime::ListStatus::COMPLETED: 76 case Anime::ListStatus::DROPPED: return "DROPPED";
80 return "COMPLETED"; 77 case Anime::ListStatus::PAUSED: return "PAUSED";
81 case Anime::ListStatus::DROPPED: 78 default: break;
82 return "DROPPED";
83 case Anime::ListStatus::PAUSED:
84 return "PAUSED";
85 default:
86 break;
87 } 79 }
88 return "CURRENT"; 80 return "CURRENT";
89 } 81 }
90 82
91 Date ParseDate(const nlohmann::json& json) { 83 Date ParseDate(const nlohmann::json& json) {