Skip to content

Carry rounded transcript timestamps#610

Open
CodingFeng101 wants to merge 1 commit into
jdepoix:masterfrom
CodingFeng101:codex/normalize-timestamp-rounding
Open

Carry rounded transcript timestamps#610
CodingFeng101 wants to merge 1 commit into
jdepoix:masterfrom
CodingFeng101:codex/normalize-timestamp-rounding

Conversation

@CodingFeng101

Copy link
Copy Markdown

What changed

_seconds_to_timestamp() now rounds the whole timestamp to milliseconds first, then splits that total into hours, minutes, seconds, and milliseconds.

Why

The previous implementation truncated the seconds component before rounding the fractional milliseconds. Values near a second boundary, such as 1.9996, formatted as 00:00:01,999 instead of carrying to 00:00:02,000. The same helper is used by SRT and WebVTT formatting.

Validation

  • python -m pytest youtube_transcript_api\test\test_formatters.py -q
  • python -m pytest youtube_transcript_api -q
  • python -m ruff check youtube_transcript_api\formatters.py youtube_transcript_api\test\test_formatters.py
  • python -m ruff format --check youtube_transcript_api\formatters.py youtube_transcript_api\test\test_formatters.py
  • git diff --check

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.

1 participant