penfold1992 / stagger

Automatically exported from code.google.com/p/stagger
BSD 2-Clause "Simplified" License
0 stars 0 forks source link

Change tag format returned by stagger.read #8

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Currently read returns a simple list of frames, which is rather inconvenient to 
manipulate.

Try this instead:

>>> tag = stagger.read("test.mp3")
>>> tag.version
4
>>> tag.frames["TIT2"]  # Straight dict
[TIT2(encoding=3, text=["Foobar"])]

>>> tag["TIT2"]         # User-friendly proxy
TIT2(encoding=3, text=["Foobar"])

>>> tag[TIT2]
TIT2(encoding=3, text=["Foobar"])

# Duplicate frames:
>>> tag[COMM]
[COMM("eng", "foo", "text text"), 
 COMM("eng", "bar", "text2 text2"), 
 COMM("hun", "foo", "text3 text3")]

# Multi-field getters (is this possible?)
>>> tag[COMM, "eng"]
[COMM("eng", "foo", "text text"), 
 COMM("eng", "bar", "text2 text2")]
>>> tag[COMM, "eng", "foo"]
COMM("eng", "foo", "text text")

>>> tag[TPE1] = TPE1(text="Joe")
>>> tag[TPE1] = TPE1(text="Joe")
>>> tag[COMM, "eng", "foo"] = COMM("eng", "foo", "dskjlsd")

# Fancy access?
>>> tag[TIT2] = "skjdfhksd"
>>> tag[TIT2]
TIT2(text=["skjdfhksd"])
>>> tag[TIT2].append("fred")
>>> tag[TIT2]
TIT2(text=["skjdfhksd", "fred"])

>>> tag[COMM, "hun", "bar"] = "text4 text4" 

# Updating
>>> tag.write("test.mp3")
# Conversion
>>> tag2 = tag.to_version(2)
>>> tag2.write("test.mp3")

Original issue reported on code.google.com by Karoly.Lorentey on 13 Jun 2009 at 6:16

GoogleCodeExporter commented 9 years ago
tag["TIT2"] and tag[TIT2] both work, currently returning a list.

Multi-field getters are certainly possible, but they need metadata extensions, 
say:

class COMM(Frame):
   _framespec = ...
   _key = ("lang", "desc")

Original comment by Karoly.Lorentey on 18 Jun 2009 at 11:10

GoogleCodeExporter commented 9 years ago
Multi-field getters live on as issue 13.

Original comment by Karoly.Lorentey on 20 Jun 2009 at 4:07