Add marker end seconds import/export (#5777)

* skip importing markers if scene is skipped
This commit is contained in:
bob123491234 2025-03-28 00:50:26 -05:00 committed by GitHub
parent c0d5d1e5a7
commit 4bfc93b7ae
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 23 additions and 5 deletions

View file

@ -709,6 +709,11 @@ func (t *ImportTask) ImportScenes(ctx context.Context) {
return err return err
} }
// skip importing markers if the scene was not created
if sceneImporter.ID == 0 {
return nil
}
// import the scene markers // import the scene markers
for _, m := range sceneJSON.Markers { for _, m := range sceneJSON.Markers {
markerImporter := &scene.MarkerImporter{ markerImporter := &scene.MarkerImporter{

View file

@ -14,6 +14,7 @@ import (
type SceneMarker struct { type SceneMarker struct {
Title string `json:"title,omitempty"` Title string `json:"title,omitempty"`
Seconds string `json:"seconds,omitempty"` Seconds string `json:"seconds,omitempty"`
EndSeconds string `json:"end_seconds,omitempty"`
PrimaryTag string `json:"primary_tag,omitempty"` PrimaryTag string `json:"primary_tag,omitempty"`
Tags []string `json:"tags,omitempty"` Tags []string `json:"tags,omitempty"`
CreatedAt json.JSONTime `json:"created_at,omitempty"` CreatedAt json.JSONTime `json:"created_at,omitempty"`

View file

@ -235,6 +235,10 @@ func GetSceneMarkersJSON(ctx context.Context, markerReader models.SceneMarkerFin
UpdatedAt: json.JSONTime{Time: sceneMarker.UpdatedAt}, UpdatedAt: json.JSONTime{Time: sceneMarker.UpdatedAt},
} }
if sceneMarker.EndSeconds != nil {
sceneMarkerJSON.EndSeconds = getDecimalString(*sceneMarker.EndSeconds)
}
results = append(results, sceneMarkerJSON) results = append(results, sceneMarkerJSON)
} }

View file

@ -27,9 +27,17 @@ type MarkerImporter struct {
func (i *MarkerImporter) PreImport(ctx context.Context) error { func (i *MarkerImporter) PreImport(ctx context.Context) error {
seconds, _ := strconv.ParseFloat(i.Input.Seconds, 64) 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{ i.marker = models.SceneMarker{
Title: i.Input.Title, Title: i.Input.Title,
Seconds: seconds, Seconds: seconds,
EndSeconds: endSeconds,
SceneID: i.SceneID, SceneID: i.SceneID,
CreatedAt: i.Input.CreatedAt.GetTime(), CreatedAt: i.Input.CreatedAt.GetTime(),
UpdatedAt: i.Input.UpdatedAt.GetTime(), UpdatedAt: i.Input.UpdatedAt.GetTime(),