Public/Export-ShellPhishAllSongs.ps1
|
function Export-ShellPhishAllSongs { <# .SYNOPSIS Exports the full Phish song catalog with extended song data. .PARAMETER ExportPath Required. File path (.csv or .json) to export to. .PARAMETER IncludeSongData Also fetch extended songdata (history, lyrics). Much slower due to per-song API calls. .PARAMETER DelayMs Delay in milliseconds between API calls. Default 500. .EXAMPLE PS C:\> Export-ShellPhishAllSongs -ExportPath ./songs.csv .EXAMPLE PS C:\> Export-ShellPhishAllSongs -ExportPath ./songs-full.json -IncludeSongData #> [CmdletBinding()] param ( [Parameter(Mandatory=$true)] [string]$ExportPath, [Parameter()] [switch]$IncludeSongData, [Parameter()] [int]$DelayMs = 500 ) Write-Verbose "Fetching song catalog..." $songs = (Get-ShellPhishSongs).data if (-not $songs) { Write-Warning "No songs returned" return } if ($IncludeSongData) { Write-Verbose "Enriching $($songs.Count) songs with songdata..." $enriched = foreach ($song in $songs) { Start-Sleep -Milliseconds $DelayMs $detail = (Get-ShellPhishSongData -Slug $song.slug).data if ($detail) { $d = if ($detail -is [array]) { $detail[0] } else { $detail } [PSCustomObject]@{ Song = $song.song Slug = $song.slug Artist = $song.artist Debut = $d.debut LastPlayed = $d.last_played Times = $d.times_played Gap = $d.gap } } else { [PSCustomObject]@{ Song = $song.song Slug = $song.slug Artist = $song.artist Debut = '' LastPlayed = '' Times = '' Gap = '' } } } Export-ShellPhishData -Data $enriched -ExportPath $ExportPath } else { Export-ShellPhishData -Data $songs -ExportPath $ExportPath } } |