view src/services/services.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 948955c3ba81
children
line wrap: on
line source

#include "services/services.h"
#include "core/session.h"
#include "core/strings.h"
#include "gui/translate/anime.h"
#include "services/anilist.h"
#include "services/kitsu.h"

#include <fmt/core.h>

namespace Services {

void Synchronize() {
	session.SetStatusBar(fmt::format(Strings::Translate("{}: Retrieving anime list..."), Translate::ToString(session.config.service)));

	switch (session.config.service) {
		case Anime::Service::AniList: AniList::GetAnimeList(); break;
		case Anime::Service::Kitsu: Kitsu::GetAnimeList(); break;
		default: break;
	}
}

bool RetrieveAnimeMetadata(int id) {
	switch (session.config.service) {
		case Anime::Service::Kitsu:	return Kitsu::RetrieveAnimeMetadata(id);
		default: return false;
	}
}

std::vector<int> Search(const std::string& search) {
	session.SetStatusBar(fmt::format(Strings::Translate("{}: Requesting search query..."), Translate::ToString(session.config.service)));

	switch (session.config.service) {
		case Anime::Service::AniList: return AniList::Search(search);
		case Anime::Service::Kitsu: return Kitsu::Search(search);
		default: return {};
	}
}

bool GetSeason(Anime::Season season) {
	session.SetStatusBar(fmt::format(Strings::Translate("{}: Retrieving anime season data..."), Translate::ToString(session.config.service)));

	switch (session.config.service) {
		case Anime::Service::AniList: return AniList::GetSeason(season);
		case Anime::Service::Kitsu: return Kitsu::GetSeason(season);
		default: return {};
	}
}

void UpdateAnimeEntry(int id) {
	session.SetStatusBar(fmt::format(Strings::Translate("{}: Updating remote anime entry..."), Translate::ToString(session.config.service)));

	switch (session.config.service) {
		case Anime::Service::AniList: AniList::UpdateAnimeEntry(id); break;
		case Anime::Service::Kitsu: Kitsu::UpdateAnimeEntry(id); break;
		default: break;
	}
}

}; // namespace Services