Mercurial > minori
diff src/gui/translate/anilist.cc @ 81:9b2b41f83a5e
boring: mass rename to cc
because this is a very unix-y project, it makes more sense to use the
'cc' extension
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Mon, 23 Oct 2023 12:07:27 -0400 |
parents | src/gui/translate/anilist.cpp@3d2decf093bb |
children | 9613d72b097e |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/gui/translate/anilist.cc Mon Oct 23 12:07:27 2023 -0400 @@ -0,0 +1,53 @@ +#include "gui/translate/anilist.h" + +namespace Translate { +namespace AniList { + +Anime::SeriesStatus ToSeriesStatus(std::string status) { + const std::unordered_map<std::string, Anime::SeriesStatus> map = { + {"FINISHED", Anime::SeriesStatus::FINISHED }, + {"RELEASING", Anime::SeriesStatus::RELEASING }, + {"NOT_YET_RELEASED", Anime::SeriesStatus::NOT_YET_RELEASED}, + {"CANCELLED", Anime::SeriesStatus::CANCELLED }, + {"HIATUS", Anime::SeriesStatus::HIATUS } + }; + + if (map.find(status) == map.end()) + return Anime::SeriesStatus::UNKNOWN; + return map.at(status); +} + +Anime::SeriesSeason ToSeriesSeason(std::string season) { + const std::unordered_map<std::string, Anime::SeriesSeason> map = { + {"WINTER", Anime::SeriesSeason::WINTER}, + {"SPRING", Anime::SeriesSeason::SPRING}, + {"SUMMER", Anime::SeriesSeason::SUMMER}, + {"FALL", Anime::SeriesSeason::FALL } + }; + + if (map.find(season) == map.end()) + return Anime::SeriesSeason::UNKNOWN; + return map.at(season); +} + +Anime::SeriesFormat ToSeriesFormat(std::string format) { + const std::unordered_map<std::string, enum Anime::SeriesFormat> map = { + {"TV", Anime::SeriesFormat::TV }, + {"TV_SHORT", Anime::SeriesFormat::TV_SHORT}, + {"MOVIE", Anime::SeriesFormat::MOVIE }, + {"SPECIAL", Anime::SeriesFormat::SPECIAL }, + {"OVA", Anime::SeriesFormat::OVA }, + {"ONA", Anime::SeriesFormat::ONA }, + {"MUSIC", Anime::SeriesFormat::MUSIC }, + {"MANGA", Anime::SeriesFormat::MANGA }, + {"NOVEL", Anime::SeriesFormat::NOVEL }, + {"ONE_SHOT", Anime::SeriesFormat::ONE_SHOT} + }; + + if (map.find(format) == map.end()) + return Anime::SeriesFormat::UNKNOWN; + return map.at(format); +} + +} // namespace AniList +} // namespace Translate