From 4aef73ff85471f87a428d450efbc766a088e3b68 Mon Sep 17 00:00:00 2001 From: Artem Akymenko Date: Wed, 22 Jul 2026 09:16:40 +0000 Subject: [PATCH] refactor: remove infrastructure enum duplicates MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - SubtitleFormat/SubtitleMode now only in domain/enums.py - Added VTT to SubtitleFormat - Renamed SENTENCE_HIGHLIGHTING → SENTENCE_HIGHLIGHT for consistency - Infrastructure subtitle_writer imports from domain --- abogen/domain/enums.py | 3 ++- abogen/domain/subtitle_generation.py | 2 +- abogen/infrastructure/subtitle_writer.py | 15 +-------------- 3 files changed, 4 insertions(+), 16 deletions(-) diff --git a/abogen/domain/enums.py b/abogen/domain/enums.py index c002f3b..5345f5b 100644 --- a/abogen/domain/enums.py +++ b/abogen/domain/enums.py @@ -18,7 +18,7 @@ class SubtitleMode(str, Enum): LINE = "Line" SENTENCE = "Sentence" SENTENCE_COMMA = "Sentence + Comma" - SENTENCE_HIGHLIGHTING = "Sentence + Highlighting" + SENTENCE_HIGHLIGHT = "Sentence + Highlighting" @classmethod def from_str(cls, value: str) -> SubtitleMode: @@ -71,6 +71,7 @@ class SubtitleFormat(str, Enum): """Subtitle file format.""" SRT = "srt" ASS = "ass" + VTT = "vtt" @property def dot_ext(self) -> str: diff --git a/abogen/domain/subtitle_generation.py b/abogen/domain/subtitle_generation.py index cfb461f..e74b9b6 100644 --- a/abogen/domain/subtitle_generation.py +++ b/abogen/domain/subtitle_generation.py @@ -57,7 +57,7 @@ def process_subtitle_tokens( and subtitle_mode in [SubtitleMode.SENTENCE, SubtitleMode.SENTENCE_COMMA] ) - if subtitle_mode == SubtitleMode.SENTENCE_HIGHLIGHTING: + if subtitle_mode == SubtitleMode.SENTENCE_HIGHLIGHT: _process_karaoke_highlighting( processed_tokens, subtitle_entries, max_subtitle_words, fallback_end_time ) diff --git a/abogen/infrastructure/subtitle_writer.py b/abogen/infrastructure/subtitle_writer.py index dcf9610..bbca5b4 100644 --- a/abogen/infrastructure/subtitle_writer.py +++ b/abogen/infrastructure/subtitle_writer.py @@ -6,23 +6,10 @@ from enum import Enum from pathlib import Path from typing import List, Optional, TextIO +from abogen.domain.enums import SubtitleFormat, SubtitleMode from abogen.subtitle_utils import clean_subtitle_text -class SubtitleFormat(Enum): - SRT = "srt" - ASS = "ass" - VTT = "vtt" - - -class SubtitleMode(Enum): - DISABLED = "Disabled" - LINE = "Line" - SENTENCE = "Sentence" - SENTENCE_COMMA = "Sentence + Comma" - SENTENCE_HIGHLIGHT = "Sentence + Highlighting" - - class SubtitleAlignment(Enum): LEFT = "left" CENTER = "center"