21 April 2008 @ 10:50Recording MP3 streams with Applescript

The other day when Ralph Bakshi was scheduled to be interviewed on WNYC, it prompted me to try to find a way to record the MP3 stream while I was away.

The basis of my Applescript was the following curl command:

curl -A "Mozilla/4.0" http://wnycfm.streamguys.com/ -o ~/Desktop/wnyc.mp3

I have yet to figure out how to get the Applescript to look at the iCal event it is attached to in order to find when it should end the curl process. I don’t even know if this is possible. As of right now, I have an Applescript that requires user interaction when launched to obtain the duration and url of the stream. Of course, in its current state it is unfit to be attached to an iCal event.

property stream_url : ""
property duration : ""
set timestamp to (do shell script "date " & "+%H%M_%m_%d_%Y")
display dialog "Enter the URL for the stream" default answer stream_url
set the stream_url to text returned of result
display dialog "Enter the duration in seconds" default answer duration
set the duration to text returned of result
do shell script ("curl -A \"Mozilla/4.0\" " & stream_url & " -o ~/Desktop/stream_" & timestamp & ".mp3 &> /dev/null & echo $!")
set pid to the result
do shell script "sleep " & duration & "; kill " & pid

One somewhat clumsy way of doing this would be to have two separate Applescripts — one to start the recording and one to end the recording, but adding and maintain these events would sure be a pain.

If anyone out there knows how to have the script that is attached to an event access the end time and description of the event, I would love to know. It would go something like this: have a script that is attached to an iCal alarm, and have this script get the uid of the event that opened the script. Then have the script look at the end time of the event and calculate the duration of the recording, and get the url of the stream out of the description.

by Jon | Add a comment | Tags: applescript, curl, music


21 April 2008 @ 6:43Camino no longer accepts the Applescript ‘get URL’

I just noticed this today when one of my scripts was broken. Apparently from Camino 1.5 to 1.6 the open URL and the get URL commands were dropped and replaced by open location. If you have any uncompiled Applescripts using the open URL or the get URL commands, you should make the change to open location.

Note: compiled Applescripts that use either of the old commands should still work.

Update:
In my testing, the problem with using the old syntax only exhibits itself when using osascript from the command line. Using “Get URL” in the Script Editor still seems to work.

The syntax on the command line should look like this:

osascript -e 'tell application "Camino"' -e 'open location "http://geek.thinkunique.org"' -e 'end tell'

by Jon | Add a comment | Tags: applescript

4 September 2007 @ 17:45Make an mp3 out of your video

Have you ever wanted to make mp3’s out of your videos (e.g. music videos) so you can load the audio onto your iPod or listen to it in your favorite music player?

This simple Applescript droplet will do just that. Drop your video onto the Video to mp3.app icon, type in the desired bitrate, and it will immediately start converting the first audio track to a mp3. Give it a try. It works with many different video formats including VOB.

Video to mp3.app (video_to_mp3.zip)

Read the rest of this entry »

by Jon | 2 comments | Tags: applescript, dvd, ffmpeg, itunes, music

25 July 2007 @ 11:33Say it ain’t so!

UneeTee WINNING Design! We Ship World WideYou know the annoying “You’ve got mail!” that AOL says when, of course, you’ve (you, not me) got mail?

I was setting up Mail.app on a user’s new laptop one day, when she asked me if it would say “You’ve got mail!” when she gets new mail. Ugh. I told her no, but that I might be able to make it do that. So here is an Applescript that will save to file whatever text you enter, in whatever voice you choose.
Read the rest of this entry »

by Jon | 2 comments | Tags: applescript, email, speech

17 July 2007 @ 12:02DVD Image Utility

Do you need to create a DVD image of a movie you made? Do you need to image and burn a copy of a DVD from your DVR? There are a lot of uses for this simple droplet which uses mkisofs for its imaging. A co-worker of mine found it useful for duplicating home videos that his wife is burning with a DVR.

My initial reason for creating DVD Image Utility was because I needed a method to burn some DVD compliant discs without having to buy a third-party application, such as Toast. Unfortunately, the Mac’s built-in hdiutil will not create a DVD compliant image. Once the resulting image was burned to a DVD-R, it would not play in all DVD players. The same DVD created and burned with DVD Image Utility has played in all DVD players that I have had the opportunity to try.

Read the rest of this entry »

by Jon | 4 comments | Tags: applescript, dvd, mkisofs

11 July 2007 @ 23:06Family Jewels

Wanna download all 702 pages of the CIA’s recently declassified historical documents known as the “Family Jewels”? Then cURL is your friend.

Read the rest of this entry »

by Jon | Add a comment | Tags: applescript, automator, curl, graphicconverter

19 January 2007 @ 12:40Rounding to the nearest even number

I was looking for a way to have an AppleScript round a number to the nearest even, whole number. I did some googling and found some examples of rounding with AppleScript, but I had to modify them to do exactly what I wanted. Here is what I came up with:

property this_number : ""
display dialog “Enter a number” default answer this_number
set the this_number to text returned of result
set rounded to (round (this_number) rounding up)
if rounded mod 2 is not 0 then
set evenNum to (rounded - 1)
else
set evenNum to rounded
end if

by Jon | Add a comment | Tags: applescript, rounding

12 January 2007 @ 16:59AppleScript and video transcoding

I know there are solutions out there for video transcoding such as the awesome ffmpegX, but I wanted to make my own solution. I drop my source video onto this droplet, and with just a few button clicks, I can convert almost any video to an mpeg2 that is DVD compliant. What I did here was make an AppleScript droplet which is an application bundle and contains the binaries, ffmpeg, pulldown, and mplex. Pulldown and mplex are necessary if you are starting with a 23.98fps source and want to keep it at that rate.

Read the rest of this entry »

by Jon | Add a comment | Tags: applescript, ffmpeg, mac, mplex, pulldown, transcode, video

Sign up for PayPal and start accepting credit card payments instantly.

Get fed!

rss icon subscribe to Geek stuff

rss icon Geek stuff in your inbox

Add the "Geek stuff" Google Gadget to your homepage

Add the "Daily Deals" Google Gadget to your homepage

Featured Tee

UneeTee.com

One Day, One Artist, One cool T-shirt

Lusus Naturae by Budi Satria
Guys - $12
Girls - $12

Apparel

Search Amazon

Search Amazon.com
Search Amazon.co.uk

Advert

Web hosting by ICDSoft