Prepare Suno WAV URLs through studio API
This commit is contained in:
@@ -112,6 +112,17 @@ function Get-UrlExtension {
|
||||
return $Fallback
|
||||
}
|
||||
|
||||
function Resolve-SunoMediaUrl {
|
||||
param([string]$Value)
|
||||
|
||||
if (-not $Value) { return "" }
|
||||
$raw = $Value.Trim()
|
||||
if ($raw -match '^https?://') { return $raw }
|
||||
if ($raw.StartsWith("//")) { return "https:$raw" }
|
||||
if ($raw.StartsWith("/")) { return "https://suno.com$raw" }
|
||||
return $raw
|
||||
}
|
||||
|
||||
function Invoke-Download {
|
||||
param(
|
||||
[string]$Url,
|
||||
@@ -180,8 +191,12 @@ foreach ($track in $tracks) {
|
||||
$model = Get-DeepValue $track @("model_name", "model", "major_model_version")
|
||||
$createdAt = Get-DeepValue $track @("created_at", "createdAt")
|
||||
|
||||
$wavUrl = if ($track.wavUrl) { "$($track.wavUrl)" } elseif ($id) { "https://cdn1.suno.ai/$id.wav" } else { "" }
|
||||
$audioUrl = if ($track.audioUrl) { "$($track.audioUrl)" } else { "" }
|
||||
$audioUrl = Resolve-SunoMediaUrl $(if ($track.audioUrl) { "$($track.audioUrl)" } else { Get-DeepValue $track @("audio_url", "audioUrl", "stream_audio_url", "streamAudioUrl", "play_url", "playUrl", "play_path", "playPath", "mp3_url", "mp3Url", "video_url", "videoUrl") })
|
||||
$wavUrl = Resolve-SunoMediaUrl $(if ($track.wavUrl) { "$($track.wavUrl)" } else { Get-DeepValue $track @("wav_url", "wavUrl", "download_url", "downloadUrl") })
|
||||
$wavCandidates = @()
|
||||
if ($wavUrl) { $wavCandidates += $wavUrl }
|
||||
if ($id) { $wavCandidates += "https://cdn1.suno.ai/$id.wav" }
|
||||
$wavCandidates = $wavCandidates | Where-Object { $_ } | Select-Object -Unique
|
||||
$imageUrl = if ($track.imageUrl) { "$($track.imageUrl)" } else { Get-DeepValue $track @("image_url", "imageUrl", "image_large_url", "cover_url") }
|
||||
|
||||
$inputAudio = Join-Path $workRoot "$prefix.input.wav"
|
||||
@@ -193,7 +208,12 @@ foreach ($track in $tracks) {
|
||||
Write-Host ""
|
||||
Write-Host "[$index/$($tracks.Count)] $title"
|
||||
|
||||
$audioOk = Invoke-Download $wavUrl $inputAudio
|
||||
$audioOk = $false
|
||||
foreach ($candidate in $wavCandidates) {
|
||||
Write-Host "WAV 후보 시도: $candidate"
|
||||
$audioOk = Invoke-Download $candidate $inputAudio
|
||||
if ($audioOk) { break }
|
||||
}
|
||||
if (-not $audioOk -and $audioUrl) {
|
||||
Write-Host "WAV 후보 실패. audioUrl로 fallback 시도."
|
||||
$audioOk = Invoke-Download $audioUrl $fallbackAudio
|
||||
|
||||
Reference in New Issue
Block a user