initial commit

This commit is contained in:
milarin
2023-12-20 20:50:11 +01:00
commit 6cd31fc715
8 changed files with 385 additions and 0 deletions

26
chapter.go Normal file
View 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
}