#---------------------------------------------------------------
# ____                   _ _         ____  _
#|  _ \ ___  _   _  __ _| | |_ _   _/ ___|| |__   __ _ _ __ ___
#| |_) / _ \| | | |/ _` | | __| | | \___ \| '_ \ / _` | '__/ _ \
#|  _ < (_) | |_| | (_| | | |_| |_| |___) | | | | (_| | | |  __/
#|_| \_\___/ \__, |\__,_|_|\__|\__, |____/|_| |_|\__,_|_|  \___|
#            |___/             |___/
#
# Copyright (C) 2010 RoyaltyShare, Inc.   All Rights Reserved
#---------------------------------------------------------------

package RPS::Import::Musiwave::v4;

use strict;

use lib '/app/tools/rps/lib';
use RPS::DB::Item::Client;

use lib '/app/tools/common/lib';
use Common::Consts;
use Common::Assert;
use Common::Log;

use lib '/app/tools/data_classes/lib';

use lib '/app/tools/rps/lib';

use base 'RPS::Import::Musiwave::TextBase';

sub _fieldMap {
    {
		label            => 7,
        distributor      => 10,
        type             => 14,
        track_product_id => 0,
        track_artist     => 1,
        album_artist     => 5,
        track_artist     => 2,
		upc              => 6,
		album_name       => 4,
		isrc             => 3,
		track_name       => 1,
		country          => 12,
		currency         => 13,
        service_name     => 10,
		net_price        => 15,
		number_of_plays  => 16,
	}
}

sub _productTypeMap {
	{
         'single full-track' =>
         {
             productType => RPS::File::Sale::TYPE_TRACK,
             formatType => RPS::File::Sale::FORMAT_DOWNLOAD,
             mediaType => RPS::DB::Item::MediaType::kMediaTypeAudio,
         },
         'album full-track' =>
         {
             productType => RPS::File::Sale::TYPE_ALBUM,
             formatType => RPS::File::Sale::FORMAT_DOWNLOAD,
             mediaType => RPS::DB::Item::MediaType::kMediaTypeAudio,
         },
	}
}

sub _getDate {
	my $self = shift;
    my $fileName = shift;

	return ($self->{_startDate}, $self->{_endDate}) if( $self->{_startDate} );

    unless( $fileName =~ /(\d{4})(\d{2})(\d{2})_(\d{4})(\d{2})(\d{2})/ ) {
        die "Could not get date from filename: $fileName";
    }

    my ($startDate, $endDate);

    $startDate   = sprintf( "%04d-%02d-%02d", $1, $2, $3 );
	$endDate     = sprintf( "%04d-%02d-%02d", $4, $5, $6 );

	$self->{_startDate} = $startDate;
	$self->{_endDate}   = $endDate;

    return ($startDate, $endDate);
}

###
1;# Play nicely.
###
