Beispiel #1
0
def genre_set(id3, key, value):
    try:
        frame = id3["TCON"]
    except KeyError:
        id3.add(mutagenx.id3.TCON(encoding=3, text=value))
    else:
        frame.encoding = 3
        frame.genres = value
Beispiel #2
0
 def setter(id3, key, value):
     try:
         frame = id3[frameid]
     except KeyError:
         id3.add(mutagenx.id3.Frames[frameid](encoding=3, text=value))
     else:
         frame.encoding = 3
         frame.text = value
Beispiel #3
0
 def setter(id3, key, value):
     try:
         frame = id3[frameid]
     except KeyError:
         id3.add(mutagenx.id3.Frames[frameid](encoding=3, text=value))
     else:
         frame.encoding = 3
         frame.text = value
Beispiel #4
0
def genre_set(id3, key, value):
    try:
        frame = id3["TCON"]
    except KeyError:
        id3.add(mutagenx.id3.TCON(encoding=3, text=value))
    else:
        frame.encoding = 3
        frame.genres = value
Beispiel #5
0
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 = mutagenx.id3.RVA2(desc=key[11:-5], gain=0, peak=0, channel=1)
        id3.add(frame)
    frame.gain = gain
Beispiel #6
0
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 = mutagenx.id3.UFID(owner="http://musicbrainz.org", data=value)
        id3.add(frame)
    else:
        frame.data = value
Beispiel #7
0
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 = mutagenx.id3.RVA2(desc=key[11:-5], gain=0, peak=0, channel=1)
        id3.add(frame)
    frame.gain = gain
Beispiel #8
0
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 = mutagenx.id3.UFID(owner="http://musicbrainz.org", data=value)
        id3.add(frame)
    else:
        frame.data = value
Beispiel #9
0
def performer_set(id3, key, value):
    wanted_role = key.split(":", 1)[1]
    try:
        mcl = id3["TMCL"]
    except KeyError:
        mcl = mutagenx.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
Beispiel #10
0
def performer_set(id3, key, value):
    wanted_role = key.split(":", 1)[1]
    try:
        mcl = id3["TMCL"]
    except KeyError:
        mcl = mutagenx.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
Beispiel #11
0
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 = mutagenx.id3.RVA2(desc=key[11:-5], gain=0, peak=0, channel=1)
        id3.add(frame)
    frame.peak = peak
Beispiel #12
0
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 = mutagenx.id3.RVA2(desc=key[11:-5], gain=0, peak=0, channel=1)
        id3.add(frame)
    frame.peak = peak
Beispiel #13
0
        def setter(id3, key, value):
            try:
                frame = id3[frameid]
            except KeyError:
                enc = 0
                # Store 8859-1 if we can, per MusicBrainz spec.
                try:
                    for v in value:
                        v.encode('latin_1')
                except UnicodeError:
                    enc = 3

                id3.add(mutagenx.id3.TXXX(encoding=enc, text=value, desc=desc))
            else:
                frame.text = value
Beispiel #14
0
        def setter(id3, key, value):
            try:
                frame = id3[frameid]
            except KeyError:
                enc = 0
                # Store 8859-1 if we can, per MusicBrainz spec.
                try:
                    for v in value:
                        v.encode('latin_1')
                except UnicodeError:
                    enc = 3

                id3.add(mutagenx.id3.TXXX(encoding=enc, text=value, desc=desc))
            else:
                frame.text = value
Beispiel #15
0
def website_set(id3, key, value):
    id3.delall("WOAR")
    for v in value:
        id3.add(mutagenx.id3.WOAR(url=v))
Beispiel #16
0
def date_set(id3, key, value):
    id3.add(mutagenx.id3.TDRC(encoding=3, text=value))
Beispiel #17
0
def website_set(id3, key, value):
    id3.delall("WOAR")
    for v in value:
        id3.add(mutagenx.id3.WOAR(url=v))
Beispiel #18
0
def date_set(id3, key, value):
    id3.add(mutagenx.id3.TDRC(encoding=3, text=value))