mirror of
https://github.com/stashapp/stash.git
synced 2025-12-06 08:26:00 +01:00
Add marker end seconds import/export (#5777)
* skip importing markers if scene is skipped
This commit is contained in:
parent
c0d5d1e5a7
commit
4bfc93b7ae
4 changed files with 23 additions and 5 deletions
|
|
@ -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{
|
||||
|
|
|
|||
|
|
@ -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"`
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,9 +27,17 @@ 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,
|
||||
EndSeconds: endSeconds,
|
||||
SceneID: i.SceneID,
|
||||
CreatedAt: i.Input.CreatedAt.GetTime(),
|
||||
UpdatedAt: i.Input.UpdatedAt.GetTime(),
|
||||
|
|
|
|||
Loading…
Reference in a new issue