2020-06-08 03:29:51 +03:00
|
|
|
package id3
|
|
|
|
|
|
|
|
import (
|
2021-08-17 13:06:32 +03:00
|
|
|
"github.com/wader/fq/format"
|
|
|
|
"github.com/wader/fq/pkg/decode"
|
2022-07-16 19:39:57 +03:00
|
|
|
"github.com/wader/fq/pkg/interp"
|
2021-12-02 00:48:25 +03:00
|
|
|
"github.com/wader/fq/pkg/scalar"
|
2020-06-08 03:29:51 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
2022-07-16 19:39:57 +03:00
|
|
|
interp.RegisterFormat(decode.Format{
|
2020-06-08 03:29:51 +03:00
|
|
|
Name: format.ID3V11,
|
|
|
|
Description: "ID3v1.1 metadata",
|
|
|
|
DecodeFn: id3v11Decode,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2023-02-18 23:10:48 +03:00
|
|
|
func id3v11Decode(d *decode.D) any {
|
2021-11-05 17:04:26 +03:00
|
|
|
d.AssertAtLeastBitsLeft(128 * 8)
|
2022-09-30 14:58:23 +03:00
|
|
|
d.FieldUTF8("magic", 4, d.StrAssert("TAG+"))
|
2020-06-08 03:29:51 +03:00
|
|
|
d.FieldUTF8("title", 60)
|
|
|
|
d.FieldUTF8("artist", 60)
|
|
|
|
d.FieldUTF8("album", 60)
|
2022-09-30 14:58:23 +03:00
|
|
|
d.FieldU8("speed", scalar.UintMapSymStr{
|
2020-06-08 03:29:51 +03:00
|
|
|
0: "unset",
|
|
|
|
1: "slow",
|
|
|
|
2: "medium",
|
|
|
|
3: "fast",
|
|
|
|
4: "hardcore",
|
2021-12-02 00:48:25 +03:00
|
|
|
})
|
2020-06-08 03:29:51 +03:00
|
|
|
d.FieldUTF8("genre", 30)
|
|
|
|
d.FieldUTF8("start", 6)
|
|
|
|
d.FieldUTF8("stop", 6)
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|