Skip to content

Commit

Permalink
Add missing api fields
Browse files Browse the repository at this point in the history
  • Loading branch information
bytedream committed Jul 11, 2024
1 parent f97d895 commit 393a69c
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/feed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ pub struct SeriesFeed {
pub ids: Vec<String>,
}

/// A feed containing a id to a series or episode, depending on what you've watched in the past.
/// A feed containing an id to a series or episode, depending on what you've watched in the past.
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct SimilarFeed {
pub title: String,
Expand All @@ -91,6 +91,15 @@ pub struct SimilarFeed {
pub similar_id: String,
}

/// A feed containing information about a game with a link to it.
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct GameFeed {
pub title: String,
pub description: String,
pub images: FeedBannerImages,
pub link: String,
}

/// Items which can be shown on the home feed.
#[derive(Clone, Debug, Serialize, Request)]
pub enum HomeFeed {
Expand Down Expand Up @@ -127,6 +136,7 @@ pub enum HomeFeed {
/// Results similar to a series. Get the series struct via [`SimilarFeed::similar_id`] and call
/// [`Series::similar`] to get similar series.
SimilarTo(SimilarFeed),
Game(GameFeed),
/// Crunchyroll may update their feed / add new items. This field catches everything which is
/// unknown / not implemented in the library.
Unknown(serde_json::Map<String, serde_json::Value>),
Expand Down Expand Up @@ -273,6 +283,12 @@ impl<'de> Deserialize<'de> for HomeFeed {
_ => Ok(HomeFeed::Unknown(as_map)),
}
}
"game" => Ok(Self::Game(
serde_json::from_value(
get_value("game").map_err(|_| type_error("game", "object"))?,
)
.map_err(map_serde_error)?,
)),
#[cfg(feature = "__test_strict")]
_ => Err(Error::custom(format!(
"cannot parse home feed resource type '{}' ({})",
Expand Down
4 changes: 4 additions & 0 deletions src/media/anime/movie_listing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ pub struct MovieListing {

pub images: PosterImages,

/// Descriptors about the movie listing content, e.g. 'Violence' or 'Sexualized Imagery'.
#[serde(default)]
pub content_descriptors: Vec<String>,

#[serde(default)]
pub keywords: Vec<String>,
#[serde(default)]
Expand Down
22 changes: 22 additions & 0 deletions src/media/anime/season.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,29 @@ use crate::media::anime::util::{fix_empty_episode_versions, fix_empty_season_ver
use crate::media::util::request_media;
use crate::media::Media;
use crate::{Crunchyroll, Episode, Locale, Result, Series};
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use std::sync::Arc;

#[derive(Clone, Debug, Deserialize, Serialize, smart_default::SmartDefault)]
#[cfg_attr(feature = "__test_strict", serde(deny_unknown_fields))]
#[cfg_attr(not(feature = "__test_strict"), serde(default))]
pub struct SeasonVersionRestrictionWindow {
pub audio_locale: Locale,

#[default(DateTime::<Utc>::from(std::time::SystemTime::UNIX_EPOCH))]
pub watch_start: DateTime<Utc>,
#[default(DateTime::<Utc>::from(std::time::SystemTime::UNIX_EPOCH))]
pub watch_end: DateTime<Utc>,
#[default(DateTime::<Utc>::from(std::time::SystemTime::UNIX_EPOCH))]
pub list_start: DateTime<Utc>,
#[default(DateTime::<Utc>::from(std::time::SystemTime::UNIX_EPOCH))]
pub list_end: DateTime<Utc>,

pub level: Vec<String>,
pub geo: Vec<String>,
}

#[derive(Clone, Debug, Default, Deserialize, Serialize, Request)]
#[cfg_attr(feature = "__test_strict", serde(deny_unknown_fields))]
#[cfg_attr(not(feature = "__test_strict"), serde(default))]
Expand All @@ -20,6 +40,8 @@ pub struct SeasonVersion {
pub audio_locale: Locale,

pub original: bool,
#[serde(default)]
pub restriction_windows: Vec<SeasonVersionRestrictionWindow>,

#[cfg(feature = "__test_strict")]
pub(crate) variant: crate::StrictValue,
Expand Down
1 change: 1 addition & 0 deletions src/media/anime/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ pub(crate) fn fix_empty_season_versions(season: &mut Season) {
.unwrap_or(&Locale::ja_JP)
.clone(),
original: true,
restriction_windows: vec![],
#[cfg(feature = "__test_strict")]
variant: StrictValue::default(),
})
Expand Down

0 comments on commit 393a69c

Please sign in to comment.