# Marketshare-CEA

Weekly marketshare data processing for DSP partners (Spotify, Apple, Amazon).

## Install

```bash
uv sync
```

## Prerequisites

Fill the following variables in your `.env` file:

```bash
LOGDIR=/path/to/logs

#Reporting-DB
hostReportingDB
portReportingDB
dbnameReportingDB
usernameReportingDB
passwordReportingDB
```

## Usage

```bash
uv run python src/main.py [OPTIONS]
```

## Options

| Option | Short | Description |
|--------|-------|-------------|
| `--partner` | `-p` | Process only this partner (spotify, apple, amazon) |
| `--force` | `-f` | Force update even if data already exists |
| `--marketshare-date` | `-d` | Start date (YYYY-MM-DD) |
| `--max-date` | `-m` | End date (YYYY-MM-DD) |

## Examples

```bash
# Process all partners (skip if data exists)
python main.py

# Process only Spotify
python main.py -p spotify

# Force update all partners
python main.py -f

# Process specific date range
python main.py -d 2024-01-01 -m 2024-01-07

# Process Spotify for specific date range with force update
python main.py -p spotify -d 2024-01-01 -m 2024-01-07 -f
```

## Behavior

- By default (`force=False`), the script checks if data already exists for a partner and date before processing. If it exists, the partner is skipped.
- With `--force`, existing data is deleted and reinserted.
- Amazon partner maps to multiple partner names: `Amazon Streaming`, `Prime Music`, `Amazon Free`.
