17

Displays info from iTunes

Posted in Music by auditor 3616 days ago

A iTunes geeklet that will display information in the following way:

Song - Artist (Album) | rating | progress%

screenshot

Please note

The script will automatically open iTunes on boot up, but this means that whenever you close iTunes it will automatically re-open.

Geeklet files to download

Comments

User Avatar
Sinani201 3465 days ago
It works well. Good replacement for those who don't like the mini player.
User Avatar
martizzle 3341 days ago
It won't let geektool run without iTunes running as well. When I close iTunes it starts back up again.
User Avatar
The_RocketRat 3185 days ago
I like the script, but I'd like to display the Trackname, Artist or Album only, and get rid of everything else (especially the track duration).  Everything I try just erases everything.  Any advice?

PS.  I can close Itunes (10) without the script reopening it again.
User Avatar
jcroucher56 2995 days ago
If you just want Trackname - Artistname ( Albumname ), use this code:

#!/bin/sh

if ps x | grep iTunes | grep -q -v grep; then

osascript -e 'tell application "iTunes"

set trackname to name of current track

set artistname to artist of current track

set albumname to album of current track

if albumname is null then

set albumshow to " "

else if albumname is "" then

set albumshow to " "

else

set albumshow to " ( " & albumname & " ) "

end if

set trackduration to duration of current track

set trackposition to player position

set output to "" & trackname & " - " & artistname & albumshow

end tell' | iconv -f utf-8 -t ucs-2-internal

fi
User Avatar
ifuxusux 3099 days ago
I think if you add "tell application "System Events" to set num to count (every process whose name is "iTunes")

if num > 0 then" before the AppleScript code and "end if" after it, it will solve the issue of it keeping iTunes open.
User Avatar
jcroucher56 2995 days ago
Can you explain this a little differently? I don't quite understand. I made a few modifications to the original code. How and where would I put the script that you're talking about? Here's what I've got:

#!/bin/sh

if ps x | grep iTunes | grep -q -v grep; then

osascript -e 'tell application "iTunes"

set trackname to name of current track

set artistname to artist of current track

set albumname to album of current track

if albumname is null then

set albumshow to ""

else if albumname is "" then

set albumshow to "( Unknown )"

else

set albumshow to albumname

end if

set trackduration to duration of current track

set trackposition to player position

set elapsed to round (trackposition / trackduration * 100)

set myRating to round ((rating of current track) / 20)

if myRating is 1 then

set myRating to " | I Star"

else if myRating is 2 then

set myRating to " | II Stars"

else if myRating is 3 then

set myRating to " | III Stars"

else if myRating is 4 then

set myRating to " | IV Stars"

else if myRating is 5 then

set myRating to " | V Stars"

else

set myRating to ""

end if

set myRating to myRating

set output to "" & "Artist: " & artistname & "\n" & "Track: " & trackname & "\n" & "Album: " & albumshow & myRating

end tell' | iconv -f utf-8 -t ucs-2-internal

fi
User Avatar
rvonsch 1852 days ago
Artist - Song (Album) | 25% | ☆☆☆

DATA=$(osascript -e 'tell application "System Events"

set myList to (name of every process)

end tell

if myList contains "iTunes" then

tell application "iTunes"

if player state is stopped then

set output to "Stopped"

else

set trackname to name of current track

set artistname to artist of current track

set albumname to album of current track

set myRating to round ((rating of current track) / 20)

if myRating is 1 then

set myRating to "☆"

else if myRating is 2 then

set myRating to "☆☆"

else if myRating is 3 then

set myRating to "☆☆☆"

else if myRating is 4 then

set myRating to "☆☆☆☆"

else if myRating is 5 then

set myRating to "☆☆☆☆☆"

else

set myRating to ""

end if

set myRating to myRating

set trackduration to duration of current track

set trackposition to player position

set elapsed to round (trackposition / trackduration * 100)

if player state is playing then

set output to artistname & " - " & trackname & " (" & albumname & ") | " & elapsed & "% | " & myRating

else if player state is paused then

set output to artistname & " - " & trackname & " (" & albumname & ") ***PAUSED*** | " & elapsed & "% | " & myRating

end if

end if

end tell

else

set output to "iTunes is not running"

end if')

echo $DATA | awk -F new_line '{print $1}'

echo $DATA | awk -F new_line '{print $2}'

Log in to comment or register here.