Skip to content

Commit c78dc50

Browse files
committed
Fix import issues and f-string syntax
- Fix f-string formatting in engine.py timestamp function - Add fallback import system in CLI for both package and module usage - Ensure compatibility when running as installed package or as module
1 parent cc6b329 commit c78dc50

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

src/transcriber/cli.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,14 @@
77

88
import click
99

10-
from .engine import TranscriptionEngine
11-
from .downloader import YouTubeDownloader
10+
try:
11+
# Try absolute imports first (when installed as package)
12+
from transcriber.engine import TranscriptionEngine
13+
from transcriber.downloader import YouTubeDownloader
14+
except ImportError:
15+
# Fall back to relative imports (when running as module)
16+
from .engine import TranscriptionEngine
17+
from .downloader import YouTubeDownloader
1218

1319

1420
@click.group()

src/transcriber/engine.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,9 @@ def _format_timestamp(self, seconds: float, vtt: bool = False) -> str:
145145
seconds = seconds % 60
146146

147147
if vtt:
148-
return f"{hours"02d"}:{minutes"02d"}:{seconds"06.3f"}".replace(".", ",")
148+
return f"{hours:02d}:{minutes:02d}:{seconds:06.3f}".replace(".", ",")
149149
else:
150-
return f"{hours"02d"}:{minutes"02d"}:{seconds"06.3f"}"
150+
return f"{hours:02d}:{minutes:02d}:{seconds:06.3f}"
151151

152152
def _clean_result_for_json(self, result: Dict[str, Any]) -> Dict[str, Any]:
153153
"""Remove non-serializable data from result."""

0 commit comments

Comments
 (0)