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

[REBOL] Re: Script to download Quicktime trailers

From: petr::krenzelok::trz::cz at: 14-Jan-2003 18:30

Frantisek Fuka wrote:
> P.P.S: This is basically my first Rebol script and I'd like to hear any > suggestions about how to improve it. >
Hello Frantisek, so,: 1) you can use 'ask function instead of 'print in conjunction with 'input one 2) although print "^/Sorry ...." is fine, more rebollish is: print join newline "Sorry ...." 3) the same goes probably for print [] ---> print newline 4) also - your script uses a bit sequencional structuring, I mean - I miss a bit if-then-else principle, but if it works, then OK ... However, maybe you could be interested into following script. We too, download new f-prot antivirus definitions and our connection to server is somehow lame and it breaks several times during the download. So, I hacked a quick partial downloader - it works following way ... 1) you download your stuff normal way ... 2) if it breaks, you select file url and paste it into my script 3) it skips already downloaded amount of data and joins at the end 4) it does so untill the file is downloaded, starting where it left last time ... just for study purposes: (note: write/binary/append is used instead of opening file using /skip refinement - it was buggy and I don't know if it is already fixed ...) 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 cheers, -pekr-