--!movie
--!encoding=utf-8
global $
----------------------------------------
-- Download file with ftp (synchronous/blocking mode)
----------------------------------------
on startMovie
_player.debugPlaybackEnabled = 1
-- libs
$.import("curl")
-- config
tRemoteFile = "ftp://ftp.fu-berlin.de/pub/du-k.gz"
tLocalFile = $.PATH & "du-k.gz"
-- get a CURL handle (xtra instance)
ch = $.curl.init()
-- specify options
ch.setOption($.curl.CURLOPT.URL, tRemoteFile)
--ch.setOption($.curl.CURLOPT.USERNAME, tUsername)
--ch.setOption($.curl.CURLOPT.PASSWORD, tPassword)
-- specify target filename
ch.setDestinationFile(tLocalFile)
-- returnMode: 0=return error code (=default), 1=return data
-- => has to be 0 (or void) to download directly to destination file!
res = ch.exec(0)
put "DOWNLOAD FINISHED!"
put "ERROR:" && curl_error(res)
--put "SPEED_DOWNLOAD:" && ch.getInfo($.curl.CURLINFO.SPEED_DOWNLOAD)
--put "TOTAL_TIME:" && ch.getInfo($.curl.CURLINFO.TOTAL_TIME)
end