Skip to content

fix(youtube): fall back to HTML when no video content is extracted - #2469

Merged
afourney merged 1 commit into
mainfrom
yt_converter
Sep 11, 2026
Merged

afourney merged 1 commit into
mainfrom
yt_converter

Conversation

@afourney

Copy link
Copy Markdown
Member

Removing the YouTube converter’s title assertion allowed titleless pages to return only  # YouTube  when no video metadata, description, or transcript was extracted. This reported a successful conversion and prevented the generic HTML fallback from preserving useful body content.

This change adds the YouTube heading only after actual content has been extracted. If extraction produces nothing, the converter rewinds the stream to its original position and delegates to  HtmlConverter , preserving the charset and conversion options.

Successful YouTube output remains unchanged, including titleless pages with useful descriptions or library-provided transcripts. Transcript retrieval and its existing error handling are unchanged.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Whitespace-only metadata still suppresses HTML fallback and can discard useful body content.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Adds HTML fallback when YouTube-specific extraction yields no content.

Changes:

  • Defers the YouTube heading until content exists.
  • Rewinds streams and delegates empty results to HtmlConverter.
  • Adds fallback and regression tests.
File summaries
File Description
_youtube_converter.py Implements HTML fallback.
test_youtube_converter.py Tests fallback and preserved output.
test_module_misc.py Updates titleless-page expectations.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 1
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread packages/markitdown/src/markitdown/converters/_youtube_converter.py

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The fallback is correctly implemented and covered across metadata, transcript, charset, stream-position, and dispatcher scenarios.

Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

@afourney
afourney merged commit 5640da7 into main Sep 11, 2026
25 checks passed
@afourney
afourney deleted the yt_converter branch September 11, 2026 22:53
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