[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Reading and writing mp3 metadata
- From: Daurnimator <quae@...>
- Date: Tue, 30 Apr 2013 15:17:50 -0400
On 30 April 2013 12:01, Luiz Henrique de Figueiredo
<lhf@tecgraf.puc-rio.br> wrote:
>> You may want to look to
>> https://github.com/daurnimator/lamt/blob/master/id3v1.lua#L53 for
>> inspiration.
>
> My code was indeed too complicated. Try this
>
> f = io.open("foo.mp3","rb")
> f:seek("end",-128)
> t = {}
> t.signature = f:read(3)
> t.title = f:read(30)
> t.artist = f:read(30)
> t.album = f:read(30)
> t.year = f:read(4)
> t.comment = f:read(30)
> t.genre = f:read(1)
> f:close()
>
You will also need to post-process those strings by stripping trailing
whitespace and nulls and converting to the correct encoding (id3v1 is
usually created in the encoder's codepage.... and most id3v1 tags were
created back in the 90s)
Also genre should be looked up in this[1] table.
[1] https://github.com/daurnimator/lamt/blob/master/genrelist.lua