30 lines
620 B
Go
30 lines
620 B
Go
package media
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
"log"
|
|
)
|
|
|
|
type MediaSetService struct{}
|
|
|
|
func (s *MediaSetService) GetMediaSet(ctx context.Context, source string, id string) (*MediaSet, error) {
|
|
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
|
|
}
|
|
|
|
return &MediaSet{ID: id}, nil
|
|
}
|