Mercurial > minori
comparison src/gui/translate/anilist.cpp @ 47:d8eb763e6661
information.cpp: add widgets to the list tab, and add an
"optional date" widget like taiga has so users can specify whether to
set the date or not
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Mon, 25 Sep 2023 00:43:38 -0400 |
parents | d0adc4aedfc8 |
children | 3d2decf093bb |
comparison
equal
deleted
inserted
replaced
46:d0adc4aedfc8 | 47:d8eb763e6661 |
---|---|
1 #include "gui/translate/anilist.h" | 1 #include "gui/translate/anilist.h" |
2 | 2 |
3 namespace Translate::AniList { | 3 namespace Translate::AniList { |
4 | 4 |
5 Anime::SeriesStatus ToSeriesStatus(std::string status) { | 5 Anime::SeriesStatus ToSeriesStatus(std::string status) { |
6 std::unordered_map<std::string, Anime::SeriesStatus> map = { | 6 const std::unordered_map<std::string, Anime::SeriesStatus> map = { |
7 {"FINISHED", Anime::SeriesStatus::FINISHED }, | 7 {"FINISHED", Anime::SeriesStatus::FINISHED }, |
8 {"RELEASING", Anime::SeriesStatus::RELEASING }, | 8 {"RELEASING", Anime::SeriesStatus::RELEASING }, |
9 {"NOT_YET_RELEASED", Anime::SeriesStatus::NOT_YET_RELEASED}, | 9 {"NOT_YET_RELEASED", Anime::SeriesStatus::NOT_YET_RELEASED}, |
10 {"CANCELLED", Anime::SeriesStatus::CANCELLED }, | 10 {"CANCELLED", Anime::SeriesStatus::CANCELLED }, |
11 {"HIATUS", Anime::SeriesStatus::HIATUS } | 11 {"HIATUS", Anime::SeriesStatus::HIATUS } |
12 }; | 12 }; |
13 | 13 |
14 if (!map.contains(status)) | 14 if (map.find(status) == map.end()) |
15 return Anime::SeriesStatus::UNKNOWN; | 15 return Anime::SeriesStatus::UNKNOWN; |
16 return map[status]; | 16 return map.at(status); |
17 } | 17 } |
18 | 18 |
19 Anime::SeriesSeason ToSeriesSeason(std::string season) { | 19 Anime::SeriesSeason ToSeriesSeason(std::string season) { |
20 std::unordered_map<std::string, Anime::SeriesSeason> map = { | 20 const std::unordered_map<std::string, Anime::SeriesSeason> map = { |
21 {"WINTER", Anime::SeriesSeason::WINTER}, | 21 {"WINTER", Anime::SeriesSeason::WINTER}, |
22 {"SPRING", Anime::SeriesSeason::SPRING}, | 22 {"SPRING", Anime::SeriesSeason::SPRING}, |
23 {"SUMMER", Anime::SeriesSeason::SUMMER}, | 23 {"SUMMER", Anime::SeriesSeason::SUMMER}, |
24 {"FALL", Anime::SeriesSeason::FALL } | 24 {"FALL", Anime::SeriesSeason::FALL } |
25 }; | 25 }; |
26 | 26 |
27 if (!map.contains(season)) | 27 if (map.find(season) == map.end()) |
28 return Anime::SeriesSeason::UNKNOWN; | 28 return Anime::SeriesSeason::UNKNOWN; |
29 return map[season]; | 29 return map.at(season); |
30 } | 30 } |
31 | 31 |
32 Anime::SeriesFormat ToSeriesFormat(std::string format) { | 32 Anime::SeriesFormat ToSeriesFormat(std::string format) { |
33 std::unordered_map<std::string, enum Anime::SeriesFormat> map = { | 33 const std::unordered_map<std::string, enum Anime::SeriesFormat> map = { |
34 {"TV", Anime::SeriesFormat::TV }, | 34 {"TV", Anime::SeriesFormat::TV }, |
35 {"TV_SHORT", Anime::SeriesFormat::TV_SHORT}, | 35 {"TV_SHORT", Anime::SeriesFormat::TV_SHORT}, |
36 {"MOVIE", Anime::SeriesFormat::MOVIE }, | 36 {"MOVIE", Anime::SeriesFormat::MOVIE }, |
37 {"SPECIAL", Anime::SeriesFormat::SPECIAL }, | 37 {"SPECIAL", Anime::SeriesFormat::SPECIAL }, |
38 {"OVA", Anime::SeriesFormat::OVA }, | 38 {"OVA", Anime::SeriesFormat::OVA }, |
41 {"MANGA", Anime::SeriesFormat::MANGA }, | 41 {"MANGA", Anime::SeriesFormat::MANGA }, |
42 {"NOVEL", Anime::SeriesFormat::NOVEL }, | 42 {"NOVEL", Anime::SeriesFormat::NOVEL }, |
43 {"ONE_SHOT", Anime::SeriesFormat::ONE_SHOT} | 43 {"ONE_SHOT", Anime::SeriesFormat::ONE_SHOT} |
44 }; | 44 }; |
45 | 45 |
46 if (!map.contains(format)) | 46 if (map.find(format) == map.end()) |
47 return Anime::SeriesFormat::UNKNOWN; | 47 return Anime::SeriesFormat::UNKNOWN; |
48 return map[format]; | 48 return map.at(format); |
49 } | 49 } |
50 | 50 |
51 } // namespace Translate::AniList | 51 } // namespace Translate::AniList |