-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path10. Set Rating to 2.scpt
More file actions
106 lines (94 loc) · 3.18 KB
/
Copy path10. Set Rating to 2.scpt
File metadata and controls
106 lines (94 loc) · 3.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
-- Set Rating to 2.applescript
--
-- Created by Jacob Rus on 2006-06-02.
-- Copyright (c) 2006. All rights reserved.
on run
tell application "System Events"
if (application processes whose name is "iTunes") is not {} then
my main()
end if
end tell
end run
on main()
registerWithGrowl()
tell application "iTunes" to set rating of current track to 40
showCurrentTrack()
end main
on registerWithGrowl()
set the_notifications to {"Current Track", "Toggle Shuffle", "Toggle Repeat"}
tell application "GrowlHelperApp"
register as application ¬
"iTunes Controller Scripts" all notifications the_notifications ¬
default notifications the_notifications ¬
icon of application "iTunes"
end tell
end registerWithGrowl
on showCurrentTrack()
tell application "iTunes"
-- Set the title of the notification
try
set note_title to name of current track as Unicode text
-- Set the description of the notification
set the_year to " (" & (year of current track as string) & ")"
if the_year = " (0)" then set the_year to ""
set note_desc to my playState() & " " & my ratingStars(rating of current track) ¬
& "\n" & artist of current track ¬
& "\n" & album of current track & the_year
on error
set note_title to "Stopped" as Unicode text
set note_desc to "" as Unicode text
end try
try
set album_art to data of artwork 1 of current track
on error
set album_art to null
end try
end tell
-- Put the notification on the screen
tell application "GrowlHelperApp"
if album_art is not null then
notify with name ¬
"Current Track" title note_title description note_desc ¬
application name ¬
"iTunes Controller Scripts" pictImage album_art
else
notify with name ¬
"Current Track" title note_title description note_desc ¬
application name "iTunes Controller Scripts"
end if
end tell
end showCurrentTrack
on ratingStars(the_rating)
set star_string to "(" as Unicode text
set black_star to «data utxt2605» as Unicode text
set one_half to «data utxt00BD» as Unicode text
set bullet to «data utxt200A00B7200A» as Unicode text
repeat (the_rating div 20) times
set star_string to star_string & black_star
end repeat
if 10 ≤ (the_rating mod 20) then
set star_string to star_string & one_half
end if
repeat (6 - (length of star_string)) times
set star_string to star_string & bullet
end repeat
set star_string to star_string & ")"
-- if the_rating = 0 then set star_string to "(Unrated)"
return star_string
end ratingStars
on playState()
tell application "iTunes"
if player state is paused then
return «data utxt2759200A2759200A200A» as Unicode text
else if player state is playing then
return «data utxt25B6» as Unicode text
else if player state is fast forwarding then
return «data utxt25B625B6» as Unicode text
else if player state is rewinding then
return «data utxt25C025C0» as Unicode text
else
return «data utxt25FC» as Unicode text
--return «data utxt2588» as Unicode text
end if
end tell
end playState