1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186
use chrono::NaiveDate; use super::Include; use crate::date_format; use crate::entity::alias::Alias; use crate::entity::genre::Genre; use crate::entity::label::LabelInfo; use crate::entity::recording::Recording; use crate::entity::release_group::ReleaseGroup; use crate::entity::tag::Tag; use crate::entity::BrowseBy; /// A MusicBrainz release represents the unique release (i.e. issuing) of a product on a specific /// date with specific release information such as the country, label, barcode and packaging. /// If you walk into a store and purchase an album or single, they are each represented in /// MusicBrainz as one release. /// /// Each release belongs to a release group and contains at least one medium (commonly referred to /// as a disc when talking about a CD release). Each medium has a tracklist. /// A medium is the actual physical medium that stores the audio content. This means that each CD /// in a multi-disc release will be entered as separate mediums within the release, and that both /// sides of a vinyl record or cassette will exist on one medium. Mediums have a format (e.g. CD, /// DVD, vinyl, and cassette) and can optionally also have a title. Sometimes a medium can be a /// side of a disc. For example, the two sides of a hybrid SACD (the CD side and the SACD side) /// should be entered as two mediums. /// Tracklists represent the set and ordering of tracks as listed on a liner, and the same tracklist /// can appear on more than one release. For example, a boxset compilation that contains previously /// released CDs would share the same tracklists as the separate releases. #[derive(Debug, Serialize, Deserialize, PartialEq, Clone)] #[serde(rename_all(deserialize = "kebab-case"))] pub struct Release { /// See [MusicBrainz Identifier](https://musicbrainz.org/doc/MusicBrainz_Identifier). pub id: String, /// The title of the release. pub title: String, #[serde(rename = "status-id")] pub status_id: Option<String>, /// The status describes how "official" a release is. pub status: Option<ReleaseStatus>, /// The date the release was issued. #[serde(deserialize_with = "date_format::deserialize_opt")] pub date: Option<NaiveDate>, /// The country the release was issued in. pub country: Option<String>, /// Data quality indicates how good the data for a release is. It is not a mark of how good or /// bad the music itself is - for that, use ratings. pub quality: Option<ReleaseQuality>, pub barcode: Option<String>, pub disambiguation: Option<String>, #[serde(rename = "packaging-id")] pub packaging_id: Option<String>, /// The physical packaging that accompanies the release. See the /// [list of packaging](https://musicbrainz.org/doc/Release/Packaging) for more information. pub packaging: Option<String>, //TODO: This might be an enum needs to test all against all possible values pub release_group: Option<ReleaseGroup>, pub media: Option<Vec<Media>>, pub label_info: Option<Vec<LabelInfo>>, pub tags: Option<Vec<Tag>>, pub aliases: Option<Vec<Alias>>, pub genres: Option<Vec<Genre>>, pub annotation: Option<String>, } #[derive(Debug, Serialize, Deserialize, PartialEq, Clone)] pub struct ReleaseTextRepresentation { pub language: Language, pub script: ReleaseScript, } /// The script used to write the release's track list. The possible values are taken from the /// [ISO 15924](https://en.wikipedia.org/wiki/ISO_15924) standard. #[derive(Debug, Serialize, Deserialize, PartialEq, Clone)] pub enum ReleaseScript { /* TODO: we need to test all posible values to build the enum see https://musicbrainz.org/doc/Release */ /// ## Latin (also known as Roman or, incorrectly, "English") /// Latin is the most common script, and usually the correct choice. It is used /// for all Western European languages, and many others. It is also the most common script used for transliterations. Latn, } /* TODO: we need to test all posible values to build the enum see https://musicbrainz.org/doc/Release */ #[derive(Debug, Serialize, Deserialize, PartialEq, Clone)] pub enum Language { Eng, } #[derive(Debug, Serialize, Deserialize, PartialEq, Clone)] #[serde(rename_all(deserialize = "lowercase"))] pub enum ReleaseQuality { /// The release needs serious fixes, or its existence is hard to prove (but it's not clearly fake). Low, /// All available data has been added, if possible including cover art with liner info that /// proves it. High, /// This is the default setting - technically "unknown" if the quality has never been modified, /// "normal" if it has. Normal, Unknown, None, } /// The release status describes how "official" a release is. #[derive(Debug, Serialize, Deserialize, PartialEq, Clone)] pub enum ReleaseStatus { /// Any release officially sanctioned by the artist and/or their record company. Most releases /// will fit into this category. Official, /// A give-away release or a release intended to promote an upcoming official release (e.g. /// pre-release versions, releases included with a magazine, versions supplied to radio DJs /// for air-play). Promotion, /// An unofficial/underground release that was not sanctioned by the artist and/or the record /// company. This includes unofficial live recordings and pirated releases. Bootleg, /// An alternate version of a release where the titles have been changed. These don't correspond /// to any real release and should be linked to the original release using the /// [transl(iter)ation relationship](https://musicbrainz.org/relationship/fc399d47-23a7-4c28-bfcf-0607a562b644). PseudoRelease, None, } #[derive(Debug, Serialize, Deserialize, PartialEq, Clone)] #[serde(rename_all(deserialize = "kebab-case"))] pub struct Media { pub title: String, pub position: u32, pub track_count: u32, pub disc_count: Option<u32>, pub format_id: Option<String>, pub format: Option<String>, pub tracks: Option<Vec<Track>>, } #[derive(Debug, Serialize, Deserialize, PartialEq, Clone)] #[serde(rename_all(deserialize = "kebab-case"))] pub struct Track { pub recording: Recording, pub title: String, pub number: String, pub length: Option<u32>, pub position: u32, pub id: String, } impl_browse! { Release, (by_area, BrowseBy::Area), (by_artist, BrowseBy::Artist), (by_label, BrowseBy::Label), (by_track, BrowseBy::Track), (by_track_artist, BrowseBy::TrackArtist), (by_recording, BrowseBy::Recording), (by_release_group, BrowseBy::ReleaseGroup), (by_collection, BrowseBy::Collection) } impl_includes!( Release, (with_labels, Include::Labels), (with_recordings, Include::Recordings), (with_release_groups, Include::ReleaseGroups), (with_tags, Include::Tags), (with_ratings, Include::Rating), (with_aliases, Include::Aliases), (with_genres, Include::Genres), (with_annotations, Include::Annotations) );