2020-07-23 01:56:08 +00:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"errors"
|
|
|
|
"strconv"
|
|
|
|
|
|
|
|
"github.com/stashapp/stash/pkg/api/urlbuilders"
|
|
|
|
"github.com/stashapp/stash/pkg/manager"
|
|
|
|
"github.com/stashapp/stash/pkg/models"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (r *queryResolver) SceneStreams(ctx context.Context, id *string) ([]*models.SceneStreamEndpoint, error) {
|
|
|
|
// find the scene
|
2021-01-18 01:23:20 +00:00
|
|
|
var scene *models.Scene
|
|
|
|
if err := r.withReadTxn(ctx, func(repo models.ReaderRepository) error {
|
|
|
|
idInt, _ := strconv.Atoi(*id)
|
|
|
|
var err error
|
|
|
|
scene, err = repo.Scene().Find(idInt)
|
|
|
|
return err
|
|
|
|
}); err != nil {
|
2020-07-23 01:56:08 +00:00
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
if scene == nil {
|
|
|
|
return nil, errors.New("nil scene")
|
|
|
|
}
|
|
|
|
|
|
|
|
baseURL, _ := ctx.Value(BaseURLCtxKey).(string)
|
|
|
|
builder := urlbuilders.NewSceneURLBuilder(baseURL, scene.ID)
|
|
|
|
|
|
|
|
return manager.GetSceneStreamPaths(scene, builder.GetStreamURL())
|
|
|
|
}
|