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

package RPS::Import::LimeWire::v2;

use strict;

use Date::Calc qw(Days_in_Month Add_Delta_Days Decode_Month);

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 RPS::Import::SaleRec;
use RPS::DB::Item::MediaType;
use RPS::File::Sale;

use lib '/app/tools/rps/lib';
use RPS::Import::Importer;
use base 'RPS::Import::LimeWire::Base';

sub _country  { 'US' }
sub _currency { 'USD' }

sub _fieldMap {
    {
        track_artist     => 2,
        upc              => 8,
        track_product_id => 3,
        album_name       => 5,
        album_artist     => 6,
        album_product_id => 7,
        isrc             => 4,
        track_name       => 1,
        type             => 11,
        net_price        => 14,
    };
}

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

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

    my ( $startDate, $endDate );

    my $f_date = $sheet->[8]->[0];
    if ( $f_date =~ /(\d{1,2}\/\d{1,2}\/\d{4}) - (\d{1,2}\/\d{1,2}\/\d{4})/ ) {
        $startDate = $1;
        $endDate   = $2;
    }

    return ( $startDate, $endDate );
}

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