Skip to content

Conversation

Copy link

Copilot AI commented Dec 17, 2025

Separates export format selection from content configuration, allowing users to customize speaker and timestamp inclusion, placement, and formatting across all export formats.

Core Changes

ExportConfig dataclass - Configuration model for export options:

  • Speaker: include toggle, placement (inline/separate)
  • Timestamps: include toggle, placement (beginning/end/inline), type (start/range), format (HH:MM:SS variants)

Export methods - All methods now accept optional ExportConfig:

# Backward compatible - no config uses original behavior
editor.export_csv()  # → "00:00:01,000","00:00:03,500","Speaker A","text"

# With config - separate columns for metadata
config = ExportConfig(speaker_placement="separate", timestamp_format="HH:MM:SS.mmm")
editor.export_csv(config)  # → "00:00:01.000","00:00:03.500","Speaker A","text"

Helper methods:

  • format_timestamp() - Converts between HH:MM:SS format variants
  • generate_preview() - Renders first N segments with current config
  • Format-specific preview generators for each export type

Export dialog - Modal UI replacing dropdown button:

  • Left panel: format selector, speaker/timestamp configuration
  • Right panel: live preview updating on any option change
  • Dynamic option visibility (e.g., "separate" placement only for CSV/TSV/JSON)
  • Smart enable/disable based on checkbox state

Technical Notes

CSV/TSV/JSON behavior: speaker_placement="separate" controls all metadata column structure. When "separate", timestamps and speakers go to distinct columns/fields; when "inline", metadata embeds in text field.

JSON export return type: Returns dict without config (backward compatibility), JSON string with config (consistency with other exporters).

Preview optimization: Processes only first 3 segments to maintain UI responsiveness.

Integration

Replaced multi-item export dropdown with single "Export..." button opening configuration dialog. All existing export functionality preserved.

Original prompt

Background

Implement the advanced export module as described in issue #37. The goal is to separate file format from content configuration, allowing users to customize what metadata is included in exports and how it is formatted.

Files to Modify

  • utils/srt.py - Add export configuration classes and update export methods
  • pages/srt.py - Add export dialog UI with configuration options

Requirements

1. Export Configuration Class

Add a new ExportConfig dataclass in utils/srt.py with the following options:

  • include_speaker: bool - Toggle speaker information
  • speaker_placement: str - "inline" or "separate" (for CSV/TSV/JSON)
  • include_timestamps: bool - Toggle timestamps
  • timestamp_placement: str - "beginning", "end", or "inline"
  • timestamp_type: str - "start" or "range" (start-end)
  • timestamp_format: str - Preset options: "HH:MM:SS", "HH:MM:SS,mmm", "HH:MM:SS.mmm"

2. Update Export Methods in SRTEditor class

Modify the following export methods to accept an optional ExportConfig parameter:

  • export_txt() - Apply speaker and timestamp options
  • export_rtf() - Apply speaker and timestamp options
  • export_csv() - Apply speaker and timestamp options, support separate columns
  • export_tsv() - Apply speaker and timestamp options, support separate columns
  • export_json() - Apply speaker and timestamp options

Add helper methods:

  • format_timestamp(timestamp: str, format_preset: str) -> str - Convert timestamp to specified format
  • generate_preview(config: ExportConfig, format: str, num_segments: int = 3) -> str - Generate preview of export output

3. Export Dialog UI in pages/srt.py

Replace the simple dropdown export button with an "Export..." button that opens a dialog containing:

  1. Format Selection - Radio buttons or select for: TXT, RTF, JSON, CSV, TSV (and SRT/VTT for srt data format)

  2. Speaker Options Section

    • Checkbox: "Include speaker information"
    • Radio/Select (enabled when include_speaker is True): Speaker placement
      • "Inline prefix (e.g., 'Speaker A:')"
      • "Separate column/field" (only for CSV, TSV, JSON)
  3. Timestamp Options Section

    • Checkbox: "Include timestamps"
    • Radio/Select (enabled when include_timestamps is True): Timestamp placement
      • "At beginning of each segment"
      • "At end of each segment"
      • "Inline with text"
    • Radio/Select: Timestamp type
      • "Start time only"
      • "Start–end range"
    • Select: Timestamp format preset
      • "HH:MM:SS"
      • "HH:MM:SS,mmm" (with comma)
      • "HH:MM:SS.mmm" (with dot)
  4. Preview Panel

    • Show a live preview of the first 2-3 segments
    • Update preview immediately when any option changes
    • Display in a styled code/text block
  5. Action Buttons

    • "Cancel" - Close dialog
    • "Export" - Execute export with selected options

4. UI/UX Considerations

  • Disable speaker placement options when "Include speaker information" is unchecked
  • Disable timestamp options when "Include timestamps" is unchecked
  • Show/hide "Separate column/field" option based on selected format
  • Preview should reflect exact export output format
  • Use consistent styling with existing UI (NiceGUI components, existing CSS classes)

Reference Code Locations

  • Current export methods: utils/srt.py lines 332-433
  • Current export UI: pages/srt.py lines 131-171
  • Existing dialog pattern: utils/srt.py lines 1148-1183 (validate_captions dialog)

This pull request was created from Copilot chat.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Implement advanced export module for custom metadata configuration Implement advanced export module with configurable metadata and live preview Dec 17, 2025
Copilot AI requested a review from krihal December 17, 2025 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants