diff --git a/beets/mediafile.py b/beets/mediafile.py index 611876280..ef2d53c58 100644 --- a/beets/mediafile.py +++ b/beets/mediafile.py @@ -34,9 +34,11 @@ import mutagen.oggvorbis import mutagen.mp4 import mutagen.flac import mutagen.monkeysaudio +import mutagen.asf import datetime import re import base64 +import struct import imghdr import os import logging @@ -72,6 +74,7 @@ TYPES = { 'ape': 'APE', 'wv': 'WavPack', 'mpc': 'Musepack', + 'asf': 'Windows Media' } @@ -139,6 +142,44 @@ def _safe_cast(out_type, val): return val +def unpack_image(data): + """ + Helper function to unpack image data from a WM/Picture tag. + + The data has the following format: + 1 byte: Picture type (0-20), see ID3 APIC frame specification at http://www.id3.org/id3v2.4.0-frames + 4 bytes: Picture data length in LE format + MIME type, null terminated UTF-16-LE string + Description, null terminated UTF-16-LE string + The image data in the given length + """ + (type, size) = struct.unpack_from("