Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Accessing iTunes with Python via the Windows SDK
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Denrael  
View profile  
 More options May 24 2007, 2:23 pm
Newsgroups: comp.lang.python
From: Denrael <lear...@gmail.com>
Date: 23 May 2007 21:23:56 -0700
Local: Thurs, May 24 2007 2:23 pm
Subject: Accessing iTunes with Python via the Windows SDK
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


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tony Meyer  
View profile  
 More options May 24 2007, 3:17 pm
Newsgroups: comp.lang.python
From: Tony Meyer <tony.me...@gmail.com>
Date: 23 May 2007 22:17:01 -0700
Local: Thurs, May 24 2007 3:17 pm
Subject: Re: Accessing iTunes with Python via the Windows SDK
On May 24, 4:23 pm, Denrael <lear...@gmail.com> wrote:
> 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
[...]
> I get an error indicating that SkippedCount isn't a valid attribute:

[...]

The object you get back from iTunes.CurrentTrack (the traceback shows
this) is an IITTrack.  If you check the iTunes SDK, you'll see that
IITTrack objects don't have a "SkippedCount" attribute -
IITFileOrCDTrack objects do (from memory, this excludes things like
radio links).  You need to conver the IITrack object to a
IITFileOrCDTrack object (assuming that it is one); you can do this
with win32com.client.CastTo, as follows:

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

Cheers,
Tony


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Denrael  
View profile  
 More options May 24 2007, 3:59 pm
Newsgroups: comp.lang.python
From: Denrael <lear...@gmail.com>
Date: 23 May 2007 22:59:58 -0700
Local: Thurs, May 24 2007 3:59 pm
Subject: Re: Accessing iTunes with Python via the Windows SDK
On May 24, 12:17 am, Tony Meyer <tony.me...@gmail.com> wrote:

> On May 24, 4:23 pm, Denrael <lear...@gmail.com> wrote:> I've been playing with the iTunes sdk on windows, and have come across
> > a strange problem.  With the following code:

> The object you get back from iTunes.CurrentTrack (the traceback shows
> this) is an IITTrack.  If you check the iTunes SDK, you'll see that
> IITTrack objects don't have a "SkippedCount" attribute -
> IITFileOrCDTrack objects do (from memory, this excludes things like
> radio links).  You need to conver the IITrack object to a
> IITFileOrCDTrack object (assuming that it is one); you can do this
> with win32com.client.CastTo, as follows:

> Cheers,
> Tony

Thanks Tony!

I had a suspicion it had to do with casting it, but I was missing some
synapses to figure out exactly how to do that. Things have changed
from my Assembly Language PL/1 and REXX days.  :) I figure if I'm
gonna learn a new language, Python's a lot more usable than VBS, and
it has an elegance to it that I already appreciate. I'm working my way
thru Learning Python ... I suppose I better find some doc on the Win32
COM stuff too.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
kyoso...@gmail.com  
View profile  
 More options May 25 2007, 7:05 am
Newsgroups: comp.lang.python
From: kyoso...@gmail.com
Date: 24 May 2007 14:05:36 -0700
Local: Fri, May 25 2007 7:05 am
Subject: Re: Accessing iTunes with Python via the Windows SDK
On May 24, 12:59 am, Denrael <lear...@gmail.com> wrote:

The best Python docs on win32 in general is "Python Programming on
Win32" by Hammond & Robinson. It has some stuff on Python and COM as
well. I'm sure a win32 COM book would be good too.

Mike


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google