2011-09-16 6 views
0

HTTPサーバーからファイルをダウンロードするスクリプトを作成しましたが、結果は非常に散発的です。 3回連続して実行すると、2回動作し、1回エラーが発生するか、まったく動作せず、異なるエラーが返される可能性があります。Applescript Httpサーバーのファイルを散発的にダウンロードする

私は取得していますエラーの一部は次のとおりです。ターゲットURL(-609)をダウンロードして

エラー URLアクセスのスクリプトはエラーを得た:接続が無効です。

ターゲットURL(-31040)をダウンロード中にエラーが発生しました。 URLアクセススクリプトにエラーが発生しました。タイプが-31040のエラーが発生しました。

try 
    set theFileURL to "http://ftp2.nflfilmstv.com/filmsint/ftp-inet/Team/110915_game_preview_phi_atl_3200k.mp4" as text 

    set TID to AppleScript's text item delimiters 
    set AppleScript's text item delimiters to "/" 
    set theFile to text item -1 of theFileURL 
    set AppleScript's text item delimiters to TID 

    set theFilePath to "Macintosh HD:Users:rgilkes:Desktop:" & theFile as text 

    tell application "URL Access Scripting" to download theFileURL to file theFilePath with progress 
    on error ErrorMessage number ErrorNumber 
     display alert "Error with downloading target URL (" & ErrorNumber & ")" message ErrorMessage 
end try 

AppleScript経由でファイルをダウンロードする方法はありますか、それともコードが悪いですか?

答えて

1

ああ、プレビューありがとう!私はもともとフィラデルフィアであり、フィリースポーツについてはまだ熱心です。私はファルコンズのファンを助けてくれないことを願っています。少なくとも今週はない! ;)

とにかく、あなたのコードはうまく見えますが、URLAccessScriptingはダウンロードするのが最も信頼できる方法ではありません。実際には10.7以降、OSには含まれていません。カールは代替品で、通常は安定しています。あなたはそれと一緒に進歩のウィンドウを取得しません。これを試して。それがより安定しているかどうか確認してください。それはあなたが終わった時を教えてくれるでしょう。

set theFileURL to "http://ftp2.nflfilmstv.com/filmsint/ftp-inet/Team/110915_game_preview_phi_atl_3200k.mp4" 

set {TID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, "/"} 
set theFile to text item -1 of theFileURL 
set AppleScript's text item delimiters to TID 

set theFilePath to (path to desktop as text) & theFile 

try 
    do shell script "curl " & quoted form of theFileURL & " -o " & quoted form of POSIX path of theFilePath 
    display dialog "The download is finished!" buttons {"OK"} default button 1 with icon note giving up after 5 
on error theError 
    display dialog "Error downloading the file:" & return & theFile & return & return & theError buttons {"OK"} default button 1 with icon 0 giving up after 5 
end try 
+0

私は実際にファルコンの仕事をしています。素晴らしいゲームになるよ!これは完璧に働いてくれてありがとうございました。私は別の場所でそれについていくつかのコメントを見ましたが、完全に認識していませんでした。 – RGilkes

+0

うれしい私は助けることができました!はい、それは素晴らしいゲームとあなたに幸運でなければなりません...日曜日の夜約3時間を除いて! – regulus6633

関連する問題