diff --git a/Cargo.lock b/Cargo.lock index 4ab978d..750aa9d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1486,7 +1486,7 @@ dependencies = [ [[package]] name = "ramdl" -version = "1.0.2" +version = "1.0.3" dependencies = [ "base64", "fancy-regex", diff --git a/Cargo.toml b/Cargo.toml index bd8a7b2..2c0e996 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ramdl" -version = "1.0.2" +version = "1.0.3" edition = "2021" license = "GPL-3.0-or-later" description = "A Rust library for downloading Apple Music songs/music videos/posts" diff --git a/src/api/albums.rs b/src/api/albums.rs new file mode 100644 index 0000000..2a14e84 --- /dev/null +++ b/src/api/albums.rs @@ -0,0 +1,141 @@ +use super::artwork::Artwork; +use super::editorial_notes::EditorialNotes; +use super::play_parameters::PlayParameters; + +#[derive(serde::Serialize, serde::Deserialize, Debug, Clone)] +#[serde(rename_all = "camelCase")] +pub struct Albums { + /// The identifier for the album. + pub id: String, + /// This value is always albums. + #[serde(rename = "type")] + pub type_: String, + /// The relative location for the album resource. + pub href: String, + /// The attributes for the album. + pub attributes: Option, + /// The relationships for the album. + pub relationships: Option, +} + +#[derive(serde::Serialize, serde::Deserialize, Debug, Clone)] +#[serde(rename_all = "camelCase")] +pub struct Attributes { + /// The name of the primary artist associated with the album. + pub artist_name: String, + /// The URL of the artist for this content. + pub artist_url: Option, + /// The artwork for the album. + pub artwork: Artwork, + /// Indicates the specific audio variant for the album. + pub audio_variants: Option>, + /// The Recording Industry Association of America (RIAA) rating of the content. + pub content_rating: Option, + /// The copyright text. + pub copyright: Option, + /// The notes about the album that appear in the iTunes Store. + pub editorial_notes: Option, + /// The names of the genres associated with the album. + pub genre_names: Vec, + /// Indicates whether the album is marked as a compilation. + pub is_compilation: bool, + /// Indicates whether the album is complete. + pub is_complete: bool, + /// Indicates whether the response delivered the album as an Apple Digital Master. + pub is_mastered_for_itunes: bool, + /// Indicates whether the album contains a single song. + pub is_single: bool, + /// The localized name of the album. + pub name: String, + /// Indicates that one or more tracks on the album are available to play with an Apple Music subscription. + pub play_params: Option, + /// The name of the record label for the album. + pub record_label: Option, + /// The release date of the album, when known. + pub release_date: Option, + /// The number of tracks for the album. + pub track_count: i32, + /// The Universal Product Code for the album. + pub upc: Option, + /// The URL for sharing the album in Apple Music. + pub url: String, +} + +#[derive(serde::Serialize, serde::Deserialize, Debug, Clone)] +#[serde(rename_all = "camelCase")] +pub struct Relationships { + // /// The artists associated with the album. By default, artists includes identifiers only. + // pub artists: Option, + // /// The genres for the album. By default, genres not included. + // pub genres: Option, + // /// The songs and music videos on the album. By default, tracks includes objects. + // pub tracks: Option, + // /// The album in the user’s library for the catalog album, if any. + // pub library: Option, + // /// The record labels for the album. + // pub record_labels: Option, +} + +// #[derive(serde::Serialize, serde::Deserialize, Debug, Clone)] +// #[serde(rename_all = "camelCase")] +// pub struct AlbumsArtistsRelationship { +// /// The relative location to fetch the relationship directly. +// pub href: String, +// /// The relative location to request the next page of resources in the collection, if additional resources are available for fetching. +// pub next: Option, +// /// The artists for the album. +// pub data: Vec, +// } + +// #[derive(serde::Serialize, serde::Deserialize, Debug, Clone)] +// #[serde(rename_all = "camelCase")] +// pub struct AlbumsGenresRelationship { +// /// The relative location to fetch the relationship directly. +// pub href: String, +// /// The relative location to request the next page of resources in the collection, if additional resources are available for fetching. +// pub next: Option, +// /// The album’s associated genre. +// pub data: Vec, +// } + +// #[derive(serde::Serialize, serde::Deserialize, Debug, Clone)] +// #[serde(rename_all = "camelCase")] +// pub struct AlbumsTracksRelationship { +// /// The relative location to fetch the relationship directly. +// pub href: String, +// /// The relative location to request the next page of resources in the collection, if additional resources are available for fetching. +// pub next: Option, +// /// The tracks for the album. +// pub data: Vec, +// } + +// #[derive(serde::Serialize, serde::Deserialize, Debug, Clone)] +// #[serde(rename_all = "camelCase")] +// pub enum TrackData { +// #[serde(rename = "songs")] +// Songs(Songs), +// #[serde(rename = "music-videos")] +// MusicVideos(MusicVideos), +// } + +// #[derive(serde::Serialize, serde::Deserialize, Debug, Clone)] +// #[serde(rename_all = "camelCase")] +// pub struct AlbumsLibraryRelationship { +// /// The relative location to fetch the relationship directly. +// pub href: String, +// /// The relative location to request the next page of resources in the collection, if additional resources are available for fetching. +// pub next: Option, +// /// The library content this album is associated with if added to the user’s library. +// pub data: Vec, +// } + +// #[derive(serde::Serialize, serde::Deserialize, Debug, Clone)] +// #[serde(rename_all = "camelCase")] +// pub struct AlbumsRecordLabelsRelationship { +// /// The relative location to fetch the relationship directly. +// pub href: String, +// /// The relative location to request the next page of resources in the collection, if additional resources are available for fetching. +// pub next: Option, +// /// The album’s associated record label. +// pub data: Vec, +// } diff --git a/src/api/artists.rs b/src/api/artists.rs new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/src/api/artists.rs @@ -0,0 +1 @@ + diff --git a/src/api/artwork.rs b/src/api/artwork.rs new file mode 100644 index 0000000..5ad35ce --- /dev/null +++ b/src/api/artwork.rs @@ -0,0 +1,21 @@ +#[derive(serde::Serialize, serde::Deserialize, Debug, Clone)] +#[serde(rename_all = "camelCase")] +pub struct Artwork { + /// The average background color of the image. + pub bg_color: Option, + /// The maximum height available for the image. + pub height: i32, + /// The maximum width available for the image. + pub width: i32, + /// The primary text color used if the background color gets displayed. + pub text_color1: String, + /// The secondary text color used if the background color gets displayed. + pub text_color2: String, + /// The tertiary text color used if the background color gets displayed. + pub text_color3: String, + /// The final post-tertiary text color used if the background color gets displayed. + pub text_color4: String, + /// The URL to request the image asset. {w}x{h}must precede image filename, as placeholders for the width and height values as described above. For example, {w}x{h}bb.jpeg). + pub url: String, + pub has_p3: Option, +} diff --git a/src/api/editorial_notes.rs b/src/api/editorial_notes.rs new file mode 100644 index 0000000..e326f22 --- /dev/null +++ b/src/api/editorial_notes.rs @@ -0,0 +1,11 @@ +#[derive(serde::Serialize, serde::Deserialize, Debug, Clone)] +pub struct EditorialNotes { + /// Abbreviated notes shown inline or when the content appears alongside other content. + pub short: Option, + /// Notes shown when the content is prominently displayed. + pub standard: Option, + /// Name for the editorial notes. + pub name: Option, + /// The tag line for the editorial notes. + pub tagline: Option, +} diff --git a/src/api/genres.rs b/src/api/genres.rs new file mode 100644 index 0000000..dfa2dfa --- /dev/null +++ b/src/api/genres.rs @@ -0,0 +1,26 @@ +#[derive(serde::Serialize, serde::Deserialize, Debug, Clone)] +#[serde(rename_all = "camelCase")] +pub struct Genre { + /// The identifier for the genre. + pub id: String, + /// This value must always be genres. + #[serde(rename = "type")] + pub type_field: String, + /// The relative location for the genre resource. + pub href: String, + /// The attributes for the genre. + pub attributes: Attributes, +} + +#[derive(serde::Serialize, serde::Deserialize, Debug, Clone)] +#[serde(rename_all = "camelCase")] +pub struct Attributes { + /// The localized name of the genre. + pub name: String, + /// The identifier of the parent for the genre. + pub parent_id: Option, + /// The localized name of the parent genre. + pub parent_name: Option, + /// A localized string to use when displaying the genre in relation to charts. + pub chart_label: Option, +} diff --git a/src/api/library_albums.rs b/src/api/library_albums.rs new file mode 100644 index 0000000..860e461 --- /dev/null +++ b/src/api/library_albums.rs @@ -0,0 +1,99 @@ +use super::albums::Albums; +use super::artwork::Artwork; +use super::play_parameters::PlayParameters; +#[derive(serde::Serialize, serde::Deserialize, Debug, Clone)] +#[serde(rename_all = "camelCase")] +pub struct LibraryAlbums { + /// The identifier for the library album. + pub id: String, + /// This value is always library-albums. + #[serde(rename = "type")] + pub type_: String, + /// The relative location for the library album resource. + pub href: String, + /// The attributes for the library album. + pub attributes: Option, + /// The relationships for the library album. + pub relationships: Option, +} + +#[derive(serde::Serialize, serde::Deserialize, Debug, Clone)] +#[serde(rename_all = "camelCase")] +pub struct Attributes { + /// The artist’s name. + pub artist_name: String, + /// The album artwork. + pub artwork: Artwork, + /// The Recording Industry Association of America (RIAA) rating of the content. + /// The possible values for this rating are clean and explicit. No value means no rating. + pub content_rating: Option, + /// The date the album was added to the library, in YYYY-MM-DD or YYYY format. + pub date_added: Option, + /// The localized name of the album. + pub name: String, + /// When present, this attribute indicates that tracks from the album are available to play. + /// The value map may be used to initiate playback of available tracks on the album. + pub play_params: Option, + /// The release date of the album, when known, in YYYY-MM-DD or YYYY format. + /// Pre-release albums may have an expected release date in the future. + pub release_date: Option, + /// The number of tracks. + pub track_count: i32, + /// The names of the genres associated with this album. + pub genre_names: Vec, +} + +#[derive(serde::Serialize, serde::Deserialize, Debug, Clone)] +#[serde(rename_all = "camelCase")] +pub struct Relationships { + // /// The library artists associated with the album. By default, artists not included. + // /// Fetch limits: 10 default, 10 maximum + // pub artists: Option, + // /// The album in the Apple Music catalog the library album is associated with, when known. + // /// Fetch limits: None (associated with at most one catalog album) + // pub catalog: Option, + // /// The library songs and library music videos on the album. Only available when fetching single library album resource by ID. By default, tracks includes objects. + // /// Fetch limits: 300 default, 300 maximum. + // pub tracks: Option, +} + +// #[derive(serde::Serialize, serde::Deserialize, Debug, Clone)] +// #[serde(rename_all = "camelCase")] +// pub struct LibraryAlbumsArtistsRelationship { +// /// The relative location to fetch the relationship directly. +// pub href: String, +// /// The relative location to request the next page of resources in the collection, if additional resources are available for fetching. +// pub next: Option, +// /// The library artists for the library album. +// pub data: Vec, +// } + +#[derive(serde::Serialize, serde::Deserialize, Debug, Clone)] +#[serde(rename_all = "camelCase")] +pub struct LibraryAlbumsCatalogRelationship { + /// The relative location to fetch the relationship directly. + pub href: String, + /// The relative location to request the next page of resources in the collection, if additional resources are available for fetching. + pub next: Option, + /// The album from the Apple Music catalog associated with the library album, if any. + pub data: Vec, +} + +// #[derive(serde::Serialize, serde::Deserialize, Debug, Clone)] +// #[serde(rename_all = "camelCase")] +// pub struct LibraryAlbumsTracksRelationship { +// /// The relative location to fetch the relationship directly. +// pub href: String, +// /// The relative location to request the next page of resources in the collection, if additional resources are available for fetching. +// pub next: Option, +// /// The songs and music videos from the library album’s tracklist added to the user’s library. +// pub data: Vec, +// } + +// #[derive(serde::Serialize, serde::Deserialize, Debug, Clone)] +// #[serde(rename_all = "camelCase")] +// #[serde(tag = "type")] +// pub enum LibraryTracks { +// LibraryMusicVideos(LibraryMusicVideos), +// LibrarySongs(LibrarySongs), +// } diff --git a/src/api/mod.rs b/src/api/mod.rs index f74b548..a30a743 100644 --- a/src/api/mod.rs +++ b/src/api/mod.rs @@ -1,10 +1,32 @@ //! the API struct of Apple Music. +/// A resource object that represents an album. +pub mod albums; +/// A resource object that represents the artist of an album where an artist can be one or more people. +pub mod artists; +/// An object that represents artwork. +pub mod artwork; +/// An object that represents a notes attribute. +/// ## Discussion +/// Notes may include XML tags for formatting (<b> for bold, <i> for italic, or <br> for line break) and special characters (&amp; for &, &lt; for <, &gt; for >, &apos; for ‘, and &quot; for “). +pub mod editorial_notes; +/// A resource object that represents a music genre. +pub mod genres; +/// A resource object that represents a library album. +pub mod library_albums; /// /v1/catalog/:store_front/songs/:song_id?include=lyrics,syllable-lyrics pub mod lyrics; +/// /v1/catalog/:store_front/music-videos/:id +pub mod music_videos; +/// An object that represents play parameters for resources. +pub mod play_parameters; +/// /v1/catalog/:store_front/playlists/:id +pub mod playlists; +/// An object that represents a preview for resources. +pub mod previews; /// /v1/catalog/:store_front/search pub mod search; -/// /v1/catalog/:store_front/songs/:song_id?include=albums +/// /v1/catalog/:store_front/songs/:id?include=albums pub mod songs; /// WEBPLAYBACK_API_URL pub mod webplayback; diff --git a/src/api/music_videos.rs b/src/api/music_videos.rs new file mode 100644 index 0000000..eb46f92 --- /dev/null +++ b/src/api/music_videos.rs @@ -0,0 +1,95 @@ +use super::artwork::Artwork; +use super::editorial_notes::EditorialNotes; +use super::play_parameters::PlayParameters; +use super::previews::Preview; + +#[derive(serde::Serialize, serde::Deserialize, Debug, Clone)] +#[serde(rename_all = "camelCase")] +pub struct MusicVideos { + /// The identifier for the music video. + pub id: String, + /// This value is always music-videos. + pub type_: String, + /// The relative location for the music video resource. + pub href: String, + /// The attributes for the music video. + pub attributes: Attributes, + /// The relationships for the music video. + pub relationships: Option, +} + +#[derive(serde::Serialize, serde::Deserialize, Debug, Clone)] +#[serde(rename_all = "camelCase")] +pub struct Attributes { + /// The name of the album the music video appears on. + pub album_name: Option, + /// The artist’s name. + pub artist_name: String, + /// (Extended) The URL of the artist for this content. + pub artist_url: Option, + /// The artwork for the music video’s associated album. + pub artwork: Artwork, + /// The Recording Industry Association of America (RIAA) rating of the content. No value means no rating. + /// Possible Values: clean, explicit + pub content_rating: Option, + /// The duration of the music video in milliseconds. + pub duration_in_millis: i64, + /// The editorial notes for the music video. + pub editorial_notes: Option, + /// The music video’s associated genres. + pub genre_names: Vec, + /// Whether the music video has 4K content. + pub has_4k: bool, + /// Whether the music video has HDR10-encoded content. + pub has_hdr: bool, + /// The International Standard Recording Code (ISRC) for the music video. + pub isrc: Option, + /// The localized name of the music video. + pub name: String, + /// When present, this attribute indicates that the music video is available to play with an Apple Music subscription. + /// The value map may be used to initiate playback. Previews of the music video may be available with or without an Apple Music subscription. + pub play_params: Option, + /// The preview assets for the music video. + pub previews: Vec, + /// The release date of the music video, when known, in YYYY-MM-DD or YYYY format. + /// Prerelease music videos may have an expected release date in the future. + pub release_date: Option, + /// The number of the music video in the album’s track list, when associated with an album. + pub track_number: Option, + /// (Required) The URL for sharing the music video in Apple Music. + pub url: String, + /// The video subtype associated with the content. + /// Value: preview + pub video_sub_type: Option, + /// (Classical music only) A unique identifier for the associated work. + pub work_id: Option, + /// (Classical music only) The name of the associated work. + pub work_name: Option, +} + +#[derive(serde::Serialize, serde::Deserialize, Debug, Clone)] +#[serde(rename_all = "camelCase")] +pub struct Relationships { + // /// The albums associated with the music video. By default, albums includes identifiers only. + // pub albums: Option, + // /// The artists associated with the music video. By default, artists includes identifiers only. + // pub artists: Option, + // /// The genres associated with the music video. By default, genres not included. + // pub genres: Option, + // /// The library of a music video if added to library. + // pub library: Option, + // /// The songs associated with the music video. + // pub songs: Option, +} + +// /// A relationship from the music video to its albums. +// #[derive(serde::Serialize, serde::Deserialize, Debug, Clone)] +// #[serde(rename_all = "camelCase")] +// pub struct MusicVideosAlbumsRelationship { +// /// A relative location for the relationship. +// pub href: Option, +// /// A relative cursor to fetch the next paginated collection of resources in the relationship if more exist. +// pub next: Option, +// /// The albums associated with the music video, if any. +// pub data: Vec, +// } diff --git a/src/api/play_parameters.rs b/src/api/play_parameters.rs new file mode 100644 index 0000000..b666d11 --- /dev/null +++ b/src/api/play_parameters.rs @@ -0,0 +1,8 @@ +#[derive(serde::Serialize, serde::Deserialize, Debug, Clone)] +#[serde(rename_all = "camelCase")] +pub struct PlayParameters { + /// The ID of the content to use for playback. + pub id: String, + /// The kind of the content to use for playback. + pub kind: String, +} diff --git a/src/api/playlists.rs b/src/api/playlists.rs new file mode 100644 index 0000000..42fd9e1 --- /dev/null +++ b/src/api/playlists.rs @@ -0,0 +1,102 @@ +use super::artwork::Artwork; +use super::music_videos::MusicVideos; +use super::play_parameters::PlayParameters; +use super::songs::Songs; + +#[derive(serde::Serialize, serde::Deserialize, Debug, Clone)] +pub struct Playlists { + /// The identifier for the playlist. + pub id: String, + /// This value is always playlists. + #[serde(rename = "type")] + pub type_: String, + /// The relative location for the playlist resource. + pub href: String, + /// The attributes for the playlist. + pub attributes: Attributes, + // /// The relationships for the playlist. + pub relationships: Relationships, +} + +#[derive(serde::Serialize, serde::Deserialize, Debug, Clone)] +#[serde(rename_all = "camelCase")] +pub struct Attributes { + /// The playlist artwork. + pub artwork: Option, + /// The display name of the curator. + pub curator_name: String, + /// A description of the playlist. + pub description: Option, + /// Indicates whether the playlist represents a popularity chart. + pub is_chart: bool, + /// The date the playlist was last modified. + pub last_modified_date: String, + /// The localized name of the playlist. + pub name: String, + /// The type of playlist. Possible values are: + /// + /// Editorial: A playlist created by an Apple Music curator. + /// + /// External: A playlist created by a non-Apple curator or brand. + /// + /// Personal-mix: A personalized playlist for an Apple Music user. + /// + /// Replay: A personalized Apple Music Replay playlist for an Apple Music user. + /// + /// User-shared: A playlist created and shared by an Apple Music user. + pub playlist_type: String, + /// The value map may be used to initiate playback of available tracks in the playlist. + pub play_params: PlayParameters, + /// The URL for sharing the playlist in Apple Music. + pub url: String, + /// (Extended) The resource types that are present in the tracks of the playlists. + /// Possible Values: music-videos, songs + pub track_types: Vec, +} + +#[derive(serde::Serialize, serde::Deserialize, Debug, Clone)] +pub struct DescriptionAttribute { + /// An abbreviated description to show inline or when the content appears alongside other content. + pub short: String, + /// A description to show when the content is prominently displayed. + pub standard: String, +} + +#[derive(serde::Serialize, serde::Deserialize, Debug, Clone)] +#[serde(rename_all = "camelCase")] +pub struct Relationships { + /// The songs and music videos included in the playlist. By default, tracks includes objects + pub tracks: Option, + // /// The curator that created the playlist. By default, curator includes identifiers only. + // pub curator: Option, +} + +#[derive(serde::Serialize, serde::Deserialize, Debug, Clone)] +#[serde(rename_all = "camelCase")] +pub struct Tracks { + /// A relative location for the relationship. + pub href: Option, + /// A relative cursor to fetch the next paginated collection of resources in the relationship if more exist. + pub next: Option, + /// The data for the included tracks. + pub data: Vec, +} + +#[derive(serde::Serialize, serde::Deserialize, Debug, Clone)] +#[serde(tag = "type")] +pub enum TrackData { + #[serde(rename = "songs")] + Songs(Songs), + #[serde(rename = "music-videos")] + MusicVideos(MusicVideos), +} + +// #[derive(serde::Serialize, serde::Deserialize, Debug, Clone)] +// pub struct Curator { +// /// A relative location for the relationship. +// pub href: Option, +// /// A relative cursor to fetch the next paginated collection of resources in the relationship if more exist. +// pub next: Option, +// /// The curator for the playlist. +// pub data: Vec, +// } diff --git a/src/api/previews.rs b/src/api/previews.rs new file mode 100644 index 0000000..d79ee53 --- /dev/null +++ b/src/api/previews.rs @@ -0,0 +1,12 @@ +use super::artwork::Artwork; + +#[derive(serde::Serialize, serde::Deserialize, Debug, Clone)] +#[serde(rename_all = "camelCase")] +pub struct Preview { + /// The preview artwork for the associated preview music video. + pub artwork: Option, + /// The preview URL for the content. + pub url: String, + /// The HLS preview URL for the content. + pub hls_url: Option, +} diff --git a/src/api/songs.rs b/src/api/songs.rs index ea16cc2..01c35d4 100644 --- a/src/api/songs.rs +++ b/src/api/songs.rs @@ -1,6 +1,11 @@ +use super::artwork::Artwork; +use super::editorial_notes::EditorialNotes; +use super::play_parameters::PlayParameters; +use super::previews::Preview; + #[derive(serde::Serialize, serde::Deserialize, Debug, Clone)] #[serde(rename_all = "camelCase")] -pub struct Song { +pub struct Songs { /// The identifier for the song. pub id: String, /// This value is always songs. @@ -16,20 +21,6 @@ pub struct Song { pub meta: Option, } -#[derive(serde::Serialize, serde::Deserialize, Debug, Clone)] -#[serde(rename_all = "camelCase")] -pub struct Artwork { - pub width: u32, - pub url: String, - pub height: u32, - pub text_color3: String, - pub text_color2: String, - pub text_color4: String, - pub text_color1: String, - pub bg_color: String, - pub has_p3: bool, -} - #[derive(serde::Serialize, serde::Deserialize, Debug, Clone)] #[serde(rename_all = "camelCase")] pub struct Attributes { @@ -75,7 +66,7 @@ pub struct Attributes { /// The localized name of the song. pub name: String, /// When present, this attribute indicates that the song is available to play with an Apple Music subscription. The value map may be used to initiate playback. Previews of the song audio may be available with or without an Apple Music subscription. - pub play_params: Option, + pub play_params: Option, /// The preview assets for the song. pub previews: Vec, /// The release date of the song, when known, in YYYY-MM-DD or YYYY format. Prerelease songs may have an expected release date in the future. @@ -95,37 +86,6 @@ pub struct Attributes { pub extended_asset_urls: Option, } -/// An object that represents a notes attribute. -/// ## Discussion -/// Notes may include XML tags for formatting (<b> for bold, <i> for italic, or <br> for line break) and special characters (&amp; for &, &lt; for <, &gt; for >, &apos; for ‘, and &quot; for “). -#[derive(serde::Serialize, serde::Deserialize, Debug, Clone)] -pub struct EditorialNotes { - /// Abbreviated notes shown inline or when the content appears alongside other content. - pub short: Option, - /// Notes shown when the content is prominently displayed. - pub standard: Option, - /// Name for the editorial notes. - pub name: Option, - /// The tag line for the editorial notes. - pub tagline: Option, -} - -#[derive(serde::Serialize, serde::Deserialize, Debug, Clone)] -pub struct PlayParams { - /// The ID of the content to use for playback. - pub id: String, - /// The kind of the content to use for playback. - pub kind: String, -} - -#[derive(serde::Serialize, serde::Deserialize, Debug, Clone)] -#[serde(rename_all = "camelCase")] -pub struct Preview { - pub artwork: Option, - pub url: String, - pub hls_url: Option, -} - #[derive(serde::Serialize, serde::Deserialize, Debug, Clone)] #[serde(rename_all = "camelCase")] pub struct ExtendedAssetUrls { diff --git a/src/lib.rs b/src/lib.rs index e98ba45..b060838 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -14,7 +14,7 @@ use serde_json::json; use lyrics::Lyrics; use search; -use songs::Song; +use songs::Songs; use stream_info::StreamInfo; /// @@ -176,7 +176,7 @@ impl AppleMusicDownloader { } /// Gets the song information. - pub async fn get_songs(&self, song_id: &str) -> Result { + pub async fn get_songs(&self, song_id: &str) -> Result { let store_front = self.store_front.clone(); let res = self .client @@ -187,7 +187,7 @@ impl AppleMusicDownloader { .await? .json::() .await?; - let song: Song = serde_json::from_value(res["data"][0].clone())?; + let song: Songs = serde_json::from_value(res["data"][0].clone())?; Ok(song) }