Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Youtube link regex fails for youtu.be links. #55
Comments
|
An annotated version of the above, which is not as verbose as it could be, but attempts some explanation of parts: |
|
Fixed. Thanks. |
Given the example link "http://youtu.be/watch?v=COiIC3A0ROM"
and the _VALID_URL regex present in the Jan 7 checkout, the groups() results are as follows:
('http://youtu.be/', 'watch')
The fix for the regex is a parenthesis that is placed too late. There should be an extra one after the ".com/" part, closing the optional matching group for youtu.be | \w+.youtube.com.
The regular expression that "works for me" is as follows:
_VALID_URL = r'^((?:https?://)?(?:youtu.be/|(?:\w+.)?youtube(?:-nocookie)?.com/)(?:(?:v/)|(?:(?:watch(?:popup)?(?:.php)?)?(?:?|#!?)(?:.+&)?v=)))?([0-9A-Za-z-]+)(?(1).+)?$'