annotate src/services/services.cc @ 327:b5d6c27c308f

anime: refactor Anime::SeriesSeason to Season class ToLocalString has also been altered to take in both season and year because lots of locales actually treat formatting seasons differently! most notably is Russian which adds a suffix at the end to notate seasons(??)
author Paper <paper@paper.us.eu.org>
date Thu, 13 Jun 2024 01:49:18 -0400
parents 78929794e7d8
children 948955c3ba81
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 10
diff changeset
1 #include "services/services.h"
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
2 #include "core/session.h"
320
1b5c04268d6a services/kitsu: ACTUALLY finish GetAnimeList
Paper <paper@paper.us.eu.org>
parents: 317
diff changeset
3 #include "gui/translate/anime.h"
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
4 #include "services/anilist.h"
317
b1f4d1867ab1 services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
5 #include "services/kitsu.h"
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
6
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
7 namespace Services {
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
8
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
9 void Synchronize() {
320
1b5c04268d6a services/kitsu: ACTUALLY finish GetAnimeList
Paper <paper@paper.us.eu.org>
parents: 317
diff changeset
10 session.SetStatusBar(Translate::ToString(session.config.service) + ": Retrieving anime list...");
1b5c04268d6a services/kitsu: ACTUALLY finish GetAnimeList
Paper <paper@paper.us.eu.org>
parents: 317
diff changeset
11
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
12 switch (session.config.service) {
279
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 250
diff changeset
13 case Anime::Service::AniList: AniList::GetAnimeList(); break;
317
b1f4d1867ab1 services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
14 case Anime::Service::Kitsu: Kitsu::GetAnimeList(); break;
112
80f49f623d30 locale: allow switching locales without restarting
Paper <mrpapersonic@gmail.com>
parents: 81
diff changeset
15 default: break;
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
16 }
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
17 }
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
18
320
1b5c04268d6a services/kitsu: ACTUALLY finish GetAnimeList
Paper <paper@paper.us.eu.org>
parents: 317
diff changeset
19 bool RetrieveAnimeMetadata(int id) {
1b5c04268d6a services/kitsu: ACTUALLY finish GetAnimeList
Paper <paper@paper.us.eu.org>
parents: 317
diff changeset
20 switch (session.config.service) {
1b5c04268d6a services/kitsu: ACTUALLY finish GetAnimeList
Paper <paper@paper.us.eu.org>
parents: 317
diff changeset
21 case Anime::Service::Kitsu: return Kitsu::RetrieveAnimeMetadata(id);
1b5c04268d6a services/kitsu: ACTUALLY finish GetAnimeList
Paper <paper@paper.us.eu.org>
parents: 317
diff changeset
22 default: return false;
1b5c04268d6a services/kitsu: ACTUALLY finish GetAnimeList
Paper <paper@paper.us.eu.org>
parents: 317
diff changeset
23 }
1b5c04268d6a services/kitsu: ACTUALLY finish GetAnimeList
Paper <paper@paper.us.eu.org>
parents: 317
diff changeset
24 }
1b5c04268d6a services/kitsu: ACTUALLY finish GetAnimeList
Paper <paper@paper.us.eu.org>
parents: 317
diff changeset
25
250
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 112
diff changeset
26 std::vector<int> Search(const std::string& search) {
320
1b5c04268d6a services/kitsu: ACTUALLY finish GetAnimeList
Paper <paper@paper.us.eu.org>
parents: 317
diff changeset
27 session.SetStatusBar(Translate::ToString(session.config.service) + ": Requesting search query...");
1b5c04268d6a services/kitsu: ACTUALLY finish GetAnimeList
Paper <paper@paper.us.eu.org>
parents: 317
diff changeset
28
250
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 112
diff changeset
29 switch (session.config.service) {
279
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 250
diff changeset
30 case Anime::Service::AniList: return AniList::Search(search);
317
b1f4d1867ab1 services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
31 case Anime::Service::Kitsu: return Kitsu::Search(search);
250
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 112
diff changeset
32 default: return {};
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 112
diff changeset
33 }
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 112
diff changeset
34 }
c130f47f6f48 *: many many changes
Paper <paper@paper.us.eu.org>
parents: 112
diff changeset
35
327
b5d6c27c308f anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents: 325
diff changeset
36 bool GetSeason(Anime::Season season) {
320
1b5c04268d6a services/kitsu: ACTUALLY finish GetAnimeList
Paper <paper@paper.us.eu.org>
parents: 317
diff changeset
37 session.SetStatusBar(Translate::ToString(session.config.service) + ": Retrieving anime season data...");
1b5c04268d6a services/kitsu: ACTUALLY finish GetAnimeList
Paper <paper@paper.us.eu.org>
parents: 317
diff changeset
38
304
2115488eb302 *: add very early season searcher
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
39 switch (session.config.service) {
327
b5d6c27c308f anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents: 325
diff changeset
40 case Anime::Service::AniList: return AniList::GetSeason(season);
b5d6c27c308f anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents: 325
diff changeset
41 case Anime::Service::Kitsu: return Kitsu::GetSeason(season);
304
2115488eb302 *: add very early season searcher
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
42 default: return {};
2115488eb302 *: add very early season searcher
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
43 }
2115488eb302 *: add very early season searcher
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
44 }
2115488eb302 *: add very early season searcher
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
45
52
0c4138de2ea7 anime list: we are finally read-write
Paper <mrpapersonic@gmail.com>
parents: 47
diff changeset
46 void UpdateAnimeEntry(int id) {
320
1b5c04268d6a services/kitsu: ACTUALLY finish GetAnimeList
Paper <paper@paper.us.eu.org>
parents: 317
diff changeset
47 session.SetStatusBar(Translate::ToString(session.config.service) + ": Updating remote anime entry...");
1b5c04268d6a services/kitsu: ACTUALLY finish GetAnimeList
Paper <paper@paper.us.eu.org>
parents: 317
diff changeset
48
52
0c4138de2ea7 anime list: we are finally read-write
Paper <mrpapersonic@gmail.com>
parents: 47
diff changeset
49 switch (session.config.service) {
279
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 250
diff changeset
50 case Anime::Service::AniList: AniList::UpdateAnimeEntry(id); break;
317
b1f4d1867ab1 services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents: 304
diff changeset
51 case Anime::Service::Kitsu: Kitsu::UpdateAnimeEntry(id); break;
52
0c4138de2ea7 anime list: we are finally read-write
Paper <mrpapersonic@gmail.com>
parents: 47
diff changeset
52 default: break;
0c4138de2ea7 anime list: we are finally read-write
Paper <mrpapersonic@gmail.com>
parents: 47
diff changeset
53 }
0c4138de2ea7 anime list: we are finally read-write
Paper <mrpapersonic@gmail.com>
parents: 47
diff changeset
54 }
0c4138de2ea7 anime list: we are finally read-write
Paper <mrpapersonic@gmail.com>
parents: 47
diff changeset
55
44
619cbd6e69f9 filesystem: fix CreateDirectories function
Paper <mrpapersonic@gmail.com>
parents: 15
diff changeset
56 }; // namespace Services