feat: add media sources
This commit is contained in:
@@ -1,5 +1,11 @@
|
||||
package pg
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
)
|
||||
|
||||
// swagger:enum MediaType
|
||||
// ENUM(
|
||||
// Video = "video",
|
||||
@@ -7,3 +13,30 @@ package pg
|
||||
// Pdf = "pdf",
|
||||
// )
|
||||
type MediaType string
|
||||
|
||||
type MediaSource struct {
|
||||
Duration int64 `json:"duration"`
|
||||
Items []MediaSourceItem `json:"items"`
|
||||
}
|
||||
|
||||
func (x MediaSource) Scan(value interface{}) (err error) {
|
||||
switch v := value.(type) {
|
||||
case string:
|
||||
return json.Unmarshal([]byte(v), &x)
|
||||
case []byte:
|
||||
return json.Unmarshal(v, &x)
|
||||
case *string:
|
||||
return json.Unmarshal([]byte(*v), &x)
|
||||
}
|
||||
return errors.New("Unknown type for ")
|
||||
}
|
||||
|
||||
func (x MediaSource) Value() (driver.Value, error) {
|
||||
return json.Marshal(x)
|
||||
}
|
||||
|
||||
type MediaSourceItem struct {
|
||||
Source string `json:"source"`
|
||||
Size int64 `json:"size"`
|
||||
Duration int64 `json:"duration"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user