Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/exportHandler/exportHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ export interface ExportOptions {
removeIds?: boolean;
includeAudio?: boolean;
includeTimestamps?: boolean;
excludeLabels?: boolean;
/** Per-file 0-based milestone indices to include when exporting audio. An empty array skips that file entirely. Files omitted from this map are exported in full (no milestone step). */
selectedMilestonesByFile?: Record<string, number[]>;
}
Expand Down Expand Up @@ -2066,8 +2067,15 @@ export const exportCodexContentAsSubtitlesVtt = async (
totalCells += cells.length;
debug(`File has ${cells.length} active cells`);

const vttContent = generateVttData(cells, includeStyles, cueSplitting, file.fsPath);
debug({ vttContent, cells, includeStyles });
// Generate VTT content
const vttContent = generateVttData(
cells,
includeStyles,
cueSplitting,
file.fsPath,
options?.excludeLabels === true
);
debug({ vttContent, cells, includeStyles });

const timestamp = new Date().toISOString().replace(/[:.]/g, "-");
const fileName = basename(file.fsPath).replace(".codex", "") || "unknown";
Expand Down
5 changes: 3 additions & 2 deletions src/exportHandler/vttUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ export const generateVttData = (
cells: CodexNotebookAsJSONData["cells"],
includeStyles: boolean,
cueSplitting: boolean,
filePath: string
filePath: string,
excludeLabels: boolean = false
): string => {
if (!cells.length) return "";

Expand All @@ -95,7 +96,7 @@ export const generateVttData = (
const text = includeStyles ? processVttContent(unit.value) : removeHtmlTags(unit.value);
const finalText = ensureDialogueLineBreaks(text);

const rawLabel = unit.metadata?.cellLabel?.trim();
const rawLabel = excludeLabels ? undefined : unit.metadata?.cellLabel?.trim();
const payload = rawLabel
? `<v ${escapeVoiceName(rawLabel)}>${finalText}</v>`
: finalText;
Expand Down
25 changes: 25 additions & 0 deletions src/projectManager/projectExportView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,21 @@ function getWebviewContent(
.format-option-row[data-option].hidden { display: none !important; }
.format-option p, .format-option-content p { line-height: 1.45; margin: 4px 0 0 0; }
.format-option-content { display: flex; flex-direction: column; gap: 4px; }
.format-option-toggle {
display: flex;
align-items: center;
gap: 6px;
font-size: 0.9em;
color: var(--vscode-descriptionForeground);
cursor: pointer;
user-select: none;
}
.format-option-toggle input[type="checkbox"] { margin: 0; cursor: pointer; }
.format-section-suboption {
padding: 10px 12px;
background-color: var(--vscode-editor-background);
border-top: 1px solid var(--vscode-input-border);
}
.format-tag {
display: inline-block;
padding: 1px 4px;
Expand Down Expand Up @@ -1248,6 +1263,12 @@ function getWebviewContent(
</div>
</div>
</div>
<div class="format-section-suboption">
<label class="format-option-toggle" id="vttExcludeLabelsToggle">
<input type="checkbox" id="vttExcludeLabelsCb">
Exclude speaker labels from WebVTT cues
</label>
</div>
</div>
<!-- Round-trip: only for supported file types -->
<div class="roundtrip-wrapper" data-option="roundTrip">
Expand Down Expand Up @@ -2954,6 +2975,10 @@ function getWebviewContent(
options.includeAudio = true;
options.includeTimestamps = selectedAudioMode === 'audio-timestamps';
}
if (selectedFormat && selectedFormat.startsWith('subtitles-vtt-')) {
const cb = document.getElementById('vttExcludeLabelsCb');
if (cb && cb.checked) options.excludeLabels = true;
}
const selectedMilestones = buildSelectedMilestonesPayload();
if (selectedMilestones) {
options.selectedMilestonesByFile = selectedMilestones;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1483,10 +1483,10 @@ const messageHandlers: Record<string, (ctx: MessageHandlerContext) => Promise<vo
// Read the video file content
const fileData = await vscode.workspace.fs.readFile(fileUri);

// Enforce a reasonable max size (e.g., 600 MB) for video files
const MAX_BYTES = 600 * 1024 * 1024;
// Enforce a reasonable max size (e.g., 900 MB) for video files
const MAX_BYTES = 900 * 1024 * 1024;
if (fileData.length > MAX_BYTES) {
throw new Error("Video file exceeds maximum allowed size (500 MB)");
throw new Error("Video file exceeds maximum allowed size 900 MB)");
}

// Determine document segment
Expand Down
Loading