diff --git a/plugins/timestampTrade/timestampTrade.py b/plugins/timestampTrade/timestampTrade.py index 2e8a1eb8..8c2f45c0 100644 --- a/plugins/timestampTrade/timestampTrade.py +++ b/plugins/timestampTrade/timestampTrade.py @@ -51,12 +51,19 @@ def processSceneTimestamTrade(s): previous = {"title": "", "seconds": -1} for m in data["markers"]: + marker = { "seconds": m["start_time"] / 1000, "primary_tag": None, "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 + log.debug(f"Added end time: {marker['end_seconds']} seconds for marker '{marker['title']}'") + if settings["addTsTradeTag"]: marker["tags"].append(int(getTag("[Timestamp]"))) @@ -567,7 +574,7 @@ def submitScene(query): } movies{ scene_index - movie{ + movie{ name url date @@ -613,6 +620,7 @@ def submitScene(query): scene_markers{ title seconds + end_seconds primary_tag{ name } @@ -661,7 +669,7 @@ def submitScene(query): } groups{ scene_index - group{ + group{ name urls date @@ -710,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) @@ -1517,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 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