diff --git a/internal/manager/task_import.go b/internal/manager/task_import.go index 8863a768d..d92f48268 100644 --- a/internal/manager/task_import.go +++ b/internal/manager/task_import.go @@ -709,6 +709,11 @@ func (t *ImportTask) ImportScenes(ctx context.Context) { return err } + // skip importing markers if the scene was not created + if sceneImporter.ID == 0 { + return nil + } + // import the scene markers for _, m := range sceneJSON.Markers { markerImporter := &scene.MarkerImporter{ diff --git a/pkg/models/jsonschema/scene.go b/pkg/models/jsonschema/scene.go index 757f520b8..c2f266d5c 100644 --- a/pkg/models/jsonschema/scene.go +++ b/pkg/models/jsonschema/scene.go @@ -14,6 +14,7 @@ import ( type SceneMarker struct { Title string `json:"title,omitempty"` Seconds string `json:"seconds,omitempty"` + EndSeconds string `json:"end_seconds,omitempty"` PrimaryTag string `json:"primary_tag,omitempty"` Tags []string `json:"tags,omitempty"` CreatedAt json.JSONTime `json:"created_at,omitempty"` diff --git a/pkg/scene/export.go b/pkg/scene/export.go index 5733c3be5..a012d1850 100644 --- a/pkg/scene/export.go +++ b/pkg/scene/export.go @@ -235,6 +235,10 @@ func GetSceneMarkersJSON(ctx context.Context, markerReader models.SceneMarkerFin UpdatedAt: json.JSONTime{Time: sceneMarker.UpdatedAt}, } + if sceneMarker.EndSeconds != nil { + sceneMarkerJSON.EndSeconds = getDecimalString(*sceneMarker.EndSeconds) + } + results = append(results, sceneMarkerJSON) } diff --git a/pkg/scene/marker_import.go b/pkg/scene/marker_import.go index 33937af7e..5f992f4f4 100644 --- a/pkg/scene/marker_import.go +++ b/pkg/scene/marker_import.go @@ -27,12 +27,20 @@ type MarkerImporter struct { func (i *MarkerImporter) PreImport(ctx context.Context) error { seconds, _ := strconv.ParseFloat(i.Input.Seconds, 64) + + var endSeconds *float64 + if i.Input.EndSeconds != "" { + parsedEndSeconds, _ := strconv.ParseFloat(i.Input.EndSeconds, 64) + endSeconds = &parsedEndSeconds + } + i.marker = models.SceneMarker{ - Title: i.Input.Title, - Seconds: seconds, - SceneID: i.SceneID, - CreatedAt: i.Input.CreatedAt.GetTime(), - UpdatedAt: i.Input.UpdatedAt.GetTime(), + Title: i.Input.Title, + Seconds: seconds, + EndSeconds: endSeconds, + SceneID: i.SceneID, + CreatedAt: i.Input.CreatedAt.GetTime(), + UpdatedAt: i.Input.UpdatedAt.GetTime(), } if err := i.populateTags(ctx); err != nil {