Mercurial > minori
annotate src/gui/translate/anilist.cc @ 337:a7d4e5107531
dep/animone: REFACTOR ALL THE THINGS
1: animone now has its own syntax divergent from anisthesia,
making different platforms actually have their own sections
2: process names in animone are now called `comm' (this will
probably break things). this is what its called in bsd/linux
so I'm just going to use it everywhere
3: the X11 code now checks for the existence of a UTF-8 window title
and passes it if available
4: ANYTHING THATS NOT LINUX IS 100% UNTESTED AND CAN AND WILL BREAK!
I still actually need to test the bsd code. to be honest I'm probably
going to move all of the bsds into separate files because they're
all essentially different operating systems at this point
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Wed, 19 Jun 2024 12:51:15 -0400 |
parents | b5d6c27c308f |
children |
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 |