fix: emit distinct status messages for individual tracks during download

- yt-dlp downloads video and audio streams sequentially, causing the progress bar to reset when switching streams.
- The status message was previously hardcoded to 'Downloading Media' and overwrote track change indicators.
- Now, when yt-dlp starts a new stream, the status message clearly reads 'Downloading Video Track', 'Downloading Audio Track', etc., explaining the progress reset to the user.
This commit is contained in:
NimBold
2026-06-11 14:19:59 +03:30
parent 99500254a1
commit 4856b3f3b2
2 changed files with 13 additions and 9 deletions
@@ -572,9 +572,6 @@ final class DownloadController: ObservableObject {
$0.etaText = progress.etaText
}
$0.connectionCount = progress.connectionCount
if $0.message == "Starting" {
$0.message = "Downloading Media"
}
}
}
},
+13 -6
View File
@@ -263,6 +263,7 @@ final class YTDLPOutputHandler: @unchecked Sendable {
private let outputPathTracker: YTDLPOutputPathTracker
private let progress: @Sendable (DownloadProgress) -> Void
private let messageUpdate: @Sendable (String) -> Void
private var trackCount = 0
init(
parser: YTDLPProgressParser,
@@ -280,18 +281,17 @@ final class YTDLPOutputHandler: @unchecked Sendable {
for line in text.split(whereSeparator: \.isNewline) {
let stringLine = String(line)
outputPathTracker.observe(stringLine)
if let update = parser.parse(stringLine) {
progress(update)
messageUpdate("Downloading Media")
} else if let message = statusMessage(for: stringLine) {
if let message = statusMessage(for: stringLine) {
messageUpdate(message)
} else if let update = parser.parse(stringLine) {
progress(update)
}
}
}
private func statusMessage(for line: String) -> String? {
if line.contains("[Merger]") || line.contains("[ExtractAudio]") || line.contains("[Fixup") {
return "Processing Media..."
return "Merging Media Tracks..."
}
if line.contains("[youtube]") && line.localizedCaseInsensitiveContains("Downloading") {
return "Fetching YouTube data..."
@@ -309,7 +309,14 @@ final class YTDLPOutputHandler: @unchecked Sendable {
return "YouTube challenge solver unavailable"
}
if line.contains("Destination:") {
return "Starting media download..."
trackCount += 1
if trackCount == 1 {
return "Downloading Video Track"
} else if trackCount == 2 {
return "Downloading Audio Track"
} else {
return "Downloading Track \(trackCount)"
}
}
return nil
}