fix: support youtu.be short URLs in YouTubeConverter.accepts()#1731
Open
kuishou68 wants to merge 1 commit intomicrosoft:mainfrom
Open
fix: support youtu.be short URLs in YouTubeConverter.accepts()#1731kuishou68 wants to merge 1 commit intomicrosoft:mainfrom
kuishou68 wants to merge 1 commit intomicrosoft:mainfrom
Conversation
…microsoft#1730) Signed-off-by: cocoon <54054995+kuishou68@users.noreply.github.com>
Author
@microsoft-github-policy-service agree company="Microsoft" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1730
Problem
YouTubeConverter.accepts()only matchedhttps://www.youtube.com/watch?URLs. Anyyoutu.be/<id>short URL oryoutube.com/shorts/<id>URL returnedFalse, falling through to a generic HTML converter and producing noisy unconverted output.Additionally, the
convert()method extracted the video ID only viaparse_qs(urlparse(...).query)["v"], which also fails for short and Shorts URLs.Fix
_extract_youtube_video_id(url)that handles three URL forms:https://www.youtube.com/watch?v=ID(existing)https://youtu.be/ID(short URL — previously broken)https://www.youtube.com/shorts/ID(Shorts — previously broken)accepts()to use this helper — it now returnsTruefor all three forms.convert()to use the same helper when extracting the video ID for transcript fetching, replacing the oldparse_qsapproach that silently returned no ID for short URLs.Signed-off-by: cocoon 54054995+kuishou68@users.noreply.github.com