def genre_set(id3, key, value): try: frame = id3["TCON"] except KeyError: id3.add(lib.mutagen.id3.TCON(encoding=3, text=value)) else: frame.encoding = 3 frame.genres = value
def setter(id3, key, value): try: frame = id3[frameid] except KeyError: id3.add(lib.mutagen.id3.Frames[frameid](encoding=3, text=value)) else: frame.encoding = 3 frame.text = value
def gain_set(id3, key, value): if len(value) != 1: raise ValueError("there must be exactly one gain value, not %r.", value) gain = float(value[0].split()[0]) try: frame = id3["RVA2:" + key[11:-5]] except KeyError: frame = lib.mutagen.id3.RVA2(desc=key[11:-5], gain=0, peak=0, channel=1) id3.add(frame) frame.gain = gain
def musicbrainz_trackid_set(id3, key, value): if len(value) != 1: raise ValueError("only one track ID may be set per song") value = value[0].encode('ascii') try: frame = id3["UFID:http://musicbrainz.org"] except KeyError: frame = lib.mutagen.id3.UFID(owner="http://musicbrainz.org", data=value) id3.add(frame) else: frame.data = value
def peak_set(id3, key, value): if len(value) != 1: raise ValueError("there must be exactly one peak value, not %r.", value) peak = float(value[0]) if peak >= 2 or peak < 0: raise ValueError("peak must be => 0 and < 2.") try: frame = id3["RVA2:" + key[11:-5]] except KeyError: frame = lib.mutagen.id3.RVA2(desc=key[11:-5], gain=0, peak=0, channel=1) id3.add(frame) frame.peak = peak
def performer_set(id3, key, value): wanted_role = key.split(":", 1)[1] try: mcl = id3["TMCL"] except KeyError: mcl = lib.mutagen.id3.TMCL(encoding=3, people=[]) id3.add(mcl) mcl.encoding = 3 people = [p for p in mcl.people if p[0] != wanted_role] for v in value: people.append((wanted_role, v)) mcl.people = people
def setter(id3, key, value): try: frame = id3[frameid] except KeyError: enc = 0 # Store 8859-1 if we can, per MusicBrainz spec. for v in value: if max(v) > u'\x7f': enc = 3 id3.add(lib.mutagen.id3.TXXX(encoding=enc, text=value, desc=desc)) else: frame.text = value
def setter(id3, key, value): try: frame = id3[frameid] except KeyError: enc = 0 # Store 8859-1 if we can, per MusicBrainz spec. for v in value: if max(v) > u'\x7f': enc = 3 id3.add( lib.mutagen.id3.TXXX(encoding=enc, text=value, desc=desc)) else: frame.text = value
def website_set(id3, key, value): id3.delall("WOAR") for v in value: id3.add(lib.mutagen.id3.WOAR(url=v))
def date_set(id3, key, value): id3.add(lib.mutagen.id3.TDRC(encoding=3, text=value))