I have internet plan which allows me to download freely at night. I want to schedule my downloads. I use Camino browser (Beta version 2.0b3). When a download begins it creates two files:
3.xyz and 3.xyz.part.
When the download is finished, 3.xyz.part is deleted automatically.
Some of my downloads are often youtube files, so I cannot just queue them because the links will expire after some time.
Sometimes if a download is broken, the 2 files still remain in the folder.
How do I script ?
I am willing to use something else(except Safari because Safari often does not resume even resumable downloads and my ISP does reset connection sometimes) other than Camino if it makes scripting easier.
I don’t want a script. Just show me the path.
Let me know the best suited application to do it and the method I must use (folder action, or a script that runs in the background etc)
I don’t see any way to do what you want without some kind of a queue… so I don’t see a solution for you.
By queue, i meant i cannot use some external download manager which allows queuing downloads. I download my youtube videos by placing the URL in the address bar and executing a javascript. The javascript is a bookmarklet (for some reasons, thats how it has to be in Camino) and i execute the bookmarklet with a keystroke like (Cmd+2).
repeat with i from 11 to 15
delay 240
set aitem to item i of allnames
delay 5
open aitem ---its a webloc file
tell application "Camino"
activate
tell application "System Events"
tell process "Camino"
delay 5
keystroke "2" using command down
end tell
end tell
end tell
end repeat
But the above script is dependent on time and not on completed downloads. This has to change.
Here’s what I use when I want to watch a download. The premise is that when a file is downloading that the folder where the file is being downloaded to will be getting bigger in size as the download progresses. So we can check the size of the folder and when the size stops changing then we know the download has completed… unless of course the download stops for some other reason.
set watchFolder to path to downloads folder as text
set success to delayUntilFolderSizeStopsChanging(watchFolder)
if success then
display dialog "The download completed!" buttons {"OK"} default button 1 with icon note
else
display dialog "There was an error watching the folder!" buttons {"OK"} default button 1 with icon caution
end if
on delayUntilFolderSizeStopsChanging(theFolder)
set timeDelay to 10 -- the time to wait between size checks
try
set sizeThen to size of (info for file (theFolder as text)) --get initial size
repeat
delay timeDelay
set sizeNow to size of (info for file theFolder) -- get new size
if sizeNow - sizeThen is less than or equal to 0 then exit repeat
set sizeThen to sizeNow
end repeat
on error
return false
end try
return true
end delayUntilFolderSizeStopsChanging
So what I would do is make a text file with all my links that need to be downloaded, each link on a separate line. Then you could use this to get the links from the file. Then you can incorporate the above script into this one so that each download will happen one at a time.
set linkFile to (path to desktop folder as text) & "links.txt"
set theLinks to paragraphs of (read file linkFile)
repeat with i from 1 to count of theLinks
set thisLink to item i of theLinks
-- start the download
-- watch the download folder for changing size
end repeat