Script to download Quicktime trailers
[1/3] from: fuka:fuxoft:cz at: 14-Jan-2003 14:50
I am a movie fan and I have exceptionally slow internet connection.
Because of this, I often tried to download embedded Quicktime movie
trailers (which can take several hours) only to find out that my
computer crashed few minutes before the end of trailer. because the
movies are embedded in the pages, Resume doesn't work and you have to
start from the beginning...
Because of this, I created a quick-and-dirty Rebol script to find URL of
the Quicktime movie file itself. You can find the script here:
http://www.fuxoft.cz/rebol/slowtime.r
For example, if you want to download the trailer on this page:
http://www.apple.com/trailers/fox/daredevil/trailer2_medium.html
Just enter this URL in my script and it will find the URL where the
movie file is stored and from where it can be downloaded using your
favourite downloader (stopping and resuming as you wish).
P.S: For those that don't download these trailers very often: This is
not a script that simply finds the ".MOV" link in the HTML page. It's a
little bit more complicated. Just try to download the movie on the above
page without this script...
P.P.S: This is basically my first Rebol script and I'd like to hear any
suggestions about how to improve it.
--
Frantisek Fuka
(yes, that IS my real name)
(and it's pronounced "Fran-tjee-shek Foo-kah")
----------------------------------------------------
My E-mail: [fuka--fuxoft--cz]
My Homepage: http://www.fuxoft.cz
My ICQ: 2745855
[2/3] 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-
[3/3] from: g:santilli:tiscalinet:it at: 14-Jan-2003 19:36
Hi Petr,
On Tuesday, January 14, 2003, 6:30:42 PM, you wrote:
PK> 2) although print "^/Sorry ...." is fine, more rebollish is:
PK> print join newline "Sorry ...."
Well, I would never had used JOIN in such case... :-)
PK> 3) the same goes probably for print [] ---> print newline
[print newline] actully prints two newlines. Maybe you meant [prin
newline] (without the "t"), but I find [print ""] or [print []] to
be not that bad...
Regards,
Gabriele.
--
Gabriele Santilli <[g--santilli--tiscalinet--it]> -- REBOL Programmer
Amigan -- AGI L'Aquila -- REB: http://web.tiscali.it/rebol/index.r