diff oembed/views.py @ 907:344f7914d421

Add scheme=https to oembed request. YouTube added this so you could get HTML that used https to embed the video. It seems that Vimeo also supports it.
author Brian Neal <bgneal@gmail.com>
date Sun, 15 Mar 2015 21:48:33 -0500
parents 89b240fe9297
children 4da4e32b314c
line wrap: on
line diff
--- a/oembed/views.py	Sun Mar 08 11:06:07 2015 -0500
+++ b/oembed/views.py	Sun Mar 15 21:48:33 2015 -0500
@@ -43,23 +43,24 @@
         if re.match(provider.url_regex, url):
             try:
                 data = get_oembed(provider.api_endpoint,
-                        url,
-                        maxwidth=settings.OEMBED_MAXWIDTH,
-                        maxheight=settings.OEMBED_MAXHEIGHT)
+                                  url,
+                                  maxwidth=settings.OEMBED_MAXWIDTH,
+                                  maxheight=settings.OEMBED_MAXHEIGHT,
+                                  scheme='https')
             except IOError, e:
                 return HttpResponseBadRequest(
                     "Sorry, we could not retrieve your video (%s)" % e)
 
-            if 'type' not in data or data['type'] != 'video':
+            if data.get('type') != 'video':
                 return HttpResponseBadRequest(
                     "Hey, this doesn't look like a video..??")
 
             oembed = Oembed(url=url,
-                    type=Oembed.VIDEO,
-                    title=data.get('title', ''),
-                    width=int(data.get('width', 0)),
-                    height=int(data.get('height', 0)),
-                    html=data.get('html', ''))
+                            type=Oembed.VIDEO,
+                            title=data.get('title', ''),
+                            width=int(data.get('width', 0)),
+                            height=int(data.get('height', 0)),
+                            html=data.get('html', ''))
             oembed.save()
 
             data = dict(id=oembed.id, embed=oembed.html)