Batch upload Suno MP3s with metadata
This commit is contained in:
+10
-5
@@ -252,16 +252,21 @@ function Save-UploadedTrack {
|
||||
param($Payload)
|
||||
|
||||
if (-not $Payload.track) { throw "track is required" }
|
||||
if (-not $Payload.wavBase64) { throw "wavBase64 is required" }
|
||||
$audioBase64 = if ($Payload.audioBase64) { "$($Payload.audioBase64)" } else { "$($Payload.wavBase64)" }
|
||||
if (-not $audioBase64) { throw "audioBase64 is required" }
|
||||
|
||||
$track = $Payload.track
|
||||
$id = "$($track.id)".Trim()
|
||||
if (-not $id) { $id = Get-Date -Format "yyyyMMdd-HHmmssfff" }
|
||||
$ext = "$($Payload.audioExt)".Trim().TrimStart(".").ToLowerInvariant()
|
||||
if (-not $ext) { $ext = "wav" }
|
||||
if ($ext -notmatch '^[a-z0-9]{2,5}$') { $ext = "bin" }
|
||||
|
||||
$wavPath = Join-Path $inbox ("suno-upload-{0}.wav" -f $id)
|
||||
$bytes = [Convert]::FromBase64String("$($Payload.wavBase64)")
|
||||
[IO.File]::WriteAllBytes($wavPath, $bytes)
|
||||
$track | Add-Member -NotePropertyName "localWavPath" -NotePropertyValue $wavPath -Force
|
||||
$audioPath = Join-Path $inbox ("suno-upload-{0}.{1}" -f $id, $ext)
|
||||
$bytes = [Convert]::FromBase64String($audioBase64)
|
||||
[IO.File]::WriteAllBytes($audioPath, $bytes)
|
||||
$track | Add-Member -NotePropertyName "localAudioPath" -NotePropertyValue $audioPath -Force
|
||||
$track | Add-Member -NotePropertyName "localAudioExt" -NotePropertyValue $ext -Force
|
||||
|
||||
return Add-TracksToQueue @($track) "$($Payload.pageUrl)"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user