From 3006a75602b6aacfa90c4cd7faea4b76f4593815 Mon Sep 17 00:00:00 2001 From: thePR0M3TH3AN <53631862+PR0M3TH3AN@users.noreply.github.com> Date: Mon, 26 Jan 2026 12:13:26 -0500 Subject: [PATCH] Allow publish video series identifiers --- js/nostr/client.js | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/js/nostr/client.js b/js/nostr/client.js index ff0495a5..303913bd 100644 --- a/js/nostr/client.js +++ b/js/nostr/client.js @@ -5326,7 +5326,8 @@ export class NostrClient { * * **Payload Construction:** * - Creates a V3 video note with `magnet`, `url` (WebSeed), and core metadata. - * - Generates a unique `d` tag and `videoRootId` for this new series. + * - Generates a unique `d` tag and `videoRootId` for this new series unless + * an explicit identifier is provided in the upload payload. * * **Side Effects (in order):** * 1. **Primary Event**: Signs and publishes the Kind 30078 Video Note. @@ -5383,9 +5384,26 @@ export class NostrClient { const createdAt = Math.floor(Date.now() / 1000); - // brand-new root & d - const videoRootId = `${Date.now()}-${Math.random().toString(36).slice(2)}`; - const dTagValue = `${Date.now()}-${Math.random().toString(36).slice(2)}`; + const seriesIdentifierCandidates = [ + videoData.videoRootId, + videoData.seriesId, + videoData.seriesIdentifier, + ]; + let seriesIdentifier = ""; + for (const candidate of seriesIdentifierCandidates) { + const normalized = typeof candidate === "string" ? candidate.trim() : ""; + if (normalized) { + seriesIdentifier = normalized; + break; + } + } + + if (!seriesIdentifier) { + seriesIdentifier = `${Date.now()}-${Math.random().toString(36).slice(2)}`; + } + + const videoRootId = seriesIdentifier; + const dTagValue = seriesIdentifier; const finalEnableComments = videoData.enableComments === false ? false : true; @@ -5434,7 +5452,7 @@ export class NostrClient { additionalTags: nip71Tags, }); - devLogger.log("Publish event with brand-new root:", videoRootId); + devLogger.log("Publish event with series identifier:", videoRootId); devLogger.log("Event content:", event.content); try {