def write_metadata(self):
import mutagen<EOL>from mutagen import id3<EOL>id3 = id3.ID3(self.filename)<EOL>for tag in self.metadata.keys():<EOL><INDENT>value = self.metadata[tag]<EOL>frame = mutagen.id3.Frames[tag](<NUM_LIT:3>, value)<EOL>try:<EOL><INDENT>id3.add(frame)<EOL><DEDENT>except:<EOL><INDENT>raise IOError('<STR_LIT>' + tag + '<STR_LIT:">')<EOL><DEDENT><DEDENT>try:<EOL><INDENT>id3.save()<EOL><DEDENT>except:<EOL><INDENT>raise IOError('<STR_LIT>')<EOL><DEDENT>
Write all ID3v2.4 tags to file from self.metadata