Repository navigation
Prevent a second download starting when Continue is pressed twice #112
Description
After pressing Continue, the Main dialog closes, the pre-download checks run, and then the Main dialog is redisplayed with the URL still in the text box. During that gap nothing indicates work is happening, so it reads as a click that didn't register — and Continue is sitting right there to press again. Doing that starts a second download of the same URL.
When that happens, two yt-dlp processes work against the same output file names. In my case the log ended after the [download] Destination: lines with no [Merger] step, and the file left behind was the bare video stream renamed .mp4 — AV1, no audio track, and the "QT compatible video" re-encode never ran despite being enabled. That file plays on a recent Apple-silicon Mac and fails on older ones, so it looks like a codec bug rather than a duplicate run.
Two suggestions, either or both:
1. Guard against resubmission
When the Main dialog is redisplayed after a download has been launched, ignore Continue for a URL already in progress (or clear the field, as the existing "Discard URL after download" setting does).
2. Show progress during the checks
An indeterminate indicator using AppleScript's built-in progress properties — available from 10.10, so no change to the minimum OS. There is already a "Please wait" alerter notification for the channel check around line 1802; this would cover the ordinary single-video path, with no extra process to kill on the error paths.
Suggested code for (2), in Code/Main.applescript:
Add two handlers:
on show_busy(theText)
-- Show an indeterminate progress indicator while pre-download checks run.
-- These checks can take several seconds with no feedback on screen, so users press
-- Continue a second time and two downloads start on the same file names.
set progress total steps to -1
set progress completed steps to 0
set progress description to theText
set progress additional description to ""
end show_busy
on clear_busy()
-- Clear the progress indicator once the checks are finished
set progress total steps to 0
set progress description to ""
set progress additional description to ""
end clear_busyStart it when download_video() begins (currently line 1315), immediately after the handler opens:
show_busy(localized string "Checking URL - please wait..." from table "MacYTDL")Update the text at each slow stage — before the Deno check (around line 1486):
show_busy(localized string "Checking Deno..." from table "MacYTDL")and before the simulate run, section "Eighth, use simulated YTDL/yt-dlp run..." (currently line 1576):
show_busy(localized string "Checking the video - please wait..." from table "MacYTDL")Clear it before each display dialog inside download_video, before the Monitor dialog takes over, and immediately before end download_video (currently line 2793).
Three new strings would be needed for MacYTDL.strings: "Checking URL - please wait...", "Checking Deno...", "Checking the video - please wait...".
The handlers above compile and run under osacompile. They have not been tested inside MacYTDL itself, since editing the installed app would break its code signature.
Version: MacYTDL 1.31.2, macOS 26, Apple silicon.
Activity
section83 commentedon Sep 29, 2026
Hello noimdan, thank you for posting,
Regarding Issue 1, there is setting in the Admin dialog "Discard URL after download". With that on, the URL will be removed before the Main dialog is redisplayed. Originally the default behaviour was to discard the URL but a user complained that they needed to resubmit the URL when the download failed and finding the URL took time.
Regarding Issue 2, adding progress indictors is a good idea but it is hard. AppleScript can only do one thing at a time so, it can't show a progress indicator while it's updating Deno or doing any other thing. To show the current notifications I spawn a background process which is not connected to MacYTDL. All those separate download "Monitors" are separate processes.
I did look at using the AppleScript progress dialog but decided not to use it as I can't put the MacYTDL logo onto it and there is one button which issues a "Stop". But, that was in 2017 so I should have another look.
But, yes, I could show new notifications during the "simulation" stage before the download starts which say what is being checked. A bit tricky as the notification needs to visible long enough for the user to see but not so long that they are still visible when the download starts. Ideally I would issue a command to the Alerter tool to close the notification but Alerter has a bug and doesn't close cleanly. I'm waiting until the redeveloped Alerter is debugged and will start using that. Unfortunately Alerter is now macOS 13+ only.
Of course, in a true video download app there would be a pane showing what is happening as it happens and updating in real time. If I get time, I hope to start work on MacYTDL v2.0 which will be in SwiftUI. That would not have the limitations of AppleScript.
Thanks again.