Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: tired of broken downloads?

From: petr:krenzelok:trz:cz at: 16-Aug-2002 12:50

; replying myself with updated versions .... downloaded safely more than 100 MB today, correctly appends to interrupted downloads, etc. REBOL [ Title: "download-it!" Author: "Petr Krenzelok" Email: [petr--krenzelok--trz--cz] File: %download-it!.r Version: 1.0 Comment: {Tries to download file, till complete. Still place for improvements: - GUI - not necessary imo - log events to file? - download list of files? - callbacks? E.g. notification by sending email, sms, etc. - whatever ... as for me though - it works, so - finished ... :-) } ] source-file: to-url ask "Paste URL: " target-file: first request-file/title "Save (append) to ..." "Select" source-size: size? source-file either exists? target-file [target-size: size? target-file][target-size: 0] if target-size == source-size [print "Nothing to download, file already complete ..." halt] if target-size > 0 [print ["Appending at " target-size "bytes"]] start: now/time forever [ while [error? try [source: open/binary/direct/no-wait/skip source-file target-size]][ print "Can't open source file .... waiting 10 min" wait 00:10 ] while [ wait source all [ not error? try [data: copy/part source 8192] data ] ][ write/binary/append target-file data target-size: target-size + length? data print ["Source-size: " source-size tab "Downloaded: " target-size tab "Time: " now/time - start] ] if target-size >= source-size [print "Download complete ..." break] print "Download interrupted ..." print ["Continuing at " target-size "bytes"] close source ] close source