1. --!movie
  2. --!encoding=utf-8
  3.  
  4. global $
  5.  
  6. ----------------------------------------
  7. -- Download file with ftp (synchronous/blocking mode)
  8. ----------------------------------------
  9. on startMovie
  10.     _player.debugPlaybackEnabled = 1
  11.  
  12.     -- libs
  13.     $.import("curl")
  14.  
  15.     -- config
  16.     tRemoteFile = "ftp://ftp.fu-berlin.de/pub/du-k.gz"
  17.     tLocalFile = $.PATH & "du-k.gz"
  18.  
  19.     -- get a CURL handle (xtra instance)
  20.     ch = $.curl.init()
  21.  
  22.     -- specify options
  23.     ch.setOption($.curl.CURLOPT.URL, tRemoteFile)
  24.  
  25.     --ch.setOption($.curl.CURLOPT.USERNAME, tUsername)
  26.     --ch.setOption($.curl.CURLOPT.PASSWORD, tPassword)
  27.  
  28.     -- specify target filename
  29.     ch.setDestinationFile(tLocalFile)
  30.  
  31.     -- returnMode: 0=return error code (=default), 1=return data
  32.     -- => has to be 0 (or void) to download directly to destination file!
  33.     res = ch.exec(0)
  34.  
  35.     put "DOWNLOAD FINISHED!"
  36.     put "ERROR:" && curl_error(res)
  37.     --put "SPEED_DOWNLOAD:" && ch.getInfo($.curl.CURLINFO.SPEED_DOWNLOAD)
  38.     --put "TOTAL_TIME:" && ch.getInfo($.curl.CURLINFO.TOTAL_TIME)
  39. end
  40.  
[raw code]