clipper/backend/media/service.go

30 lines
620 B
Go
Raw Normal View History

2021-10-22 19:30:09 +00:00
package media
2021-10-27 19:34:59 +00:00
import (
"context"
"errors"
"fmt"
"log"
)
2021-10-22 19:30:09 +00:00
type MediaSetService struct{}
func (s *MediaSetService) GetMediaSet(ctx context.Context, source string, id string) (*MediaSet, error) {
2021-10-27 19:34:59 +00:00
log.Printf("GetMediaSet called with source %q, id %q", source, id)
if source != "youtube" {
return nil, errors.New("unknown source")
}
// try to load and return a cached MediaSet, if possible:
mediaSet := NewMediaSet(id)
if mediaSet.Exists() {
if err := mediaSet.Load(); err != nil {
return nil, fmt.Errorf("error loading MediaSet: %v", err)
}
return mediaSet, nil
}
2021-10-22 19:30:09 +00:00
return &MediaSet{ID: id}, nil
}