<?xml version="1.0" encoding="utf-8"?>
<MediaItem>
  <MediaType>Audio</MediaType>
  <MediaItemType>Album</MediaItemType>
  <Collection>
    <Action MetadataOnly="false">insert</Action>
    <LastUpdate>[% timestamp | html %]</LastUpdate>
    <Identifiers>
      <PrimaryIdentifier Name="UPC">[% upc %]</PrimaryIdentifier>
    </Identifiers>
    <Media>
      <ImageLocation>[% image_filename | html %]</ImageLocation>
    </Media>
    <CollectionType>Album</CollectionType>
    <Title>[% title | html %]</Title>
    <Explicit>[% IF is_explicit == 'explicit' %]1[% ELSE %]0[% END %]</Explicit>
    <Copyright>[% cline | html %]</Copyright>
    <PhonographicCopyright>[% pline | html %]</PhonographicCopyright>
    <DisplayLabel>[% label | html %]</DisplayLabel>
    <ReleaseDate>[% release_date %]T00:00:00Z</ReleaseDate>
    <TrackCount>[% track_count %]</TrackCount>
    <TrackBundleCount>[% volume_count %]</TrackBundleCount>
    <Duration>[% audio_duration %]</Duration>
    <Language>EN</Language>
    <Contributors>
      <Contributor Role="Primary Artist">
        <Name>[% display_artist | html %]</Name>
      </Contributor>
      [% FOREACH artist = additional_artists %]
        <Contributor Role="[% artist.role.map %]">
          <Name>[% artist.display_artist | html %]</Name>
        </Contributor>
      [% END %]
    </Contributors>
    <Genres>
      <Genre>[% genre | html %]</Genre>
    </Genres>
    [% IF genre_secondary %]
    <SubGenres>
      <SubGenre>[% genre_secondary | html %]</SubGenre>
    </SubGenres>
    [% END %]
    <OfferingTerms>
      [% FOREACH territory = territories.allowed -%]
      <Territory Code="[% territory %]" EndDate="9999-12-31T23:59:58Z" StartDate="[% release_date %]T00:00:00Z">
        <Rights>
          <Right UsageType="StreamOnDemand">
            <Devices>
              <Device>PC</Device>
              <Device>Mobile</Device>
            </Devices>
          </Right>
          <Right UsageType="DigitalDownload">
            <Devices>
              <Device>PC</Device>
              <Device>Mobile</Device>
            </Devices>
          </Right>
          <Right UsageType="RadioStream">
            <Devices>
              <Device>PC</Device>
              <Device>Mobile</Device>
            </Devices>
          </Right>
          <Right UsageType="SampleStreamOnDemand">
            <Devices>
              <Device>PC</Device>
              <Device>Mobile</Device>
            </Devices>
          </Right>
          <Right UsageType="SubscriptionStreamOnDemand">
            <Devices>
              <Device>PC</Device>
              <Device>Mobile</Device>
            </Devices>
          </Right>
        </Rights>
      </Territory>
      [% END %]
    </OfferingTerms>
    <Tracks>
    [% FOREACH volume = volumes -%]
    [% FOREACH track = volume.tracks -%]
      <Track>
        <Action MetadataOnly="false">insert</Action>
        <Identifiers>
          <PrimaryIdentifier Name="ISRC">[% track.isrc %]</PrimaryIdentifier>
        </Identifiers>
        <Media>
          <ClipLocation>[% track.audio_preview_filename %]</ClipLocation>
          <TrackLocation>[% track.audio_filename %]</TrackLocation>
        </Media>
        <Title>[% track.title | html %]</Title>
        <Duration>[% track.audio_duration %]</Duration>
        <Explicit>[% IF track.is_explicit == 'explicit' %]1[% ELSE %]0[% END %]</Explicit>
        <ReleaseDate>[% release_date %]T00:00:00Z</ReleaseDate>
        <Copyright>[% track.cline | html %]</Copyright>
        <PhonographicCopyright>[% track.pline | html %]</PhonographicCopyright>
        <DisplayLabel>[% track.label | html %]</DisplayLabel>
        <DiscNumber>[% volume.sequence %]</DiscNumber>
        <TrackNumber>[% track.sequence %]</TrackNumber>
        <Language>EN</Language>
        <Contributors>
          <Contributor Role="Primary Artist">
            <Name>[% track.display_artist | html %]</Name>
          </Contributor>
          [% IF track.composer %]
          <Contributor Role="Composer">
            <Name>[% track.composer | html %]</Name>
          </Contributor>
          [% END %]
          [% FOREACH artist = track.additional_artists %]
            <Contributor Role="[% artist.role.map %]">
              <Name>[% artist.display_artist | html %]</Name>
            </Contributor>
          [% END %]
        </Contributors>
        <Genres>
          <Genre>[% track.genre | html %]</Genre>
        </Genres>
        [% IF track.genre_secondary %]
        <SubGenres>
          <SubGenre>[% track.genre_secondary | html %]</SubGenre>
        </SubGenres>
        [% END %]
        <OfferingTerms>
        [% FOREACH territory = territories.allowed -%]
          <Territory Code="[% territory %]" EndDate="9999-12-31T23:59:58Z" StartDate="[% release_date %]T00:00:00Z">
            <Rights>
              <Right [% IF track.album_only %]AlbumOnly="1"[% END %] UsageType="DigitalDownload">
                <Devices>
                  <Device>PC</Device>
                  <Device>Mobile</Device>
                </Devices>
              </Right>
              [% IF track.album_only %]
              [% ELSE %]
              <Right UsageType="StreamOnDemand">
                <Devices>
                  <Device>PC</Device>
                  <Device>Mobile</Device>
                </Devices>
              </Right>
              <Right UsageType="RadioStream">
                <Devices>
                  <Device>PC</Device>
                  <Device>Mobile</Device>
                </Devices>
              </Right>
              <Right UsageType="SampleStreamOnDemand">
                <Devices>
                  <Device>PC</Device>
                  <Device>Mobile</Device>
                </Devices>
              </Right>
              <Right UsageType="SubscriptionStreamOnDemand">
                <Devices>
                  <Device>PC</Device>
                  <Device>Mobile</Device>
                </Devices>
              </Right>
              [% END %]
            </Rights>
          </Territory>
        [% END %]
      </OfferingTerms>
      </Track>
    [% END %]
    [% END %]
    </Tracks>
  </Collection>
</MediaItem>
