streamdata: metadata load helper

This loads metadata by ident.

Signed-off-by: Yonah <contrib@gensokyo.uk>
This commit is contained in:
2026-03-19 00:49:07 +09:00
parent a7d445c021
commit 2879d9d186
2 changed files with 60 additions and 2 deletions

View File

@@ -197,3 +197,21 @@ func (c *Channel) Add(ident *Ident, f func(v *VOD, w io.Writer) error) error {
return nil
}
// Load loads the metadata of a [VOD] by [Ident] and returns its address.
func (c *Channel) Load(ident *Ident) (*VOD, error) {
var v VOD
if r, err := c.root.Open(path.Join(
channelPathVOD,
ident.String(),
)); err != nil {
return nil, err
} else if err = json.NewDecoder(r).Decode(&v); err != nil {
_ = r.Close()
return nil, err
} else if err = r.Close(); err != nil {
return nil, err
} else {
return &v, nil
}
}