package RPS::Import::Secretly::v9;

use strict;
use warnings;

use lib '/app/tools/rps/lib';
use base 'RPS::Import::Secretly::v6';

sub _fieldMap {
    {
        labelName       => 'X',
        serviceID       => 'B',
        countryCode     => 'J',
        dateBegin       => 'T',
        productType     => 'F',
        formatType      => 'K',
        clientProductID => 'C',
        artistName      => 'G',
        upc             => 'E',
        albumName       => 'D',
        isrc            => 'F',
        trackName       => 'H',
        units           => 'L',
        price           => 'R',
    };
}

sub mediaType { RPS::DB::Item::MediaType::kMediaTypeAudio }

sub formatType {
    my $self = shift;

    my $type = $self->_getByFieldName('formatType');

    return RPS::File::Sale::FORMAT_PERFORMANCE if $type =~ (/^Radio \([BDS]/i );
    return RPS::File::Sale::FORMAT_DOWNLOAD if ($type =~ /^(?:album|track)$/i);
    return RPS::File::Sale::FORMAT_STREAM if $type =~ (/^(cloud|stream|not a sale|radio \(.+?\))$/i );

    $self->fail("Could not parse format type from '$type'");
}

1;
