comparison oembed/views.py @ 1154:4da4e32b314c

Do not restrict oEmbed support to just video. This will allow us to embed stuff from SoundClound and ReverbNation.
author Brian Neal <bgneal@gmail.com>
date Tue, 27 Dec 2016 10:21:37 -0600
parents 344f7914d421
children
comparison
equal deleted inserted replaced
1153:be34f981596e 1154:4da4e32b314c
49 scheme='https') 49 scheme='https')
50 except IOError, e: 50 except IOError, e:
51 return HttpResponseBadRequest( 51 return HttpResponseBadRequest(
52 "Sorry, we could not retrieve your video (%s)" % e) 52 "Sorry, we could not retrieve your video (%s)" % e)
53 53
54 if data.get('type') != 'video': 54 data_type = data.get('type', '?')
55 if data_type not in Oembed.ALLOWED_TYPES:
55 return HttpResponseBadRequest( 56 return HttpResponseBadRequest(
56 "Hey, this doesn't look like a video..??") 57 "Hey, this doesn't look like a media type we support..??")
57 58
58 oembed = Oembed(url=url, 59 oembed = Oembed(url=url,
59 type=Oembed.VIDEO, 60 type=Oembed.MEDIA_TYPE_REVERSE[data_type],
60 title=data.get('title', ''), 61 title=data.get('title', ''),
61 width=int(data.get('width', 0)), 62 width=int(data.get('width', 0)),
62 height=int(data.get('height', 0)), 63 height=int(data.get('height', 0)),
63 html=data.get('html', '')) 64 html=data.get('html', ''))
64 oembed.save() 65 oembed.save()