From 36133e7b02d9b5874037a5ea2ca5da611aa8b7a6 Mon Sep 17 00:00:00 2001 From: WorksDontBreak <12sketchy12@gmail.com> Date: Fri, 4 Apr 2025 19:58:55 +0000 Subject: [PATCH 1/2] Add support for end seconds --- plugins/timestampTrade/timestampTrade.py | 5 +++++ plugins/timestampTrade/timestampTrade.yml | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/plugins/timestampTrade/timestampTrade.py b/plugins/timestampTrade/timestampTrade.py index 2e8a1eb8..6f70cb0e 100644 --- a/plugins/timestampTrade/timestampTrade.py +++ b/plugins/timestampTrade/timestampTrade.py @@ -57,6 +57,11 @@ def processSceneTimestamTrade(s): "tags": [], "title": m["name"], } + + # Add end time if setting is enabled and data is available + if settings.get("useMarkerEndTimes", False) and "end_time" in m and m["end_time"]: + marker["end_seconds"] = m["end_time"] / 1000 + if settings["addTsTradeTag"]: marker["tags"].append(int(getTag("[Timestamp]"))) diff --git a/plugins/timestampTrade/timestampTrade.yml b/plugins/timestampTrade/timestampTrade.yml index 3760fc0e..ae596b72 100644 --- a/plugins/timestampTrade/timestampTrade.yml +++ b/plugins/timestampTrade/timestampTrade.yml @@ -54,6 +54,10 @@ settings: mergeMarkers: displayName: Merge Markers type: BOOLEAN + useMarkerEndTimes: + displayName: Use marker end times + description: When available, import end times for markers from timestamp.trade + type: BOOLEAN hooks: - name: Add Marker to Scene From ca67bf7977f626a99ade68356e45bece47602300 Mon Sep 17 00:00:00 2001 From: WorksDontBreak <12sketchy12@gmail.com> Date: Fri, 4 Apr 2025 21:08:16 +0000 Subject: [PATCH 2/2] Fixed issues with not exporting end_seconds when submitting --- plugins/timestampTrade/timestampTrade.py | 28 +++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/plugins/timestampTrade/timestampTrade.py b/plugins/timestampTrade/timestampTrade.py index 6f70cb0e..8c2f45c0 100644 --- a/plugins/timestampTrade/timestampTrade.py +++ b/plugins/timestampTrade/timestampTrade.py @@ -51,6 +51,7 @@ def processSceneTimestamTrade(s): previous = {"title": "", "seconds": -1} for m in data["markers"]: + marker = { "seconds": m["start_time"] / 1000, "primary_tag": None, @@ -61,7 +62,8 @@ def processSceneTimestamTrade(s): # Add end time if setting is enabled and data is available if settings.get("useMarkerEndTimes", False) and "end_time" in m and m["end_time"]: marker["end_seconds"] = m["end_time"] / 1000 - + log.debug(f"Added end time: {marker['end_seconds']} seconds for marker '{marker['title']}'") + if settings["addTsTradeTag"]: marker["tags"].append(int(getTag("[Timestamp]"))) @@ -572,7 +574,7 @@ def submitScene(query): } movies{ scene_index - movie{ + movie{ name url date @@ -618,6 +620,7 @@ def submitScene(query): scene_markers{ title seconds + end_seconds primary_tag{ name } @@ -666,7 +669,7 @@ def submitScene(query): } groups{ scene_index - group{ + group{ name urls date @@ -715,6 +718,24 @@ def submitScene(query): "md5": row[4], } ) + # Process markers to include end_seconds + processed_markers = [] + for marker in s["scene_markers"]: + processed_marker = { + "title": marker["title"], + "start_time": marker["seconds"] * 1000, # Convert to milliseconds + "tag_name": marker["primary_tag"]["name"] + } + + # Include end time if available + if "end_seconds" in marker and marker["end_seconds"]: + processed_marker["end_time"] = marker["end_seconds"] * 1000 # Convert to milliseconds + log.debug(f"Including end time: {processed_marker['end_time']} ms for marker '{marker['title']}'") + + processed_markers.append(processed_marker) + + # Add processed markers to submission data + s["markers"] = processed_markers s.pop("id") log.debug(s) request_s.post("https://timestamp.trade/submit-stash", json=s) @@ -1522,3 +1543,4 @@ def excluded_marker_tag(marker): if _type == "Image.Create.Post": img = stash.find_image(image_in=_id) processImages(img) + \ No newline at end of file