Skip to content

fix: subtitle structured output format and remove redundant items field - #10

Open
guowenfh wants to merge 1 commit into
public-clis:mainfrom
guowenfh:fix/subtitle-output
Open

fix: subtitle structured output format and remove redundant items field#10
guowenfh wants to merge 1 commit into
public-clis:mainfrom
guowenfh:fix/subtitle-output

Conversation

@guowenfh

Copy link
Copy Markdown

Summary

  • Fix --subtitle-format srt not producing actual SRT formatted text in structured output (--json/--yaml)
  • Remove redundant items field from subtitle payload — keep only text for AI/human consumers
  • Clean up unused normalize_subtitle_items function

Changes

  • bili_cli/commands/video.py: Compute formatted text based on subtitle_format and pass to payload
  • bili_cli/payloads.py:
    • Add subtitle_formatted_text parameter to normalize_video_command_payload
    • Use formatted text when available, fallback to plain text
    • Remove items field from subtitle payload
    • Remove unused normalize_subtitle_items function
  • tests/test_cli.py: Update test to verify timeline format text instead of items

Before

{
  "subtitle": {
    "available": true,
    "format": "srt",
    "text": "plain text...",  // ❌ not SRT format
    "items": [...]            // redundant
  }
}

After

{
  "subtitle": {
    "available": true,
    "format": "srt",
    "text": "1\n00:00:00,121 --> 00:00:05,121\n永不放弃你...\n\n2\n..."  // ✅ actual SRT
  }
}

- Fix --subtitle-format srt not producing actual SRT text in structured output
- Add subtitle_formatted_text param to normalize_video_command_payload
- Remove items field from subtitle payload (keep only text for AI/human consumers)
- Remove unused normalize_subtitle_items function
- Update test to verify timeline format text instead of items
@guowenfh

Copy link
Copy Markdown
Author

Expected to save about 45% tokens

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