Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates to the youtube regex #3

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 6 additions & 3 deletions embed_video/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
import json

DETECT_YOUTUBE = re.compile(
r'^(http(s)?://(www\.)?)?youtu(\.?)be(\.com)?.*', re.I
# r'^(http(s)?://(www\.)?)?youtu(\.?)be(\.com)?.*', re.I
r'(?:www.|)?youtu(\.?)be(\.com)?.*', re.I
)
DETECT_VIMEO = re.compile(
r'^(http(s)?://(www\.)?)?vimeo\.com.*', re.I
Expand All @@ -23,7 +24,7 @@ class UnknownIdException(Exception):


def detect_backend(url):
if DETECT_YOUTUBE.match(url):
if DETECT_YOUTUBE.search(url):
return YoutubeBackend(url)
elif DETECT_VIMEO.match(url):
return VimeoBackend(url)
Expand Down Expand Up @@ -87,7 +88,9 @@ def get_code(self):

class YoutubeBackend(VideoBackend):
re_code = re.compile(
r'youtu(?:be\.com/watch\?v=|\.be/)(?P<code>[\w-]*)(&(amp;)?[\w\?=]*)?',
r'(?:http|https|)(?::\/\/|)(?:www.|)(?:youtu\.be\/|youtube\.com(?:\/embed\/|\/v\/|\/watch\?v=|\/ytscreeningroom\?v=|\/feeds\/api\/videos\/|\/user\S*[^\w\-\s]|\S*[^\w\-\s]))(?P<code>[\w\-]{11})[a-z0-9;:@?&%=+\/\$_.-]*',
# r'(?:http|https|)(?::\/\/|)(?:www.|)(?:youtu\.be\/|youtube\.com(?:\/embed\/|\/v\/|\/watch\?v=|\/ytscreeningroom\?v=|\/feeds\/api\/videos\/|\/user\S*[^\w\-\s]|\S*[^\w\-\s]))(?P<code>[\w\-]{11})[a-z0-9;:@?&%=+\/\$_.-]*',
# r'youtu(?:be\.com/watch\?v=|\.be/)(?P<code>[\w-]*)(&(amp;)?[\w\?=]*)?',
re.I
)
pattern_url = 'http://www.youtube.com/embed/%s?wmode=opaque'
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def read(fname):
setup(
name='django-embed-video',
packages=find_packages(),
version='0.2.0',
version='0.2.3',
author='Juda Kaleta',
author_email='juda.kaleta@gmail.com',
url='https://github.com/yetty/django-embed-video',
Expand Down