fix: issues

This commit is contained in:
Rogee
2024-12-05 11:32:00 +08:00
parent 9ddd3f61ec
commit c6313f234b
17 changed files with 206 additions and 396 deletions

View File

@@ -27,3 +27,11 @@ func GetSubDirs(root string) ([]string, error) {
return paths, nil
}
func DirExists(path string) bool {
st, err := os.Stat(path)
if err != nil {
return false
}
return st.IsDir()
}

View File

@@ -4,6 +4,8 @@ import (
"database/sql/driver"
"encoding/json"
"errors"
"github.com/samber/lo"
)
// swagger:enum MediaType
@@ -14,12 +16,9 @@ import (
// )
type MediaType string
type MediaSource struct {
Duration int64 `json:"duration"`
Items []MediaSourceItem `json:"items"`
}
type MediaResources []MediaType
func (x MediaSource) Scan(value interface{}) (err error) {
func (x MediaResources) Scan(value interface{}) (err error) {
switch v := value.(type) {
case string:
return json.Unmarshal([]byte(v), &x)
@@ -31,12 +30,10 @@ func (x MediaSource) Scan(value interface{}) (err error) {
return errors.New("Unknown type for ")
}
func (x MediaSource) Value() (driver.Value, error) {
func (x MediaResources) Value() (driver.Value, error) {
return json.Marshal(x)
}
type MediaSourceItem struct {
Source string `json:"source"`
Size int64 `json:"size"`
Duration int64 `json:"duration"`
func (x MediaResources) MustValue() driver.Value {
return lo.Must(json.Marshal(x))
}