Jump to content
Server Maintenance This Week. ×

Download from URL


This topic is 5307 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Hi--

I have the following AS I'm trying to use in a script to download audio mp3's from my jott account. Here's what I have so far, under Send Event:

"set the target_URL to " & jotts::listenURL & "¶set the destination_file to " & ""'Macintosh HD/Users/jeffrey/Downloads/'"" & jotts::Title & "mp3"" & "¶tell application " & ""URL Access Scripting"" & "¶download target_URL to file destination_file replacing no" & "¶end tell"

I then specify the Application as Apple Script Utility.

But when I run this nothing happens.

I then tried to run the same thing in AS itself, using real url's instead of the fields, and I get an error saying "Bad name of file".

Does anyone know what I'm doing wrong here?

Link to comment
Share on other sites

I found that when using AS, you have to use :'s instead of /'s. I also added a calc field to add ID number of the file and ".mp3", for the filename, in the field specification to make the whole thing easier to read. So I've now fixed the script to read:

"set the target_URL to " & jotts::listenURL & "¶set the destination_file to " & ""Macintosh HD:Users:jeffrey:Downloads:jotts: & "" & jotts::addmp3 & "¶tell application " & ""URL Access Scripting"" & "¶download target_URL to file destination_file replacing no" & "¶end tell"

This results in the following:

set the target_URL to http://jott.com/JottAudio.ashx?id=somebunchofnumbers

set the destination_file to "Macintosh HD:Users:jeffrey:Downloads:jotts: & "somebunchofnumbers.mp3"

tell application "URL Access Scripting"

download target_URL to file destination_file replacing no

end tell

This still just opens AS Utility and does nothing.

Link to comment
Share on other sites

Ok. Got a little farther still.

So I decided to just run this as Perform AppleScript step.

So I pasted the same thing in as a calculated script:

"set the target_URL to " & jotts::listenURL & "¶set the destination_file to " & ""Macintosh HD:Users:jeffrey:Downloads:jotts: & "" & jotts::addmp3 & "¶tell application " & ""URL Access Scripting"" & "¶download target_URL to file destination_file replacing no" & "¶end tell"

So now I'm getting this:

A ":" can't go after this indentifier.

This occurs in the first use of a field:

jotts::listenURL

So now I'm really confused. There is a way to use a field in a script, yes?

Link to comment
Share on other sites

Ah, no it doesn't. I should have posted my solution.

The answer was to have the path be expressed with ":", which is what AS likes.

Hence, my finished as looks like this, and works perfectly:

"set the target_URL to "" & jotts::listenURL & ""¶set the destination_file to " & ""Macintosh HD:Users:jeffrey:Downloads:jotts:mp3s:" & jotts::addmp3 & "¶tell application " & ""URL Access Scripting"" & "¶download target_URL to file destination_file replacing no" & "¶end tell"

Where jotts::listenURL == "http://jott.com/JottAudio.ashx?id=" & jotts::ID

and jotts::addmp3 == jotts::IDShort & ".mp3""

The final result looks like this:


set the target_URL to "http://jott.com/JottAudio.ashx?id=somebunchofnumbers"

set the destination_file to "Macintosh HD:Users:jeffrey:Downloads:jotts:mp3s:somebunchofnumbers.mp3"

tell application "URL Access Scripting"

download target_URL to file destination_file replacing no

end tell

Link to comment
Share on other sites

This topic is 5307 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.