Accessing iTunes with Python via the Windows SDK

Denrael learned at gmail.com
Thu May 24 00:23:56 EDT 2007


I've been playing with the iTunes sdk on windows, and have come across
a strange problem.  With the following code:

import win32com.client
iTunes = win32com.client.gencache.EnsureDispatch("iTunes.Application")
curr = iTunes.CurrentTrack
name = curr.Name
skipped = curr.SkippedCount
skipdate = curr.SkippedDate
print name
print skipped
print skipdate

I get an error indicating that SkippedCount isn't a valid attribute:

File "C:\bin\skiptest.py", line 5, in <module>
skipped = curr.SkippedCount
File "C:\Python25\Lib\site-packages\win32com\client\__init__.py", line
454, in
__getattr__
raise AttributeError, "'%s' object has no attribute '%s'" %
(repr(self), att
r)
AttributeError: '<win32com.gen_py.iTunes 1.9 Type Library.IITTrack
instance at 0>
x14463944>' object has no attribute 'SkippedCount'


If I comment out the lines referring to SkippedCount and SkippedDate,
it works just fine. As far as I can tell from testing the same code in
VBS, there should be no difference in how SkippedCount is accessed vs.
how Name is accessed. I'm new to Python. Is anyone out there using
iTunes that may have an idea?

Thanks
Den




More information about the Python-list mailing list