hello all,
i have augmented a script i found to post spotify information into colloquy IRC.
right now it works, but the URL it posts as output is too long, i would like to use the sptfy.com API to shorten it.
how is/could this done in applescript?
here is the script in question, feel free to tear it apart, im a total n00b at this.
(*
Created by Tim Andersson (http://www.cocoabeans.se).
Augmented by Alex Herron
If you redistribute the script, please give credit where it is due.
This script requires Spotify >= 0.5.1
To install it, place it in ~/Library/Application Support/Colloquy/PlugIns
and then type "/reload plugins" in Colloquy.
To use it, type /spotify
*)
using terms from application "Colloquy"
on process user command cmd with arguments for view
if cmd is equal to "spotify" then
if application "Spotify" is running then
tell application "Spotify"
set is_playing to (player state is equal to playing)
set is_paused to (player state is equal to paused)
set has_played to (played count of current track > 0)
if player state is not equal to stopped then
set track_artist to artist of current track
set track_name to name of current track
set track_album to album of current track
set track_plays to played count of current track
set track_duration to duration of current track
set track_minutes to (track_duration div minutes)
set track_seconds to (track_duration mod minutes)
end if
if track_seconds < 10 then
set track_seconds to "0" & track_seconds
set output_time to track_minutes & track_seconds as text
else
set output_time to track_minutes & track_seconds as text
end if
set AppleScript's text item delimiters to ":"
set track_uri to spotify url of current track
set track_id to text item 3 of track_uri
end tell
if is_playing and has_played then
set info_string to "is listening to " & track_name & " by " & track_artist & " from the album " & track_album & " [" & output_time & " - Plays: " & track_plays & " ]" & " (http://open.spotify.com/track/" & track_id & ")"
tell view to send message info_string encoded as UTF8 with action tense
else if is_playing then
set info_string to "is listening to " & track_name & " by " & track_artist & " from the album " & track_album & " [" & output_time & "]" & " (http://open.spotify.com/track/" & track_id & ") "
tell view to send message info_string encoded as UTF8 with action tense
else if is_paused then
tell view to add event message "Spotify is paused dummy."
else
tell view to add event message "You're not playing anything in Spotify dummy."
end if
else
tell view to add event message "Spotify isn't running."
end if
end if
end process user command
end using terms from