Public/Export-ShellPhishSetlistsByYear.ps1

function Export-ShellPhishSetlistsByYear {
    <#
    .SYNOPSIS
        Exports every setlist entry for a given year - one row per song per show.
    .PARAMETER Year
        Four-digit year to export.
    .PARAMETER ExportPath
        Required. File path (.csv or .json) to export to.
    .PARAMETER DelayMs
        Delay in milliseconds between API calls. Default 500.
    .EXAMPLE
        PS C:\> Export-ShellPhishSetlistsByYear -Year 1997 -ExportPath ./setlists-1997.csv
    #>

    [CmdletBinding()]
    param (
        [Parameter(Mandatory=$true)]
        [ValidatePattern('^\d{4}$')]
        [string]$Year,

        [Parameter(Mandatory=$true)]
        [string]$ExportPath,

        [Parameter()]
        [int]$DelayMs = 500
    )

    Write-Verbose "Fetching shows for $Year..."
    $shows = (Get-ShellPhishShows -Year $Year -OrderBy showdate -Direction asc).data

    if (-not $shows) {
        Write-Warning "No shows found for $Year"
        return
    }

    Write-Verbose "Found $($shows.Count) show(s). Fetching setlists..."
    $allEntries = @()
    foreach ($show in $shows) {
        Start-Sleep -Milliseconds $DelayMs
        $setlist = (Get-ShellPhishSetlists -ShowDate $show.showdate).data
        if ($setlist) {
            foreach ($entry in $setlist) {
                $allEntries += [PSCustomObject]@{
                    ShowDate  = $show.showdate
                    Venue     = $show.venue
                    City      = $show.city
                    State     = $show.state
                    Set       = $entry.set
                    Position  = $entry.position
                    Song      = $entry.song
                    Slug      = $entry.slug
                    Transition = $entry.trans_mark
                }
            }
        }
    }

    Export-ShellPhishData -Data $allEntries -ExportPath $ExportPath
}