fix: YouTubeConverter.accepts() silently drops youtu.be short URLs
Bug Description
The YouTubeConverter.accepts() method in _youtube_converter.py only matches URLs that begin with https://www.youtube.com/watch? and silently rejects all youtu.be short URLs (e.g. https://youtu.be/dQw4w9WgXcQ). This means short YouTube links are never converted — the converter returns False and falls through to a generic HTML converter, producing noisy output instead of a clean transcript.
Reproduction
from markitdown import MarkItDown
md = MarkItDown()
# This works:
result = md.convert("https://www.youtube.com/watch?v=dQw4w9WgXcQ")
# This does NOT go through YouTubeConverter:
result = md.convert("https://youtu.be/dQw4w9WgXcQ")
Root Cause
In packages/markitdown/src/markitdown/converters/_youtube_converter.py, the accepts() method contains:
if not url.startswith("https://www.youtube.com/watch?"):
# Not a YouTube URL
return False
This check must also accept https://youtu.be/<id> and https://www.youtube.com/shorts/<id> URLs.
Expected Fix
The accepts() check should be extended to recognise short URLs and extract the video ID from the youtu.be/<id> path segment, and the convert() method should handle extracting the video ID from both URL forms.
Related
Issue #1704 mentions that short URLs (youtu.be/…) are silently skipped.
I've opened PR #1731 to fix this issue. The fix introduces a shared helper function _extract_youtube_video_id(url) that correctly handles youtu.be/<id> short URLs, youtube.com/shorts/<id> URLs, and the original youtube.com/watch?v=<id> form. Both accepts() and convert() now use this helper, so short-URL transcripts are fetched correctly.
Good day,
I've prepared a fix for this issue. The problem was that YouTubeConverter.accepts() only matched full youtube.com/watch URLs, not short URLs like youtu.be or youtube.com/shorts.
Solution:
- Extended accepts() to recognize all YouTube URL patterns
- Added _extract_video_id() helper to extract video ID from any URL format
- Updated convert() to use the helper for transcript fetching
Complete patch: https://gist.github.com/Jah-yee/1c51d1f327e2d28244a8aa197f296160
Would you like me to submit this as a PR?
感谢你们的奉献,希望能提供帮助。如果我解决得有问题或有待商妥的地方,请在下面留言,我会来处理。
Warmly, RoomWithOutRoof
Good day,
I noticed this issue and wanted to share a fix. The problem is that YouTubeConverter.accepts() only matches URLs starting with , which excludes:
- Short URLs like
- Shorts URLs like
Here is the fix:
In accepts() method (lines 47-51):
In convert() method (lines 149-165):
This allows the converter to handle all YouTube URL formats and extract transcripts properly.
Thank you for your work on this project. I hope this small fix is helpful. Please let me know if there's anything to adjust.
Warmly, RoomWithOutRoof
Bug Description
The
YouTubeConverter.accepts()method in_youtube_converter.pyonly matches URLs that begin withhttps://www.youtube.com/watch?and silently rejects allyoutu.beshort URLs (e.g.https://youtu.be/dQw4w9WgXcQ). This means short YouTube links are never converted — the converter returnsFalseand falls through to a generic HTML converter, producing noisy output instead of a clean transcript.Reproduction
from markitdown import MarkItDown md = MarkItDown()
This works:
result = md.convert("https://www.youtube.com/watch?v=dQw4w9WgXcQ")
This does NOT go through YouTubeConverter:
result = md.convert("https://youtu.be/dQw4w9WgXcQ")
Root Cause
In
packages/markitdown/src/markitdown/converters/_youtube_converter.py, theaccepts()method contains:if not url.startswith("https://www.youtube.com/watch?"): # Not a YouTube URL return False This check must also accept
https://youtu.be/<id>andhttps://www.youtube.com/shorts/<id>URLs.Expected Fix
The
accepts()check should be extended to recognise short URLs and extract the video ID from theyoutu.be/<id>path segment, and theconvert()method should handle extracting the video ID from both URL forms.Related
Issue #1704 mentions that short URLs (
youtu.be/…) are silently skipped.
Open
Bug Description
The
YouTubeConverter.accepts()method in_youtube_converter.pyonly matches URLs that begin withhttps://www.youtube.com/watch?and silently rejects allyoutu.beshort URLs (e.g.https://youtu.be/dQw4w9WgXcQ). This means short YouTube links are never converted — the converter returnsFalseand falls through to a generic HTML converter, producing noisy output instead of a clean transcript.Reproduction
from markitdown import MarkItDown md = MarkItDown()
This works:
result = md.convert("https://www.youtube.com/watch?v=dQw4w9WgXcQ")
This does NOT go through YouTubeConverter:
result = md.convert("https://youtu.be/dQw4w9WgXcQ")
Root Cause
In
packages/markitdown/src/markitdown/converters/_youtube_converter.py, theaccepts()method contains:if not url.startswith("https://www.youtube.com/watch?"): # Not a YouTube URL return False This check must also accept
https://youtu.be/<id>andhttps://www.youtube.com/shorts/<id>URLs.Expected Fix
The
accepts()check should be extended to recognise short URLs and extract the video ID from theyoutu.be/<id>path segment, and theconvert()method should handle extracting the video ID from both URL forms.Related
Issue #1704 mentions that short URLs (
youtu.be/…) are silently skipped.
Bug Description
The YouTubeConverter.accepts() method in _youtube_converter.py only matches URLs that begin with https://www.youtube.com/watch? and silently rejects all youtu.be short URLs (e.g. https://youtu.be/dQw4w9WgXcQ). This means short YouTube links are never converted — the converter returns False and falls through to a generic HTML converter, producing noisy output instead of a clean transcript.
Reproduction
from markitdown import MarkItDown
md = MarkItDown()
# This works:
result = md.convert("https://www.youtube.com/watch?v=dQw4w9WgXcQ")
# This does NOT go through YouTubeConverter:
result = md.convert("https://youtu.be/dQw4w9WgXcQ")
Root Cause
In packages/markitdown/src/markitdown/converters/_youtube_converter.py, the accepts() method contains:
if not url.startswith("https://www.youtube.com/watch?"):
# Not a YouTube URL
return False
This check must also accept https://youtu.be/<id> and https://www.youtube.com/shorts/<id> URLs.
Expected Fix
The accepts() check should be extended to recognise short URLs and extract the video ID from the youtu.be/<id> path segment, and the convert() method should handle extracting the video ID from both URL forms.
Related
Issue #1704 mentions that short URLs (youtu.be/…) are silently skipped.
I appreciate the detailed explanation here, especially the reminder that converted content still needs human review instead of being treated as perfect automatically. For readers comparing tools in this area, the official MarkItDown Online website is worth checking: https://markitdown.store/
Support for youtu.be short URLs was added in #1882. I’m closing this as fixed. Please reopen if a particular short URL still fails against the latest version.