diff src/gui/translate/anime.cc @ 175:9b10175be389

dep/json: update to v3.11.3 anime/db: save anime list to database, very much untested and likely won't work as intended
author Paper <mrpapersonic@gmail.com>
date Thu, 30 Nov 2023 13:52:26 -0500
parents f88eda79c60a
children 62e336597bb7
line wrap: on
line diff
--- a/src/gui/translate/anime.cc	Wed Nov 29 13:53:56 2023 -0500
+++ b/src/gui/translate/anime.cc	Thu Nov 30 13:52:26 2023 -0500
@@ -50,31 +50,48 @@
 		case Anime::SeriesStatus::CANCELLED: return "Cancelled";
 		case Anime::SeriesStatus::HIATUS: return "On hiatus";
 		default:
-		case Anime::SeriesStatus::UNKNOWN: "Unknown";
+		case Anime::SeriesStatus::UNKNOWN: return "Unknown";
+	}
+}
+
+std::string ToString(const Anime::Services service) {
+	switch (service) {
+		case Anime::Services::ANILIST: return "AniList";
+		default:
+		case Anime::Services::NONE:    return "None";
 	}
 }
 
-Anime::SeriesStatus ToListStatus(const std::string& str) {
-	const std::unordered_map<std::string, Anime::SeriesStatus> map = {
-	    {"Currently watching", Anime::SeriesSeason::CURRENT},
-	    {"Plan to watch", Anime::SeriesSeason::PLANNING},
-	    {"Completed", Anime::SeriesSeason::COMPLETED},
-	    {"Dropped", Anime::SeriesSeason::DROPPED},
-	    {"On hold", Anime::SeriesSeason::PAUSED}
+std::string ToString(const Anime::TitleLanguage language) {
+	switch (language) {
+		case Anime::TitleLanguage::NATIVE:  return "Native";
+		case Anime::TitleLanguage::ENGLISH: return "English";
+		default:
+		case Anime::TitleLanguage::ROMAJI:  return "Romaji";
+	}
+}
+
+Anime::ListStatus ToListStatus(const std::string& str) {
+	const std::unordered_map<std::string, Anime::ListStatus> map = {
+	    {"Currently watching", Anime::ListStatus::CURRENT},
+	    {"Plan to watch", Anime::ListStatus::PLANNING},
+	    {"Completed", Anime::ListStatus::COMPLETED},
+	    {"Dropped", Anime::ListStatus::DROPPED},
+	    {"On hold", Anime::ListStatus::PAUSED}
 	};
 
 	if (map.find(str) == map.end())
-		return Anime::SeriesStatus::NOT_IN_LIST;
+		return Anime::ListStatus::NOT_IN_LIST;
 	return map.at(str);
 }
 
 Anime::SeriesStatus ToSeriesStatus(const std::string& str) {
 	const std::unordered_map<std::string, Anime::SeriesStatus> map = {
-	    {"Currently airing", Anime::SeriesSeason::RELEASING},
-	    {"Finished airing", Anime::SeriesSeason::FINISHED},
-	    {"Not yet aired", Anime::SeriesSeason::NOT_YET_RELEASED},
-	    {"Cancelled", Anime::SeriesSeason::CANCELLED},
-	    {"On hiatus", Anime::SeriesSeason::HIATUS}
+	    {"Currently airing", Anime::SeriesStatus::RELEASING},
+	    {"Finished airing", Anime::SeriesStatus::FINISHED},
+	    {"Not yet aired", Anime::SeriesStatus::NOT_YET_RELEASED},
+	    {"Cancelled", Anime::SeriesStatus::CANCELLED},
+	    {"On hiatus", Anime::SeriesStatus::HIATUS}
 	};
 
 	if (map.find(str) == map.end())
@@ -95,6 +112,22 @@
 	return map.at(str);
 }
 
+Anime::SeriesFormat ToSeriesFormat(const std::string& str) {
+	const std::unordered_map<std::string, Anime::SeriesFormat> map = {
+	    {"TV", Anime::SeriesFormat::TV},
+	    {"TV short", Anime::SeriesFormat::TV_SHORT},
+	    {"OVA", Anime::SeriesFormat::OVA},
+	    {"Movie", Anime::SeriesFormat::MOVIE},
+	    {"Special", Anime::SeriesFormat::SPECIAL},
+	    {"ONA", Anime::SeriesFormat::ONA},
+	    {"Music", Anime::SeriesFormat::MUSIC}
+	};
+
+	if (map.find(str) == map.end())
+		return Anime::SeriesFormat::UNKNOWN;
+	return map.at(str);
+}
+
 Anime::Services ToService(const std::string& str) {
 	const std::unordered_map<std::string, Anime::Services> map = {
 	    {"AniList", Anime::Services::ANILIST}