1package playlistfs
2
3import (
4 "fmt"
5 "strings"
6)
7
8type Playlist struct {
9 FileName string
10 Description string
11}
12
13func PlaylistCmd(buf []byte) (*Playlist, error) {
14 var entry Playlist
15
16 fields, err := parseFields(buf, 1, -1)
17 if err != nil {
18 return nil, err
19 }
20
21 for _, field := range fields {
22 for i := 0; i < len(field); i++ {
23 data := field[i]
24 switch i {
25 case 0:
26 entry.FileName = data
27 case 1:
28 entry.Description = strings.Join(field[i:], " ")
29 return &entry, nil
30 }
31 }
32 }
33
34 return &entry, nil
35}
36
37func (p *Playlist) String() string {
38 return fmt.Sprintf("%s '%s'", p.FileName, p.Description)
39}