annotate src/gui/translate/anilist.cc @ 342:adb79bdde329

dep/animone: fix tons of issues for example, the window ID stuff was just... completely wrong. since we're supporting multiple different window systems, it *has* to be a union rather than just a single integer type. HWND is also not a DWORD, it's a pointer(!), so now it's stored as a std::uintptr_t. (this probably breaks things)
author Paper <paper@paper.us.eu.org>
date Thu, 20 Jun 2024 03:03:05 -0400
parents b5d6c27c308f
children
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
327
b5d6c27c308f anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
21 Anime::Season::Name ToSeriesSeason(const std::string& season) {
b5d6c27c308f anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
22 static const std::unordered_map<std::string, Anime::Season::Name> map = {
b5d6c27c308f anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
23 {"WINTER", Anime::Season::Name::Winter},
b5d6c27c308f anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
24 {"SPRING", Anime::Season::Name::Spring},
b5d6c27c308f anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
25 {"SUMMER", Anime::Season::Name::Summer},
b5d6c27c308f anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
26 {"FALL", Anime::Season::Name::Autumn}
301
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())
327
b5d6c27c308f anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
30 return Anime::Season::Name::Unknown;
301
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
327
b5d6c27c308f anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
50 std::string ToString(Anime::Season::Name season) {
304
2115488eb302 *: add very early season searcher
Paper <paper@paper.us.eu.org>
parents: 301
diff changeset
51 switch (season) {
2115488eb302 *: add very early season searcher
Paper <paper@paper.us.eu.org>
parents: 301
diff changeset
52 default:
327
b5d6c27c308f anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
53 case Anime::Season::Name::Winter: return "WINTER";
b5d6c27c308f anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
54 case Anime::Season::Name::Autumn: return "FALL";
b5d6c27c308f anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
55 case Anime::Season::Name::Summer: return "SUMMER";
b5d6c27c308f anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
56 case Anime::Season::Name::Spring: return "SPRING";
304
2115488eb302 *: add very early season searcher
Paper <paper@paper.us.eu.org>
parents: 301
diff changeset
57 }
2115488eb302 *: add very early season searcher
Paper <paper@paper.us.eu.org>
parents: 301
diff changeset
58 }
2115488eb302 *: add very early season searcher
Paper <paper@paper.us.eu.org>
parents: 301
diff changeset
59
301
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
60 } // namespace AniList
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
61 } // namespace Translate