2015-05-31 39 views
0

我通過COM接口將文件添加到iTunes和寫評論,但是寫評論時有時會出現錯誤 -iTunes的COM接口的軌道是不可修改的

com_error: (-2147352567, '\xce\xf8\xe8\xe1\xea\xe0.', (0, None, u'The track is not modifiable.', None, 0, -1610350077), None) 

代碼:

def addFile(playlist, filePath, comment): 

     IITUserPlaylist = win32com.client.CastTo(playlist, 'IITUserPlaylist') 
     resultAdd = IITUserPlaylist.AddFile(filePath) 

     if resultAdd == None: return False  #Bad filePath 

     while resultAdd.InProgress == True:  #Wait adding files 
      print("adding file") 

     for number in range(1, resultAdd.Tracks.Count + 1): 
      currentTrack = resultAdd.Tracks.Item(number) 
      if currentTrack.Kind == 1: 
       currentTrack = comment   #Add comment to track 

     return True 

我認爲問題在於此時iTunes處理軌道,因爲重新啓動腳本時可能不會發生錯誤。最重要的是,我做了錯誤的測試就可以了:

while resultAdd.InProgress == True:  #Wait adding files 
     print("adding file") 

但我沒有其他辦法的文檔中找到。

對不起,我不好說英語。

+0

*「itunce」* - iTunes ?!我的意思是,它已經在您使用的標籤中**了。 – jonrsharpe

+0

是的,對不起,我犯了一個錯誤 – Clampson

+0

憑經驗,它發現只有當您添加沒有id3標籤的曲目時出現錯誤 – Clampson

回答

0

我很確定你的文件是隻讀的。

來源:遇到同樣的問題