Skip to content

Commit

Permalink
Slight simplification for #1042
Browse files Browse the repository at this point in the history
  • Loading branch information
sampsyo committed Oct 28, 2014
1 parent 3c748b6 commit 5ed6f59
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions beets/mediafile.py
Original file line number Diff line number Diff line change
Expand Up @@ -955,7 +955,7 @@ class APEv2ImageStorageStyle(ListStorageStyle):
"""
formats = ['APEv2File', 'WavPack', 'Musepack', 'MonkeysAudio', 'OptimFROG']

_APE_COVER_TAG_NAMES = {
TAG_NAMES = {
ImageType.other: 'Cover Art (other)',
ImageType.icon: 'Cover Art (icon)',
ImageType.other_icon: 'Cover Art (other icon)',
Expand All @@ -976,15 +976,15 @@ class APEv2ImageStorageStyle(ListStorageStyle):
ImageType.fish: 'Cover Art (colored fish)',
ImageType.illustration: 'Cover Art (illustration)',
ImageType.artist_logo: 'Cover Art (band logo)',
ImageType.publisher_logo: 'Cover Art (publisher logo)'}
ImageType.publisher_logo: 'Cover Art (publisher logo)',
}

def __init__(self):
super(APEv2ImageStorageStyle, self).__init__(key='')

def fetch(self, mutagen_file):
images = []
for cover_type, cover_tag in \
APEv2ImageStorageStyle._APE_COVER_TAG_NAMES.iteritems():
for cover_type, cover_tag in self.TAG_NAMES.items():
try:
frame = mutagen_file[cover_tag]
text_delimiter_index = frame.value.find('\x00')
Expand All @@ -1005,14 +1005,13 @@ def set_list(self, mutagen_file, values):
image_type = image.type or ImageType.other
comment = image.desc or ''
image_data = comment + "\x00" + image.data
cover_tag = APEv2ImageStorageStyle._APE_COVER_TAG_NAMES[image_type]
cover_tag = self.TAG_NAMES[image_type]
mutagen_file[cover_tag] = image_data

def delete(self, mutagen_file):
"""Remove all images from the file.
"""
for cover_tag in \
APEv2ImageStorageStyle._APE_COVER_TAG_NAMES.itervalues():
for cover_tag in self.TAG_NAMES.values():
try:
del mutagen_file[cover_tag]
except KeyError:
Expand Down

0 comments on commit 5ed6f59

Please sign in to comment.