AppleScript for displaying the currently playing track on FIP Radio in a notification
--Requires Twitter Scripter: http://mousedown.net/mouseware/TwitterScripter.html
--Requires a Twitter account to be set up in System Prefs > Internet Accounts
--Change "your_Twitter_name" in the line below to your Twitter name
--Save as Application and trigger with a keyboard shortcut
tell application "Twitter Scripter"
set fipNow to fetch user timeline for username "FipNowPlays" using account "your_Twitter_name" returning entries 1
set nowPlayingTweet to |text| of item 1 of response of fipNow
end tell
--trim unnecessary bumph
on trim_line(this_text, trim_chars, trim_indicator)
-- 0 = beginning, 1 = end, 2 = both
set x to the length of the trim_chars
-- TRIM BEGINNING
if the trim_indicator is in {0, 2} then
repeat while this_text begins with the trim_chars
try
set this_text to characters (x + 1) thru -1 of this_text as string
on error
-- the text contains nothing but the trim characters
return ""
end try
end repeat
end if
-- TRIM ENDING
if the trim_indicator is in {1, 2} then
repeat while this_text ends with the trim_chars
try
set this_text to characters 1 thru -(x + 1) of this_text as string
on error
-- the text contains nothing but the trim characters
return ""
end try
end repeat
end if
return this_text
end trim_line
set trimStart to trim_line(nowPlayingTweet, "♪ #nowplaying ", 0)
set trimEnd to trim_line(trimStart, " http://t.co/00cY9vXEFF", 1)
set nowPlaying to trimEnd
--return nowPlaying
display notification nowPlaying with title "FIP's now playing"