annotate src/gui/translate/anilist.cc @ 301:b1f625b0227c

*: convert all files CRLF -> LF some files were in DOS format, others were in unix. now everything (that at least is under our control) should all be the same format
author Paper <paper@paper.us.eu.org>
date Mon, 13 May 2024 15:04:51 -0400
parents 657fda1b9cac
children 2115488eb302
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
301
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
1 #include "gui/translate/anilist.h"
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
2 #include <unordered_map>
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
3
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
4 namespace Translate {
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
5 namespace AniList {
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
6
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
7 Anime::SeriesStatus ToSeriesStatus(const std::string& status) {
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
8 static const std::unordered_map<std::string, Anime::SeriesStatus> map = {
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
9 {"FINISHED", Anime::SeriesStatus::Finished },
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
10 {"RELEASING", Anime::SeriesStatus::Releasing },
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
11 {"NOT_YET_RELEASED", Anime::SeriesStatus::NotYetReleased},
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
12 {"CANCELLED", Anime::SeriesStatus::Cancelled },
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
13 {"HIATUS", Anime::SeriesStatus::Hiatus }
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
14 };
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
15
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
16 if (map.find(status) == map.end())
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
17 return Anime::SeriesStatus::Unknown;
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
18 return map.at(status);
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
19 }
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
20
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
21 Anime::SeriesSeason ToSeriesSeason(const std::string& season) {
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
22 static const std::unordered_map<std::string, Anime::SeriesSeason> map = {
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
23 {"WINTER", Anime::SeriesSeason::Winter},
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
24 {"SPRING", Anime::SeriesSeason::Spring},
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
25 {"SUMMER", Anime::SeriesSeason::Summer},
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
26 {"FALL", Anime::SeriesSeason::Fall }
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
27 };
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
28
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
29 if (map.find(season) == map.end())
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
30 return Anime::SeriesSeason::Unknown;
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
31 return map.at(season);
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
32 }
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
33
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
34 Anime::SeriesFormat ToSeriesFormat(const std::string& format) {
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
35 static const std::unordered_map<std::string, enum Anime::SeriesFormat> map = {
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
36 {"TV", Anime::SeriesFormat::Tv },
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
37 {"TV_SHORT", Anime::SeriesFormat::TvShort},
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
38 {"MOVIE", Anime::SeriesFormat::Movie },
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
39 {"SPECIAL", Anime::SeriesFormat::Special },
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
40 {"OVA", Anime::SeriesFormat::Ova },
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
41 {"ONA", Anime::SeriesFormat::Ona },
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
42 {"MUSIC", Anime::SeriesFormat::Music }
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
43 };
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
44
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
45 if (map.find(format) == map.end())
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
46 return Anime::SeriesFormat::Unknown;
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
47 return map.at(format);
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
48 }
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
49
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
50 } // namespace AniList
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
51 } // namespace Translate