Merge lp:~mhall119/summit/support-short-broadcast-url into lp:summit

Proposed by Michael Hall
Status: Merged
Approved by: Michael Hall
Approved revision: 499
Merged at revision: 500
Proposed branch: lp:~mhall119/summit/support-short-broadcast-url
Merge into: lp:summit
Diff against target: 24 lines (+4/-0)
1 file modified
summit/schedule/forms.py (+4/-0)
To merge this branch: bzr merge lp:~mhall119/summit/support-short-broadcast-url
Reviewer Review Type Date Requested Status
Adnane Belmadiaf Approve
Review via email: mp+151626@code.launchpad.net

Commit message

Add broadcast_url form field parsing for youtube's short url

Description of the change

Add broadcast_url form field parsing for youtube's short url

To post a comment you must log in.
Revision history for this message
Adnane Belmadiaf (daker) wrote :

+1 from me

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'summit/schedule/forms.py'
2--- summit/schedule/forms.py 2013-03-01 21:01:51 +0000
3+++ summit/schedule/forms.py 2013-03-04 21:50:25 +0000
4@@ -190,16 +190,20 @@
5 import re
6 YOUTUBE_EMBED_HTML = re.compile(r'\<iframe width="\d+" height="\d+" src="https?:\/\/www.youtube.com\/embed\/(?P<youtube_id>.*)" frameborder="0" allowfullscreen\>\<\/iframe\>')
7 YOUTUBE_PAGE_URL = re.compile(r'https?:\/\/www.youtube.com\/watch\?v=(?P<youtube_id>[^&]*).*')
8+YOUTUBE_SHORT_URL = re.compile(r'https?:\/\/youtu.be\/(?P<youtube_id>[^\?]*).*')
9
10 class YouTubeEmbedURL(forms.URLField):
11
12 def clean(self, value):
13 match_html = YOUTUBE_EMBED_HTML.match(value)
14 match_page = YOUTUBE_PAGE_URL.match(value)
15+ match_short = YOUTUBE_SHORT_URL.match(value)
16 if match_html:
17 value = 'http://www.youtube.com/embed/' + match_html.group('youtube_id')
18 elif match_page:
19 value = 'http://www.youtube.com/embed/' + match_page.group('youtube_id')
20+ elif match_short:
21+ value = 'http://www.youtube.com/embed/' + match_short.group('youtube_id')
22 else:
23 pass
24 return value

Subscribers

People subscribed via source and target branches