Changeset 211 for trunk/StreamVision/StreamVision.py
- Timestamp:
- 01/29/06 22:59:56 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/StreamVision/StreamVision.py
r200 r211 7 7 from PyObjCTools import AppHelper 8 8 from Carbon.CarbonEvt import RegisterEventHotKey, GetApplicationEventTarget 9 from Carbon.Events import cmdKey 9 from Carbon.Events import cmdKey, shiftKey 10 10 import struct 11 11 import scrape 12 import _StreamVision12 import HotKey 13 13 14 14 GROWL_APP_NAME = 'StreamVision' … … 75 75 def displayTrackInfo(self): 76 76 iTunes = iTunesApp() 77 if iTunes.player_state.get() == k.playing: 78 if iTunes.current_track.class_.get() == k.URL_track: 79 growlNotify(cleanStreamTitle(iTunes.current_stream_title.get()), 80 cleanStreamTrackName(iTunes.current_track.name.get())) 81 else: 82 kw = {} 83 artwork = iTunes.current_track.artworks.get() 84 if artwork: 85 kw['pictImage'] = artwork[0].data.get() 86 growlNotify(iTunes.current_track.name.get() + ' ' + 87 '★' * (iTunes.current_track.rating.get() / 20), 88 iTunes.current_track.album.get() + "\n" + 89 iTunes.current_track.artist.get(), 90 **kw) 91 else: 92 trackName = '' 93 if iTunes.current_track.class_.get() != k.Property: 94 trackName = iTunes.current_track.name.get() 95 growlNotify("iTunes is not playing.", trackName) 77 78 trackClass = iTunes.current_track.class_.get() 79 trackName = '' 80 if trackClass != k.Property: 81 trackName = iTunes.current_track.name.get() 82 83 if iTunes.player_state.get() != k.playing: 84 growlNotify('iTunes is not playing.', trackName) 85 return 86 if trackClass == k.URL_track: 87 growlNotify(cleanStreamTitle(iTunes.current_stream_title.get()), 88 cleanStreamTrackName(trackName)) 89 return 90 if trackClass == k.Property: 91 growlNotify('iTunes is playing.', '') 92 return 93 kw = {} 94 # XXX iTunes doesn't let you get artwork for shared tracks 95 if trackClass != k.shared_track: 96 artwork = iTunes.current_track.artworks.get() 97 if artwork: 98 kw['pictImage'] = artwork[0].data.get() 99 growlNotify(trackName + ' ' + 100 '★' * (iTunes.current_track.rating.get() / 20), 101 iTunes.current_track.album.get() + "\n" + 102 iTunes.current_track.artist.get(), 103 **kw) 96 104 97 105 def goToSite(self): … … 110 118 GetApplicationEventTarget(), 0) 111 119 self.hotKeys.append(hotKeyRef) 112 self.hotKeyActions[ _StreamVision.HotKeyAddress(hotKeyRef)] = func120 self.hotKeyActions[HotKey.HotKeyAddress(hotKeyRef)] = func 113 121 114 122 def incrementRatingBy(self, increment): … … 140 148 self.registerHotKey(lambda: iTunesApp().previous_track(), 109) # F10 141 149 self.registerHotKey(lambda: iTunesApp().next_track(), 103) # F11 142 self.registerHotKey(lambda: self.incrementRatingBy(-20), 109, cmdKey) # cmd-F10143 self.registerHotKey(lambda: self.incrementRatingBy(20), 103, cmdKey) # cmd-F11150 self.registerHotKey(lambda: self.incrementRatingBy(-20), 109, shiftKey) # shift-F10 151 self.registerHotKey(lambda: self.incrementRatingBy(20), 103, shiftKey) # shift-F11 144 152 NSDistributedNotificationCenter.defaultCenter().addObserver_selector_name_object_(self, self.displayTrackInfo, 'com.apple.iTunes.playerInfo', None) 145 153
Note:
See TracChangeset
for help on using the changeset viewer.