initial commit
This commit is contained in:
26
chapter.go
Normal file
26
chapter.go
Normal file
@ -0,0 +1,26 @@
|
||||
package mpvipc
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Chapter struct {
|
||||
Title string `json:"title"`
|
||||
Time time.Duration `json:"time"`
|
||||
}
|
||||
|
||||
func (c *Chapter) UnmarshalJSON(data []byte) error {
|
||||
m := &struct {
|
||||
Title string `json:"title"`
|
||||
Time float64 `json:"time"`
|
||||
}{}
|
||||
|
||||
if err := json.Unmarshal(data, m); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c.Title = m.Title
|
||||
c.Time = time.Duration(m.Time * float64(time.Second))
|
||||
return nil
|
||||
}
|
Reference in New Issue
Block a user