Changeset 315


Ignore:
Timestamp:
12/19/06 03:18:14 (18 years ago)
Author:
Nicholas Riley
Message:

StreamVision.py: Added more support for recent appscript versions
(k.Property => k.property). Removed unnecessary .get invocations
since we've dropped support for older appscript versions where it was
required. Robustified RealPlayer support.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/StreamVision/StreamVision.py

    r313 r315  
    4141
    4242def radioParadiseURL():
     43    # XXX better to use http://www2.radioparadise.com/playlist.xml ?
    4344    session = scrape.Session()
    4445    session.go('http://www2.radioparadise.com/nowplay_b.php')
     
    8081        iTunes = iTunesApp()
    8182
    82         trackClass = iTunes.current_track.class_.get()
     83        trackClass = iTunes.current_track.class_()
    8384        trackName = ''
    84         if trackClass != k.Property:
    85             trackName = iTunes.current_track.name.get()
    86 
    87         if iTunes.player_state.get() != k.playing:
     85        if trackClass != k.property:
     86            trackName = iTunes.current_track.name()
     87
     88        if iTunes.player_state() != k.playing:
    8889            growlNotify('iTunes is not playing.', trackName)
    8990            return
    9091        if trackClass == k.URL_track:
    91             growlNotify(cleanStreamTitle(iTunes.current_stream_title.get()),
     92            growlNotify(cleanStreamTitle(iTunes.current_stream_title()),
    9293                        cleanStreamTrackName(trackName))
    9394            return
    94         if trackClass == k.Property:
     95        if trackClass == k.property:
    9596           growlNotify('iTunes is playing.', '')
    9697           return
     
    9899        # XXX iTunes doesn't let you get artwork for shared tracks
    99100        if trackClass != k.shared_track:
    100             artwork = iTunes.current_track.artworks.get()
     101            artwork = iTunes.current_track.artworks()
    101102            if artwork:
    102                 kw['pictImage'] = artwork[0].data.get()
     103                kw['pictImage'] = artwork[0].data()
    103104        growlNotify(trackName + '  ' +
    104                     '★' * (iTunes.current_track.rating.get() / 20),
    105                     iTunes.current_track.album.get() + "\n" +
    106                     iTunes.current_track.artist.get(),
     105                    '★' * (iTunes.current_track.rating() / 20),
     106                    iTunes.current_track.album() + "\n" +
     107                    iTunes.current_track.artist(),
    107108                    **kw)
    108109
    109110    def goToSite(self):
    110111        iTunes = iTunesApp()
    111         if iTunes.player_state.get() == k.playing:
    112             url = iTunes.current_stream_URL.get()
     112        if iTunes.player_state() == k.playing:
     113            url = iTunes.current_stream_URL()
    113114            if url:
    114115                if 'radioparadise.com' in url and 'review' not in url:
     
    132133    def incrementRatingBy(self, increment):
    133134        iTunes = iTunesApp()
    134         rating = iTunes.current_track.rating.get()
     135        rating = iTunes.current_track.rating()
    135136        rating += increment
    136137        if rating < 0:
     
    144145    def playPause(self, useStereo=True):
    145146        iTunes = iTunesApp()
    146         was_playing = (iTunes.player_state.get() == k.playing)
     147        was_playing = (iTunes.player_state() == k.playing)
    147148        iTunes.playpause()
    148         if not was_playing and iTunes.player_state.get() == k.stopped:
     149        if not was_playing and iTunes.player_state() == k.stopped:
    149150            # most likely, we're focused on the iPod, so playing does nothing
    150             iTunes.browser_windows[1].view.set(iTunes.user_playlists[its.name=='Stations'][1].get())
     151            iTunes.browser_windows[1].view.set(iTunes.user_playlists[its.name=='Stations'][1]())
    151152            iTunes.play()
    152153        if HAVE_XTENSION and useStereo:
    153             if iTunes.player_state.get() == k.playing:
     154            if iTunes.player_state() == k.playing:
    154155                XTensionApp().turnon('Stereo')
    155156            else:
     
    161162        if frontName == 'RealPlayer':
    162163            realPlayer = app(id='com.RealNetworks.RealPlayer')
    163             if realPlayer.players[0].state.get() == k.playing:
    164                 realPlayer.pause()
    165             else:
    166                 realPlayer.play()
     164            if len(realPlayer.players()) > 0:
     165                if realPlayer.players[1].state() == k.playing:
     166                    realPlayer.pause()
     167                else:
     168                    realPlayer.play()
     169                return
    167170        elif frontName == 'VLC':
    168171            app(id='org.videolan.vlc').play() # equivalent to playpause
Note: See TracChangeset for help on using the changeset viewer.