from django.core.management.base import BaseCommand, CommandError
from lyrics.models import Album, Artista, Song
import csv
import argparse
from datetime import datetime


class Command(BaseCommand):
    help = "Importa la lista de letras"

    def add_arguments(self, parser):
        parser.add_argument("fichero_csv", type=str, help='Ruta al fichero csv')

    def handle(self, *args, **options):
        fichero = options["fichero_csv"]
        with open(fichero, 'r') as file:
            reader = csv.DictReader(file)
            for row in reader:
                name = row['name'],
                artist = row['artist'],
                year = row['year'],
                cover_image = row['cover_image']
                print(name, ",", artist, ",", year, ",", cover_image)
