Mercurial > minori
comparison src/gui/translate/anime.cc @ 175:9b10175be389
dep/json: update to v3.11.3
anime/db: save anime list to database, very much untested and likely won't work as intended
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Thu, 30 Nov 2023 13:52:26 -0500 |
parents | f88eda79c60a |
children | 62e336597bb7 |
comparison
equal
deleted
inserted
replaced
174:f88eda79c60a | 175:9b10175be389 |
---|---|
48 case Anime::SeriesStatus::FINISHED: return "Finished airing"; | 48 case Anime::SeriesStatus::FINISHED: return "Finished airing"; |
49 case Anime::SeriesStatus::NOT_YET_RELEASED: return "Not yet aired"; | 49 case Anime::SeriesStatus::NOT_YET_RELEASED: return "Not yet aired"; |
50 case Anime::SeriesStatus::CANCELLED: return "Cancelled"; | 50 case Anime::SeriesStatus::CANCELLED: return "Cancelled"; |
51 case Anime::SeriesStatus::HIATUS: return "On hiatus"; | 51 case Anime::SeriesStatus::HIATUS: return "On hiatus"; |
52 default: | 52 default: |
53 case Anime::SeriesStatus::UNKNOWN: "Unknown"; | 53 case Anime::SeriesStatus::UNKNOWN: return "Unknown"; |
54 } | 54 } |
55 } | 55 } |
56 | 56 |
57 Anime::SeriesStatus ToListStatus(const std::string& str) { | 57 std::string ToString(const Anime::Services service) { |
58 const std::unordered_map<std::string, Anime::SeriesStatus> map = { | 58 switch (service) { |
59 {"Currently watching", Anime::SeriesSeason::CURRENT}, | 59 case Anime::Services::ANILIST: return "AniList"; |
60 {"Plan to watch", Anime::SeriesSeason::PLANNING}, | 60 default: |
61 {"Completed", Anime::SeriesSeason::COMPLETED}, | 61 case Anime::Services::NONE: return "None"; |
62 {"Dropped", Anime::SeriesSeason::DROPPED}, | 62 } |
63 {"On hold", Anime::SeriesSeason::PAUSED} | 63 } |
64 }; | 64 |
65 | 65 std::string ToString(const Anime::TitleLanguage language) { |
66 if (map.find(str) == map.end()) | 66 switch (language) { |
67 return Anime::SeriesStatus::NOT_IN_LIST; | 67 case Anime::TitleLanguage::NATIVE: return "Native"; |
68 case Anime::TitleLanguage::ENGLISH: return "English"; | |
69 default: | |
70 case Anime::TitleLanguage::ROMAJI: return "Romaji"; | |
71 } | |
72 } | |
73 | |
74 Anime::ListStatus ToListStatus(const std::string& str) { | |
75 const std::unordered_map<std::string, Anime::ListStatus> map = { | |
76 {"Currently watching", Anime::ListStatus::CURRENT}, | |
77 {"Plan to watch", Anime::ListStatus::PLANNING}, | |
78 {"Completed", Anime::ListStatus::COMPLETED}, | |
79 {"Dropped", Anime::ListStatus::DROPPED}, | |
80 {"On hold", Anime::ListStatus::PAUSED} | |
81 }; | |
82 | |
83 if (map.find(str) == map.end()) | |
84 return Anime::ListStatus::NOT_IN_LIST; | |
68 return map.at(str); | 85 return map.at(str); |
69 } | 86 } |
70 | 87 |
71 Anime::SeriesStatus ToSeriesStatus(const std::string& str) { | 88 Anime::SeriesStatus ToSeriesStatus(const std::string& str) { |
72 const std::unordered_map<std::string, Anime::SeriesStatus> map = { | 89 const std::unordered_map<std::string, Anime::SeriesStatus> map = { |
73 {"Currently airing", Anime::SeriesSeason::RELEASING}, | 90 {"Currently airing", Anime::SeriesStatus::RELEASING}, |
74 {"Finished airing", Anime::SeriesSeason::FINISHED}, | 91 {"Finished airing", Anime::SeriesStatus::FINISHED}, |
75 {"Not yet aired", Anime::SeriesSeason::NOT_YET_RELEASED}, | 92 {"Not yet aired", Anime::SeriesStatus::NOT_YET_RELEASED}, |
76 {"Cancelled", Anime::SeriesSeason::CANCELLED}, | 93 {"Cancelled", Anime::SeriesStatus::CANCELLED}, |
77 {"On hiatus", Anime::SeriesSeason::HIATUS} | 94 {"On hiatus", Anime::SeriesStatus::HIATUS} |
78 }; | 95 }; |
79 | 96 |
80 if (map.find(str) == map.end()) | 97 if (map.find(str) == map.end()) |
81 return Anime::SeriesStatus::UNKNOWN; | 98 return Anime::SeriesStatus::UNKNOWN; |
82 return map.at(str); | 99 return map.at(str); |
90 {"Spring", Anime::SeriesSeason::SPRING} | 107 {"Spring", Anime::SeriesSeason::SPRING} |
91 }; | 108 }; |
92 | 109 |
93 if (map.find(str) == map.end()) | 110 if (map.find(str) == map.end()) |
94 return Anime::SeriesSeason::UNKNOWN; | 111 return Anime::SeriesSeason::UNKNOWN; |
112 return map.at(str); | |
113 } | |
114 | |
115 Anime::SeriesFormat ToSeriesFormat(const std::string& str) { | |
116 const std::unordered_map<std::string, Anime::SeriesFormat> map = { | |
117 {"TV", Anime::SeriesFormat::TV}, | |
118 {"TV short", Anime::SeriesFormat::TV_SHORT}, | |
119 {"OVA", Anime::SeriesFormat::OVA}, | |
120 {"Movie", Anime::SeriesFormat::MOVIE}, | |
121 {"Special", Anime::SeriesFormat::SPECIAL}, | |
122 {"ONA", Anime::SeriesFormat::ONA}, | |
123 {"Music", Anime::SeriesFormat::MUSIC} | |
124 }; | |
125 | |
126 if (map.find(str) == map.end()) | |
127 return Anime::SeriesFormat::UNKNOWN; | |
95 return map.at(str); | 128 return map.at(str); |
96 } | 129 } |
97 | 130 |
98 Anime::Services ToService(const std::string& str) { | 131 Anime::Services ToService(const std::string& str) { |
99 const std::unordered_map<std::string, Anime::Services> map = { | 132 const std::unordered_map<std::string, Anime::Services> map = { |