Not able to update album art via script

This forum is for questions / discussions regarding development of addons / tweaks for MediaMonkey for Windows 4.

Moderators: Gurus, Addon Administrators

mcow
Posts: 835
Joined: Sun Sep 21, 2008 9:35 pm
Location: Cupertino, California

Not able to update album art via script

Post by mcow »

I'm trying to fix an album-art problem. As I mentioned in another thread, I have a large number of tracks that have two art tags: the first is to a (nonexistent) file named ".jpg" and the other to an existing file called "cover.jpg", which is the right image. The first is type "Cover (front)" and the second "unspecified."

I want to delete the first entry and change the second to be the "Cover (front)". I wrote this Python script to make changes to whatever tracks are selected:

Code: Select all

import sys, os
import time
import win32com.client
import pythoncom

SDB = win32com.client.Dispatch('SongsDB.SDBApplication')

seltracks = [SDB.SelectedSongList.Item(i) for i in range(SDB.SelectedSongList.Count)]
for trk in seltracks:
    if trk.AlbumArt.Count == 2 and trk.AlbumArt.Item(0).RelativePicturePath == u'.jpg':
        trk.AlbumArt.Item(1).ItemType = 3
        trk.AlbumArt.Delete(0)
        trk.WriteTags()
        trk.UpdateDB()
        print "FIXED: " + trk.Title
    else:
        print " skip: " + trk.Title
I just make the selection in MediaMonkey and then run the script in a cmd window. It prints out the expected list of "Fixed" titles, but the track isn't getting updated. I'm sure the Python-to-MediaMonkey interface works fine, including being able to WriteTags and UpdateDB. Is there some function I'm missing a call to?