Created
April 22, 2013 04:43
-
-
Save Lanny/5432478 to your computer and use it in GitHub Desktop.
A really hacky script to check for inconsistencies in album art in an iTunes library. Verification uses md5 hashes, so different resolutions of the same artwork will be considered inconsistent.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import win32com.client | |
import sys | |
import hashlib | |
if __name__ == '__main__' : | |
itunes = win32com.client.Dispatch("iTunes.Application") | |
tracks = itunes.LibraryPlaylist.tracks | |
track_count = tracks.Count | |
inconsistent_albums = [] | |
md5_map = {} | |
for track_num in range(1, track_count+1) : | |
track = tracks.Item(track_num) | |
artwork_collection = track.Artwork | |
md5 = hashlib.md5() | |
for artwork_num in range(1, artwork_collection.Count+1): | |
artwork = artwork_collection.Item(artwork_num) | |
try: | |
artwork.SaveArtworkToFile('C:/tmp.png') | |
f = open('C:/tmp.png', 'rb') | |
md5.update(f.read()) | |
f.close() | |
except: | |
print 'WOWAH!' | |
key_name = '%s by %s' % (track.album, track.artist) | |
if not md5_map.has_key(key_name): | |
md5_map[key_name] = md5.hexdigest() | |
elif key_name not in inconsistent_albums and md5_map[key_name] != md5.hexdigest(): | |
inconsistent_albums.append(key_name) | |
print 'Completed proccessing %d of %d, have found %d inconsistencies' % (track_num, track_count, len(inconsistent_albums)) | |
f = open('C:/incon.txt', 'w') | |
f.write('\n'.join(inconsistent_albums)) | |
f.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment