Show sync counts and progress bars
This commit is contained in:
+31
-3
@@ -251,6 +251,21 @@ function Get-QueueSnapshot {
|
||||
}
|
||||
}
|
||||
|
||||
function Format-ProgressBar {
|
||||
param(
|
||||
[int]$Done,
|
||||
[int]$Total,
|
||||
[int]$Width = 28
|
||||
)
|
||||
|
||||
if ($Total -le 0) {
|
||||
return "[" + ("-" * $Width) + "]"
|
||||
}
|
||||
$ratio = [Math]::Max(0, [Math]::Min(1, $Done / $Total))
|
||||
$filled = [int][Math]::Round($ratio * $Width)
|
||||
return "[" + ("#" * $filled) + ("-" * ($Width - $filled)) + "]"
|
||||
}
|
||||
|
||||
function Stop-AllWork {
|
||||
$stopped = 0
|
||||
foreach ($job in @($script:activeJobs)) {
|
||||
@@ -288,6 +303,7 @@ function Show-Dashboard {
|
||||
Write-Host "Logs: $logs"
|
||||
Write-Host ""
|
||||
Write-Host ("Workers: {0}/{1} Queue: {2} Done: {3}/{4} Failed: {5} Progress: {6}%" -f $snapshot.activeCount, $snapshot.maxWorkers, $snapshot.queued, $snapshot.done, $snapshot.total, $snapshot.failed, $snapshot.percent)
|
||||
Write-Host ("{0} {1}/{2}" -f (Format-ProgressBar $snapshot.done $snapshot.total), $snapshot.done, $snapshot.total) -ForegroundColor Cyan
|
||||
Write-Host ""
|
||||
|
||||
if ($snapshot.activeJobs.Count) {
|
||||
@@ -381,7 +397,8 @@ function Add-TracksToQueue {
|
||||
[void]$queueIds.Add($id)
|
||||
$added += $track
|
||||
}
|
||||
$script:stats.total += @($added).Count
|
||||
$script:stats.total += (@($added).Count + $skipped)
|
||||
$script:stats.completed += $skipped
|
||||
$script:stats.skipped += $skipped
|
||||
Update-Queue
|
||||
$snapshot = Get-QueueSnapshot
|
||||
@@ -446,17 +463,23 @@ function Get-MissingTracks {
|
||||
|
||||
$existingIds = Get-ExistingSunoIds $libraryRoot
|
||||
$missing = @()
|
||||
$existingRequested = @()
|
||||
$invalid = 0
|
||||
foreach ($track in @($Tracks)) {
|
||||
$id = "$($track.id)".Trim()
|
||||
if (-not $id) { continue }
|
||||
if (-not $id) { $invalid++; continue }
|
||||
if (-not $existingIds.Contains($id)) {
|
||||
$missing += $track
|
||||
} else {
|
||||
$existingRequested += $track
|
||||
}
|
||||
}
|
||||
|
||||
return [pscustomobject]@{
|
||||
existingIds = @($existingIds)
|
||||
existingRequested = $existingRequested
|
||||
missing = $missing
|
||||
invalid = $invalid
|
||||
}
|
||||
}
|
||||
|
||||
@@ -545,8 +568,13 @@ try {
|
||||
outputRoot = $OutputRoot
|
||||
libraryRoot = $libraryRoot
|
||||
artist = $ArtistName
|
||||
requested = @($manifest.tracks).Count
|
||||
received = @($manifest.tracks).Count
|
||||
existing = @($result.existingIds).Count
|
||||
libraryExistingTotal = @($result.existingIds).Count
|
||||
existingRequested = @($result.existingRequested).Count
|
||||
missingRequested = @($result.missing).Count
|
||||
invalidRequested = $result.invalid
|
||||
existing = @($result.existingRequested).Count
|
||||
missing = @($result.missing).Count
|
||||
tracks = @($result.missing)
|
||||
} | ConvertTo-Json -Depth 50 -Compress)
|
||||
|
||||
Reference in New Issue
Block a user