Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Fix for Internet Radio Dropouts: AppleScript and Crontab' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Fix for Internet Radio Dropouts: AppleScript and Crontab
Authored by: taaminator on Jan 21, '11 10:37:37AM

Living in the uninhabited third world, drop out is a real and present problem. Fixing drop out can be a solution of Applescript and crontab.

From Doug's Applescripts:

tell application "iTunes"
if player state is stopped then play
end tell

Save that Applescript as iTunesBangThePipeStart.app or something you prefer. Save it to the iTunes Scripts folder (~/Library/iTunes/Scripts). Note: A helpful technique is to name scripts with the format (application)(function)(action). In this case, (iTunes)(BangThePipe)(Start)

Create a crontab to run the script every minute when you want iTunes to play:

# Minute Hour Day of Month Month Day of Week Command
# (0-59) (0-23) (1-31) (1-12 or Jan-Dec) (0-6 or Sun-Sat)
* 7-8 * * 1-5 /usr/bin/open /Users/(username)/Library/iTunes/Scripts/iTunesBangThePipeStart.app # Comment: If iTunes stopped then play every minute from 0700-0859, M-F

Now, the secret to not going insane: STOP the player

tell application "iTunes"
stop
end tell

0 9 * * 1-5 /usr/bin/open /Users/(username)/Library/iTunes/Scripts/iTunesBangThePipeSTOP.app # Comment: Stop iTunes 0900 M-F

Advanced:

Copy and rename the iTunes audio stream to something very simple -- without spaces.

MorningMetal.m3u

Select it.

File - New Playlist from Selection

Name the new Playlist something very simple -- without spaces.

MorningMetal

tell application "iTunes"
play track "MorningMetal.m3u" of playlist "MorningMetal"
end tell

Save that as an application: iTunesMorningMetal.app

Add to crontab

# Minute Hour Day of Month Month Day of Week Command
# (0-59) (0-23) (1-31) (1-12 or Jan-Dec) (0-6 or Sun-Sat)
59 6 * * 1-5 /usr/bin/open /Users/(username)/Library/iTunes/Scripts/iTunesPlayMorningMetal.app # Comment: Play MorningMetal at 0659
* 7-8 * * 1-5 /usr/bin/open /Users/(username)/Library/iTunes/Scripts/iTunesBangThePipeStart.app # Comment: If iTunes stopped then play
0 9 * * 1-5 /usr/bin/open /Users/(username)/Library/iTunes/Scripts/iTunesBangThePipeSTOP.app # Comment: Stop iTunes 0900 M-F

Summary: Tell iTunes to start playing MorningMetal at 0659, Monday through Friday. Check iTunes every minute, M-F, and, if it's not playing, play. Tell iTunes to stop playing at 0900, M-F.

Audio Streaming Delay Note: Pad your cron. Some audio streams take a few moments to load, initialize, resolve, fight their way through Flash, etc. If you don't want to miss any of your program, schedule the stream to start a couple of minutes before the program's scheduled start. Similarly, some streaming audio programs are significantly delayed. Schedule the stream to start a couple of minutes after the program's scheduled end.

# Minute Hour Day of Month Month Day of Week Command
# (0-59) (0-23) (1-31) (1-12 or Jan-Dec) (0-6 or Sun-Sat)
57 6 * * 1-5 /usr/bin/open /Users/(username)/Library/iTunes/Scripts/iTunesPlayMorningMetal.app # Comment: Play MorningMetal at 0657
* 7-8 * * 1-5 /usr/bin/open /Users/(username)/Library/iTunes/Scripts/iTunesBangThePipeStart.app # Comment: If iTunes stopped then play
3 9 * * 1-5 /usr/bin/open /Users/(username)/Library/iTunes/Scripts/iTunesBangThePipeSTOP.app # Comment: Stop iTunes 0903 M-F

A final note: Sometimes iTunes buffers. Buffering state is not in the iTunes AppleScript Library. Sometimes BangThePipe fails if iTunes hangs in a buffering state. Apple 'knows' that buffering is not in the library.



Be very careful! When iTunes starts playing of its own free will --

-- it's probably your cron.

HTH.





Now, can someone please help me script RealPlayer?



[ Reply to This | # ]