Bonus How-To: Use DittyBot and Skype to access your iTunes collection from any cellphone
As some of you probably already know, I've been guest-hosting G4's Attack of the Show this past week. I won't get into the gory details of how I forever shamed myself during my time on the show (you'll have to come to our reader meetup for that), but one of the best things I saw all week was DittyBot, a little something something Scott Moschella (one of the show's segment producers) cooked up that lets you remotely listen to your iTunes collection using your cellphone. Ok, so maybe yesterday's live on-air demo didn't go as smoothly as it did during rehearsal, and DittyBot isn't actually digitally streaming your music collection like with Shoutcast or Orb or whatever, but it's a damn clever trick (even if the audio quality isn't so hot) that works on nearly any cellphone, and so we had no choice but to "persuade" Scott to let us republish his DiddyBot tutorial here on Engadget.
DittyBot is an Apple Automator Workflow mixed with some Applescript. I can't code Applescript all that well, so I'm certain the Applescript coders will suggest some code fixes so that it isn't so messy. Please post any suggestions, additions, or fixes in the comments. Thanks!
Laugh all you want about the name DittyBot, but it was one of the only ways of me getting a domain name for it ahead of time. I might not need it, but at least it's there. Also, what's wrong with the name DittyBot?
If you want to use DittyBot on your Mac, make sure you read through this entire article so that DittyBot works properly. And hopefully along the way, you'll learn a little more about the simplicity and power of Automator and Applescript.
What DittyBot Does:
You send a text message from your mobile phone to your POP email account. Your text message should contain the
keywords of a song title (and possibly an artist name) that you want to hear. DittyBot finds that email (he checks Mail
every 45 seconds) and copies the song name into a text file. The song name is then copied into iTunes and a playlist is
created from your search. Next, DittyBot loads Skype (the internet telephony app) and begins calling your mobile phone.
Your mobile phone rings and when you pick it up, you should hear your song start playing in all its compressed glory.
DittyBot will play your selection to you over your phone until you hang up. Mind you, this all should happen within 1
minute of sending your song request (depending on the speed of your POP server). Sometimes it's even quicker!
That wasn't so hard now, was it?
Sure, this is silly. However, it's only a small demonstration of the power of Applescript. DittyBot's ability to
juggle all these apps should give the tinkerers out there yet another reason to consider buying an Apple.
Before you can start using DittyBot to play iTunes songs through your cell phone, there's a decent amount of setup
involved. So pay attention.
Setting Up DittyBot:
For those of you without a traditional POP email account, here's instructions for setting up Gmail for POP access.
Yahoo offers a pay-for POP account, as does Hotmail. Mail.app must be configured to work with your POP (or IMAP)
account. Note, this is not your cell phone's email address that we're talking about. You must have an email account set
up to receive email sent from your cell phone.
Here's my mail setup. I have digitally removed my password from the dialog box for security purposes, but you'll have
to put yours in there.
You're going to need a couple more things:
- A Skype account with SkypeOut so your computer can call actual telephones. This costs money, but not much. I spent $12 US for about 600 minutes. Skype now accepts PayPal, which makes the process super-easy. There's never been a better (or geekier) reason to have a SkypeOut account.
- You also need OS X running Tiger. Sorry, but right now Applescript and Automator are the only way I could think of for making this work. Consider this a challenge to the Windows and Linux community. I know it's possible to do under Windows (and Linux for that matter), but I also know it's not this easy. Prove me wrong!
Okay, you've got all that. Now what?
Well, you need to:
- Download and install Soundflower. It's a free application that reroutes your system's audio and ultimately tricks Skype into thinking that your Mac's audio output is a microphone input. Essentially, Skype thinks the audio coming from iTunes is coming from a non-existent microphone.
- It should also be apparent that you'll need the latest version of Skype for OS X Tiger. I scripted DittyBot to
work with the official release of Skype (1.0.0.24), not the beta. So I recommend that you avoid using the beta
version of Skype.
After you install Soundflower, open System Preferences and then open the Sound pane. Make your Sound pane's Input
and Output tabs look like the image on the left. Soundflower is not a stand-alone app. Instead it installs as a System
Preferences element and runs all the time. You can always change your inputs and outputs back to normal. Once you
change the Sound pane to match the image, you will no longer hear any sound coming from your computer. Note that this
will be true only when the input and output in the Sound pane are both Soundflower. However, this sound setup is
necessary in order for Skype to pipe iTunes through to your phone.
Keep the System Preferences window open and click Show All and in the System category. Then, click Universal Access.
At the bottom of the Universal Access window, enable the check box next to Enable access for assistive devices. This
must be enabled so that Applescript has the ability to press buttons inside of Skype.
You'll also need to download the DittyBot dmg file
(300K) that contains the DittyBot workflow, DittyBot Activator, and the readme.txt. Move or copy DittyBot.workflow to
the root directory on your Hard Drive. Root is your top level folder and contains all the other folders on your hard
drive. Simply double-click the hard drive icon on your desktop and copy or move DittyBot.workflow there. I couldn't
figure out a better place to put it and the way DittyBot is written, the workflow file must be in your root
folder.
The Applescript program called DittyBot Activator can be run from anywhere on your computer. When DittyBot is
activated, he creates a text file in your root directory called requested_song.txt. You can change the location of this
text file by editing Action #5 in DittyBot.workflow.
You're not done yet. You need to add an empty playlist to iTunes and call it DittyBot. And finally, you need to edit
one of the Automator actions and the Applescript inside the DittyBot.workflow. This is much easier than it sounds. Just
run Automator (located in your Applications folder) and open the DittyBot workflow. We'll go through the items you need
to change step-by-step.
Action #3 is Find Messages in Mail. Put your mobile phone's email address in the blank box next to the line that says
Sender Contains. This way, DittyBot knows how to find text messages (song requests) that you send from your mobile
phone.
Action #7 is Run Applescript. This is the heart of DittyBot. There's a few things here you need to edit.
Look for the line that says delete (every message in inbox whose sender is and add your mobile phone's email address
in between the quotes. Make sure you don't delete the quotation marks.
On the line that says delete (every message in trash mailbox whose sender is and add your mobile phone's email address
in between the quotes. Again, don't delete the quotes.
In the Skype section, look for the line that starts with set value of text field 1 of window 1 to and add your cell
phone number (with area code) after the plus sign. I would also recommend starting the phone number with 1. So, my fake
number would be +12125551212.
By now, you know that DittyBot finds your song requests by reading your emails. However, he needs to know which line
of your email contains your song request. This will normally be line ten. If however your mail is different (I could
only test this with my cell phone), you need to count how many lines down your song request is. If you need to change
this number, edit the lines that say set song_letters to the count of the characters of (paragraph 10 of the front
document) AND set songName to characters 1 through (song_letters - 1) of (paragraph 10 of the front document) as text.
Change the 10s to whatever line number your song request falls on inside song_request.txt. Take a look at the second
image below for clarification.
The curious-types out there are probably wondering what we just did. Briefly, we added your email address in Action #3
so that DittyBot knows to only look for email coming from your cell phone. We again added your phone's email address to
Action #7 so that DittyBot removes the email from your Inbox and permanently deletes it. The first line sends it to the
trash, the second deletes it from the trash. A WORD OF CAUTION: If you regularly send notes from your cell phone to
your computer via text messaging, DittyBot will delete them! He's smart enough to know not to delete any old emails
from your cell phone or emails from other people, but ones you send from your phone to your computer on the days
DittyBot is running will be permanently deleted. This isn't a problem with song requests however, we want those to be
deleted after DittyBot reads them.
We also added your mobile phone number to the Skype section of Action #7 so that Skype knows which number to call back
with the requested song.
That's all there is to it. Just save the DittyBot workflow and make sure it's in your root directory. To run DittyBot,
all you have to do is run the Activate DittyBot application. You'll see the workflow running up in your menu bar with a
red stop sign next to it. You can stop the workflow by pressing that red stop sign. However, to stop DittyBot entirely,
you'll have to give the three finger salute. This means, you can only quit DittyBot by pressing Command+Option+ESC
(this is equivalent to Windows' Ctrl+Alt+Delete). Select DittyBot Activator and press Force Quit. I did say that I
wasn't very good at Applescripting, didn't I?
Requesting a Song:
To send a song request you'll have to compose a text message from your cell phone and make the recipient an email
address instead of a cell phone number. I send song request text messages from my cell phone to my plasticbugs.com
email address. Almost any phone with text messaging capabilities can do this. Just keep an eye on how many requests you
send. I can only send 100 text messages a month before incurring overage fees, But DittyBot is so darn entertaining
that in one day I sent him 15 requests. Trust me, it's easy to do.
When requesting a song, you should only include as many keywords as you need. Because DittyBot uses iTunes' search to
find song matches, you do not need complete song names and capitalization does not matter. For example, if I want to
hear Ring of Fire by Johnny Cash, I send a text message to my email account that says ring fire cash. That way, it will
only play Johnny Cash's version of Ring of Fire and not Social Distortion's cover of Ring of Fire. I include just
enough keywords to get me one or two matches.
If more than one song matches your search terms, your playlist will contain all of those songs and iTunes will play
them in the order that they were added. However, if you have every Beatles album and just send a text message that says
beatles, iTunes will try to add every matching song to the DittyBot playlist. This will cause the script to take too
long and ultimately iTunes will not play the playlist at all. You'll still get a phone call, but you will only hear
silence. I've found that the most songs that I could match before DittyBot crapped out was around eight. You can make
this number higher by changing the delay times inside Action #7, but this will ultimately cause DittyBot to call you
back that much later.
Just think of the contents of your text message as what will be typed into iTunes' search window.
Good searches: buffett margar will get you Margaritaville by Jimmy Buffett - clash rudie calling will get you Rudie
Can't Fail by The Clash on the album London Calling Bad searches: any request that will match more than eight
songs
When DittyBot is running, he will check for emails from your phone every 45 seconds. If he doesn't find one, he will
still execute other portions of the script. However, he will not call you and he will not play any songs. Instead,
you'll briefly receive an Applescript error that you can ignore (further evidence that my Applescript skills need
help). The error message will go away after a couple of seconds. In a few more seconds, DittyBot will check your email
again and the cycle will repeat.
It's best to test DittyBot when you're in front of the computer so you can diagnose any problems before you let him
run while you're out.
To uninstall DittyBot, just delete the DittyBot workflow, DittyBot Activator, & the requested songs.txt file.


















Reader Comments (Page 1 of 1)
burch @ Dec 19th 2005 12:16AM
wow! first post again I love engadget
Guilherme Pinto @ Dec 19th 2005 12:16AM
This can easly be made on windows, im corrently searching for a way to interact with skype using a custom built application.
This custom built application will do everything the MAC does up to the skype part, such as, check mail, search for song, play song (might not be on itunes, but its a start) And after these steps, if i find a way to interact with Skype, It will call you while the song is playing.
mveloso @ Dec 19th 2005 12:16AM
That is totally cool!
One more step towards a TRL live style radio station. How about that?
Guilherme Pinto @ Dec 19th 2005 12:16AM
This can easly be made on windows, im corrently searching for a way to interact with skype using a custom built application.
This custom built application will do everything the MAC does up to the skype part, such as, check mail, search for song, play song (might not be on itunes, but its a start) And after these steps, if i find a way to interact with Skype, It will call you while the song is playing.
Jake T @ Dec 19th 2005 12:16AM
YEEEEEEAAAAAAAAAHHHHHHHHH!!!
Jonathan @ Dec 19th 2005 12:16AM
Why does ditty bot's mouth look like he's trying to goatse us?
mveloso @ Dec 19th 2005 12:16AM
Hey, does this mean that you're now PhoneCasting?
/groan
You could dial into a party line/teleconference/call in radio show, and have iTunes automatically play annoying noises!
Behold, the power of iTunes!
Phil Bertz @ Dec 19th 2005 12:16AM
Totally bitchin'... I can't wait to screw with my friends by using this...
"Can I borrow your phone? I need to send a quick text message." Followed by a return call from Sir Mix-a-Lot. Good stuff.
Tim @ Dec 19th 2005 12:16AM
You could totally use this to schedule "data bail out calls" Set it up so if you don't receive a text by X PM to call you and claim to be an emergency. Or you could set up some pranks. Record some mp3's of celebrity's voices and such and fake calls with your friends. Nice.
jimmy @ Dec 19th 2005 12:16AM
goatse? could be worse, how about a tubgirl?
seriously, this is cool though.
Tidal @ Dec 19th 2005 12:16AM
/groan attack of the show
bring back the screen savers
Carl @ Dec 19th 2005 12:16AM
lol Jake you beat me to it... peter should link to the many soundboards out there now complete with "yeaAHHHHHHHHHHHHHHHhhhhhhhhhhh" lolol
Anon @ Dec 19th 2005 12:16AM
Tidal, I totally agree... G4 is nothing but crap, and now its not just good stuff tainted with crap, its total crap, by the fact that Kevin R. left.... anyway I went and found the soundboard for the people who dont watch AOTS, (man i miss screen savers) http://peteryeah.ytmnd.com/
ryan @ Dec 19th 2005 12:16AM
anyone else think the logo designer went to the goatse site?
Feross @ Dec 19th 2005 12:16AM
I watched the Attack of the Show yesterday and saw this! I thought that it was pretty cool, except when they showed it on air, there was an AppleScript Error, and the host of the show actually had to click on the song to get it playing!!
Feross
i am a google whore: spamfeross@gmail.com
John @ Dec 19th 2005 12:16AM
Very cool, I love it when ideas fuse together and form new things. Sure, you might kill your Skipe time pretty fast but if you just have to hear a podcast and your without the 'net this is perfect.
gunboy @ Dec 19th 2005 12:16AM
I use something similar to send stickies from my psp to my powerbook. It uses the same basic principle in applescript (copy and paste), but through a website instead of email. I bet the code can be used to improve dittybot.
here's the file:
http://tinyurl.com/b5txn
Adam @ Dec 19th 2005 12:16AM
well, im getting an applescript error, and when dittybot finally calls me he doesnt play the song :(.besides that, i think i might try to make dittybot so that you can send a text from any cell phone to him... maybe make it so the subject has to be dittybot. good idea?
adam
John Soliman @ Dec 19th 2005 12:16AM
I use a program called orb, which lets me stream my computer audio and video to my phone, pocket pc, or another pc. The only thing is that the host and the client must both be connected to the internet and the client must have a media player. I currently have tried it on my Sprint cell phone which is a sanyo mm-7400 and it is very successful (you do need to have Pcs vision for it to work on a sprint phone). I can now watch full length movies on my phone and listen to all of my music. Its like a virtual ipod that uses my computer hard drive.
Im not sure of the website, just google it. It was also one of pc world's top 100 this year
mumbles @ Dec 19th 2005 12:16AM
burch, how d'you always scoop me for the first post? dammit!
and speakin of Orb and Skype in the same breath - just found a way to get Skype voicemails from my cellphone: i added my voicemail folder to Orb.
since i'm using SAM (http://www.freewebs.com/skypeansweringmachine/index.htm), the folder's just C:/My Documents/My Recorded Messages, though at some point i'll maybe write my own (using this niftyness here: http://www.skypejournal.com/blog/archives/2005/04/skype_journal_g.php#guide) and the folder'll be something else.
Damindu @ Dec 19th 2005 12:16AM
Hi guys, I just thought I'd write this short tutorial on how to setup a internet radio station at home. Then, all u have to do is tune into YOUR OWN radio through ure mobile phone to listen to ure mp3 collection.
http://damindu.tripod.com/radio.htm