home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2009 June / maximum-cd-2009-06.iso / DiscContents / digsby_setup.exe / lib / plugins / nowplaying / itunes_win.pyo (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2009-02-26  |  1.8 KB  |  59 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.5)
  3.  
  4. import threading
  5. from nowplaying import ComSongChecker, register
  6.  
  7. class iTunesSongChecker(ComSongChecker):
  8.     PROCESS_NAME = u'iTunes.exe'
  9.     COM_NAME = 'iTunes.Application'
  10.     app_name = 'iTunes'
  11.     name_id = 'itunes_win'
  12.     
  13.     def _currentSong(self):
  14.         import comtypes
  15.         
  16.         try:
  17.             song = self.client.CurrentTrack
  18.         except comtypes.COMError:
  19.             e = None
  20.             ecode = e.args[0]
  21.             if ecode == -2147418111:
  22.                 return getattr(self, '_lastsong', None)
  23.             elif ecode == -2147417848:
  24.                 self._release()
  25.                 return None
  26.             elif ecode == -2147221008:
  27.                 comtypes.CoInitializeEx()
  28.                 return getattr(self, '_lastsong', None)
  29.             else:
  30.                 raise e
  31.         except:
  32.             ecode == -2147418111
  33.  
  34.         if song is None:
  35.             thissong = None
  36.         elif bool(self.client.PlayerState):
  37.             pass
  38.         
  39.         thissong = dict(status = 'stopped', title = song.Name, filename = song.Name, length = song.Duration, artist = song.Artist, playlist_position = song.Index, rating = song.Rating, size = song.Size)
  40.         self._lastsong = thissong
  41.         return self._lastsong
  42.  
  43.  
  44. register(iTunesSongChecker)
  45. if __name__ == '__main__':
  46.     from time import clock
  47.     before = clock()
  48.     checker = iTunesSongChecker()
  49.     print 'here1'
  50.     checker.get_instance()
  51.     print 'here2'
  52.     info = checker._currentSong()
  53.     duration = clock() - before
  54.     from pprint import pprint
  55.     pprint(info)
  56.     print 
  57.     print 'duration', duration
  58.  
  59.