Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- on zero_pad(value, string_length)
- set string_zeroes to ""
- set digits_to_pad to string_length - (length of (value as string))
- if digits_to_pad > 0 then
- repeat digits_to_pad times
- set string_zeroes to string_zeroes & "0" as string
- end repeat
- end if
- set padded_value to string_zeroes & value as string
- return padded_value
- end zero_pad
- on music_char(seed)
- if seed = 0 then set np_prefix to "♩"
- if seed = 1 then set np_prefix to "♪"
- if seed = 2 then set np_prefix to "♫"
- if seed = 3 then set np_prefix to "♬"
- return np_prefix
- end music_char
- on buildNowPlaying()
- tell application "iTunes"
- set TrackAlbum to album of current track
- set TrackArtist to artist of current track
- set TrackName to name of current track
- set TrackNumber to track number of current track
- set TrackLength to time of current track
- set TrackBitrate to bit rate of current track
- -- Fix the time (current pos)
- set T to player position
- set H to T div 3600
- set S to T mod 3600
- set M to S div 60
- set S to S mod 60
- if M < 10 then set M to "0" & M
- if S < 10 then set S to "0" & S
- -- set CurrentTime to (H as text) & ":" & M & ":" & S
- set CurrentTime to M & ":" & S
- -- Fix the time (duration)
- if (character 2 of TrackLength is ":") then set TrackLength to "0" & TrackLength
- end tell
- return music_char(random number from 0 to 3) & ": " & TrackArtist & " [" & TrackAlbum & "] " & zero_pad(TrackNumber, 2) & ": " & TrackName & " [" & CurrentTime & "/" & TrackLength & "] [" & TrackBitrate & " kbps]"
- end buildNowPlaying
- using terms from application "Colloquy"
- on process user command cmd with args for chatRoom
- if cmd is equal to "np" then
- set nowPlaying to buildNowPlaying() & " " & args
- tell chatRoom to send message nowPlaying to chatRoom with action tense
- return nothing
- end if
- end process user command
- end using terms from
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement