Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6659845
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:04:50+00:00 2026-05-26T02:04:50+00:00

I am Using the iTunes COM interface on windows 7. The method iTunes.CurrentTrack.AddArtworkFromFile(path) requires

  • 0

I am Using the iTunes COM interface on windows 7.
The method iTunes.CurrentTrack.AddArtworkFromFile(path) requires path to be of type BSTR.

I understand from some research that BSTR is a C++/Visual Basic data type that means basic string.

Is there any way of converting python ascii strings to BSTR?

code :

import urllib
from BeautifulSoup import BeautifulSoup
import re
import win32com.client
import sys





iTunes = win32com.client.gencache.EnsureDispatch("iTunes.Application")

cTrackName = iTunes.CurrentTrack.Name
cArtist = iTunes.CurrentTrack.Artist
cAlbum = iTunes.CurrentTrack.Album

print cAlbum + cArtist + cTrackName
url = 'http://www.last.fm/music/'+cArtist+'/'+cAlbum
albumPage = urllib.urlopen(url).read()
soup = BeautifulSoup(albumPage)
s =  soup.prettify()
z = re.compile('.*<img  width="174" src="(.*)" class="art"  id="albumCover" itemprop="image" class="albumCover coverMega"  />')
p = re.findall(z,s)
print p
urllib.urlretrieve(p[0],'a.png')
a = urllib.quote('file://localhost/C:/Users/ArchAngel/Desktop/a.png')
iTunes.CurrentTrack.AddArtworkFromFile('file://localhost/C:/Users/ArchAngel/Desktop/a.png')
#print binascii.a2b_uu('sadsaffas')
iTunes.CurrentTrack.AddArtworkFromFile(b'C:\Users\ArchAngel\Desktop\a.png')

Error : pywintypes.com_error: (-2147352567, ‘Exception occurred.’, (0, None, None, None, 0, -2147467259), None)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T02:04:51+00:00Added an answer on May 26, 2026 at 2:04 am

    Since you are using Python 2.x, I believe you simply need to use unicode rather than str and win32com will do the rest. However, I would have expected win32com to automatically convert str to unicode for you.

    You should write it like this:

    iTunes.CurrentTrack.AddArtworkFromFile(u'file://localhost/C:/Users/ArchAngel/Desktop/a.png')
    

    If this does not work then I think your problem lies elsewhere.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the scripting bridge to query iTunes from my cocoa application. Sometimes iTunes
I recently found out about the awesomeness of the iTunes COM for Windows SDK.
I'm trying to verify a sandbox transactionReceipt at https://sandbox.itunes.apple.com/verifyReceipt using php and cURL. The
I have been messing around with iTunes COM from python. However, I haven't been
Have a look on following application http://itunes.apple.com/us/app/fatbooth/id372268904?mt=8 i think they are using the same
I'm working with the iTunes COM API on Windows. I'd like to manage the
I am using NSXMLParser to parse this XML: http://itunes.apple.com/gb/rss/topsongs/limit=50/explicit=true/xml . I am trying to
I just submitted my iPhone application using iTunes Connect, but I don't see anywhere
I'm using PowersHell to automate iTunes but find the error handling / waiting for
I need to get access to the iTunes tags in an RSS feed using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.