Jump to content

iTunes now playing workflow?


Recommended Posts

Does anyone have a workflow that can output what is current playing in iTunes into Twitter/Facebook? Done a quick search and cannot find anything...

 

I have this code I use with NerdTool (for streaming radio) so can I use this to pipe what I want to Tweetbot for example?

 

# ITUNES CURRENT MUSIC

# ROBERT WOLTERMAN (xtacocorex)

# I MODIFIED THIS FROM SOMEWHERE ON THE INTERNETS, BUT CANNOT REMEMBER WHERE

# THIS CODE WORKS IF YOU ARE LISTENING TO AUDIO FILES OR WEB STREAMS THROUGH ITUNES

 

# CHECK TO SEE IF ITUNES IS OPEN

tell application "System Events" to set iTunesIsRunning to (name of processes) contains "iTunes"

if iTunesIsRunning is false then

return "iTunes is not open"

end if

# DON'T REMEMBER WHAT THIS IS FOR

tell application "System Events"

set powerCheck to ((application processes whose (name is equal to "iTunes")) count)

if powerCheck = 0 then

return ""

end if

end tell

# GLOBAL VARIABLES

set newline to "

" as text

set header to "Now Playing" as text

# DO STUFF IF ITUNES IS OPEN

if iTunesIsRunning is true then

tell application "iTunes"

# GET INFORMATION WE NEED

set theURL to the current stream URL as text

set theStream to the current stream title as text

if player state is playing then

# WE ARE LOOKING AT A MUSIC FILE

if theURL is "missing value" and theStream is "missing value" then

# WE HAVE A FILE, SO SET BOOLEAN APPROPRIATELY

set haveFile to true

# GET THE TRACK DATA

set sartist to artist of current track

set strack to name of current track

set salbum to album of current track

else

# WE ARE LOOKING AT A MUSIC STREAM

# SET THE haveFile BOOLEAN APPROPRIATELY

set haveFile to false

# GET THE TRACK DATA

set stitle to current stream title as text

set sname to name of current track

set scategory to category of current track

# UNSURE IF scategory HAS VALUE SO CHECK AND SET AS NEEDED

if scategory is "missing value" then

set scategory to ""

end if

set sdesc to description of current track

# UNSURE IF sdesc HAS VALUE SO CHECK AND SET AS NEEDED

if sdesc is "missing value" then

set sdesc to ""

end if

if theStream contains "back soon" then

set theStream to ""

end if

end if

end if

# IF WE'RE PAUSED, UPDATE THE FOOTER VARIABLE

if player state is paused then

set footer to " / paused" as text

else if player state is stopped then

# IF WE'RE STOPPED, UPDATE THE FOOTER VARIABLE

set footer to " / stopped" as text

else

# SET TO NOTHING AS IT'S PLAYING

set footer to "" as text

end if

 

# SET THE INFORMATION TO BE DISPLAYED

if haveFile then

# INFO FOR THE FILE

set info to strack & " " & sartist & " " & salbum & footer as string

else

# INFO FOR THE STREAM

if theStream is "missing value" then

set info to sname & ": " & sdesc & footer as string

else

set info to sname & ": " & theStream as string

end if

end if

# RETURN info TO BE DISPLAYED

return info

end tell

end if

 

Thanks

Edited by gr4z
Link to comment

Does anyone have a workflow that can output what is current playing in iTunes into Twitter/Facebook? Done a quick search and cannot find anything...

 

I have this code I use with NerdTool (for streaming radio) so can I use this to pipe what I want to Tweetbot for example?

 

Thanks

 

Facebook I don't know but the AlfredTweet workflow for Alfred 2 will allow you to tweet the currently playing song in iTunes and several other apps.

Link to comment

So it does - my bad! Thanks David. 

 

Just tried to edit the playing.php to change the '#alfredtweet' to '#nowplaying', as soon as you remove it and save the file, the script no longer works. Weird. Why would that be?

Edited by gr4z
Link to comment

So it does - my bad! Thanks David. 

 

Just tried to edit the playing.php to change the '#alfredtweet' to '#nowplaying', as soon as you remove it and save the file, the script no longer works. Weird. Why would that be?

 

Did you verify that AlfredTweet was working before? Have you authenticated to Twitter?

Link to comment

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...