Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Original Copyright © 2011 Alex Sørlie
- -- <http://twitter.com/techie94>
- -------------------------------------------
- -- textual /np script modified to check between spotify and itunes
- -- also modified to take in a value (cmd) if the user wants to show/hide the song info (iTunes only)
- -- (default is to hide it)
- --
- -- Modified By: Steven Saric 28th October 2011
- -- < http://twitter.com/BoomBoxCreation >
- -------------------------------------------
- on textualcmd(cmd)
- set listening to "/debug You dont have any media players open you doof!"
- if application "Spotify" is running then
- tell application "Spotify"
- if player state is playing then
- set theurl to spotify url of the current track
- if theurl contains "track" then
- set realurl to (characters 15 thru 36 of theurl) as string
- else
- set realurl to the theurl
- end if
- set realurl to ("http://open.spotify.com/track/" & realurl)
- set artistinfo to " by " & artist of the current track
- set Albuminfo to ", from the album " & album of the current track
- if cmd is "bitrate" then
- set listening to "/me is listening to \"" & name of the current track & "\"" & artistinfo & Albuminfo & " on Spotify. " & realurl & "[" & time of current track & "]"
- else
- set listening to "/me is listening to \"" & name of the current track & "\"" & artistinfo & Albuminfo & " on Spotify. " & realurl
- end if
- else
- set listening to "/me is not currently playing anything in Spotify"
- end if
- end tell
- else if application "iTunes" is running then
- tell application "iTunes"
- if player state is playing then
- set listening to "/me is listening to "
- if current stream title is not missing value then
- set listening to listening & name of current track & " streaming \""
- set {art, nom} to my text_to_list(current stream title, " - ")
- set listening to listening & art & " - " & nom & "\""
- else
- set the_kind to kind of current track
- set songsize to ((size of current track) / 1048576)
- set songsize to (round (songsize * 100)) / 100
- set movie_list to {"Movies", "TV Shows", "Podcasts", "iTunes U"}
- set movie_kinds to {"MP4", "Movie", "WAV"}
- if the_kind contains "MPEG-3 audio file" then set the_kind to "MP3"
- if the_kind contains "MPEG-4 video file" then set the_kind to "MP4"
- if the_kind contains "QuickTime movie file" then set the_kind to "Movie"
- if the_kind contains "AAC" then set the_kind to "AAC"
- if the_kind contains "WAV" then set the_kind to "WAV"
- if the_kind contains "Apple Lossless" then set the_kind to "Apple Lossless"
- if name of current playlist is in movie_list and the_kind is in movie_kinds then
- set iartist to artist of current track
- if cmd is "bitrate" then
- if length of iartist is 0 then
- set listening to "/me is watching " & name of current track & " [" & time of current track & " mins] [" & bit rate of current track & " kbps " & the_kind & "] [" & songsize & " MB]"
- else
- set listening to "/me is watching " & artist of current track & " - " & name of current track & " [" & time of current track & " mins] [" & bit rate of current track & " kbps " & the_kind & "] [" & songsize & " MB]"
- end if
- else
- if length of iartist is 0 then
- set listening to "/me is watching " & name of current track
- else
- set listening to "/me is watching " & artist of current track & " - " & name of current track
- end if
- end if
- else
- if cmd is "bitrate" then
- set listening to "/me is listening to \"" & name of current track & "\" by " & artist of current track & ", from the album " & album of current track & " on iTunes. [" & time of current track & " mins] [" & bit rate of current track & " kbps " & the_kind & "] [" & songsize & " MB] [played " & played count of current track & " times]"
- else
- set listening to "/me is listening to \"" & name of current track & "\" by " & artist of current track & ", from the album " & album of current track & " on iTunes."
- end if
- end if
- end if
- else
- set listening to "/me is not currently playing anything in iTunes"
- end if
- end tell
- else
- set howToUse to "/debug Usage: \"/np\" , \"np bitrate\"
- /debug If you do \"/np bitrate\" it will show the music info (iTunes only) (play count, song size, bitrate and length)"
- set listening to listening & "
- " & howToUse
- end if
- return listening
- end textualcmd
- -- text_to_list AppleScript function from:
- -- <http://dougscripts.com/itunes/itinfo/locatemf.php>
- on text_to_list(txt, delim)
- set saveD to AppleScript's text item delimiters
- try
- set AppleScript's text item delimiters to {delim}
- set theList to every text item of txt
- on error errStr number errNum
- set AppleScript's text item delimiters to saveD
- error errStr number errNum
- end try
- set AppleScript's text item delimiters to saveD
- return (theList)
- end text_to_list
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement