From d979b40d9f656112b6f011f53714995cd7fd5f51 Mon Sep 17 00:00:00 2001 From: ElementalAlchemist Date: Mon, 13 Nov 2023 16:35:05 -0600 Subject: [PATCH] Make the first chapter marker uneditable and tie it to the first range start time This is a more usable enforcement of the requirement that YouTube enforces for the first chapter to be at the exact beginning of the video. --- thrimbletrimmer/edit.html | 38 ++++++++++++++++------ thrimbletrimmer/scripts/edit.js | 22 +++++++++++++ thrimbletrimmer/styles/thrimbletrimmer.css | 4 +++ 3 files changed, 54 insertions(+), 10 deletions(-) diff --git a/thrimbletrimmer/edit.html b/thrimbletrimmer/edit.html index c6fd0d7..706c5c5 100644 --- a/thrimbletrimmer/edit.html +++ b/thrimbletrimmer/edit.html @@ -164,7 +164,31 @@ class="range-definition-current" /> - + Add chapter marker Download Video diff --git a/thrimbletrimmer/scripts/edit.js b/thrimbletrimmer/scripts/edit.js index 866d311..405342f 100644 --- a/thrimbletrimmer/scripts/edit.js +++ b/thrimbletrimmer/scripts/edit.js @@ -631,6 +631,21 @@ async function initializeVideoInfo() { const chapterContainer = rangeDefinitionsContainer.children[ rangeIndex ].getElementsByClassName("range-definition-chapter-markers")[0]; + + if (currentChapterIndex === 0) { + const chapterStartField = document.getElementById( + "range-definition-chapter-marker-first-start", + ); + const chapterDescField = document.getElementById( + "range-definition-chapter-marker-first-description", + ); + chapterStartField.value = videoHumanTimeFromVideoPlayerTime( + chapterData[currentChapterIndex].start - rangeStartOffset + startPlayerTime, + ); + chapterDescField.value = chapterData[currentChapterIndex].description; + currentChapterIndex++; + } + while ( currentChapterIndex < chapterData.length && chapterData[currentChapterIndex].start < rangeEndVideoTime @@ -1643,6 +1658,13 @@ async function rangeDataUpdated() { clipBar.appendChild(marker); } } + + const firstRangeStartField = document.getElementsByClassName("range-definition-start")[0]; // There should always be a first one + const firstChapterStartField = document.getElementById( + "range-definition-chapter-marker-first-start", + ); + firstChapterStartField.value = firstRangeStartField.value; + updateDownloadLink(); } diff --git a/thrimbletrimmer/styles/thrimbletrimmer.css b/thrimbletrimmer/styles/thrimbletrimmer.css index 1e6f265..991a586 100644 --- a/thrimbletrimmer/styles/thrimbletrimmer.css +++ b/thrimbletrimmer/styles/thrimbletrimmer.css @@ -288,6 +288,10 @@ a.click { text-align: right; } +.range-definition-chapter-marker-edit-gap { + width: 16px; +} + input.range-definition-chapter-marker-description { width: 500px; }