/*
Copyright © 2023 Philipp Wolfer <phw@uploadedlobster.com>

This file is part of Scotty.

Scotty is free software: you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later version.

Scotty is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with
Scotty. If not, see <https://www.gnu.org/licenses/>.
*/

package jspf

import "time"

// See https://xspf.org/jspf
type JSPF struct {
	Playlist Playlist `json:"playlist"`
}

type Playlist struct {
	Title       string         `json:"title,omitempty"`
	Creator     string         `json:"creator,omitempty"`
	Annotation  string         `json:"annotation,omitempty"`
	Info        string         `json:"info,omitempty"`
	Location    string         `json:"location,omitempty"`
	Identifier  string         `json:"identifier,omitempty"`
	Image       string         `json:"image,omitempty"`
	Date        time.Time      `json:"date,omitempty"`
	License     string         `json:"license,omitempty"`
	Attribution []Attribution  `json:"attribution,omitempty"`
	Links       []Link         `json:"link,omitempty"`
	Meta        []Meta         `json:"meta,omitempty"`
	Extension   map[string]any `json:"extension,omitempty"`
	Tracks      []Track        `json:"track"`
}

type Track struct {
	Location   []string       `json:"location,omitempty"`
	Identifier []string       `json:"identifier,omitempty"`
	Title      string         `json:"title,omitempty"`
	Creator    string         `json:"creator,omitempty"`
	Annotation string         `json:"annotation,omitempty"`
	Info       string         `json:"info,omitempty"`
	Album      string         `json:"album,omitempty"`
	TrackNum   int            `json:"trackNum,omitempty"`
	Duration   int            `json:"duration,omitempty"`
	Links      []Link         `json:"link,omitempty"`
	Meta       []Meta         `json:"meta,omitempty"`
	Extension  map[string]any `json:"extension,omitempty"`
}

type Attribution map[string]string

type Link map[string]string

type Meta map[string]string

// Extension for "https://musicbrainz.org/doc/jspf#track"
// as used by ListenBrainz.
const MusicBrainzTrackExtensionId = "https://musicbrainz.org/doc/jspf#track"

type MusicBrainzTrackExtension struct {
	AddedAt            time.Time      `json:"added_at,omitempty"`
	AddedBy            string         `json:"added_by,omitempty"`
	ReleaseIdentifier  string         `json:"release_identifier,omitempty"`
	ArtistIdentifiers  []string       `json:"artist_identifiers,omitempty"`
	AdditionalMetadata map[string]any `json:"additional_metadata,omitempty"`
}