comparison src/services/anilist.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
comparison
equal deleted inserted replaced
326:10096c5489e3 327:b5d6c27c308f
355 ret.push_back(ParseMediaJson(media.value())); 355 ret.push_back(ParseMediaJson(media.value()));
356 356
357 return ret; 357 return ret;
358 } 358 }
359 359
360 bool GetSeason(Anime::SeriesSeason season, Date::Year year) { 360 bool GetSeason(Anime::Season season) {
361 static constexpr std::string_view query = 361 static constexpr std::string_view query =
362 "query ($season: MediaSeason!, $season_year: Int!, $page: Int) {\n" 362 "query ($season: MediaSeason!, $season_year: Int!, $page: Int) {\n"
363 " Page(page: $page) {\n" 363 " Page(page: $page) {\n"
364 " media(season: $season, seasonYear: $season_year, type: ANIME, sort: START_DATE) {\n" 364 " media(season: $season, seasonYear: $season_year, type: ANIME, sort: START_DATE) {\n"
365 MEDIA_FIELDS 365 MEDIA_FIELDS
379 379
380 while (has_next_page) { 380 while (has_next_page) {
381 nlohmann::json json = { 381 nlohmann::json json = {
382 {"query", query}, 382 {"query", query},
383 {"variables", { 383 {"variables", {
384 {"season", Translate::AniList::ToString(season)}, 384 {"season", Translate::AniList::ToString(season.season)},
385 {"season_year", Strings::ToUtf8String(year)}, 385 {"season_year", Strings::ToUtf8String(season.year)},
386 {"page", page}, 386 {"page", page},
387 }}, 387 }},
388 }; 388 };
389 389
390 const std::optional<nlohmann::json> res = SendJSONRequest(json); 390 const std::optional<nlohmann::json> res = SendJSONRequest(json);