# HG changeset patch # User Brian Neal # Date 1482855697 21600 # Node ID 4da4e32b314c892b26d027b1bf70fea50934a82f # Parent be34f981596e916fd6ccadff77f03df0562b69b8 Do not restrict oEmbed support to just video. This will allow us to embed stuff from SoundClound and ReverbNation. diff -r be34f981596e -r 4da4e32b314c oembed/models.py --- a/oembed/models.py Tue Dec 27 09:31:08 2016 -0600 +++ b/oembed/models.py Tue Dec 27 10:21:37 2016 -0600 @@ -37,6 +37,8 @@ (LINK, "link"), (RICH, "rich"), ) + ALLOWED_TYPES = set(choice[1] for choice in MEDIA_TYPE_CHOICES) + MEDIA_TYPE_REVERSE = {choice[1]: choice[0] for choice in MEDIA_TYPE_CHOICES} url = models.URLField(max_length=255, db_index=True) type = models.IntegerField(choices=MEDIA_TYPE_CHOICES) diff -r be34f981596e -r 4da4e32b314c oembed/views.py --- a/oembed/views.py Tue Dec 27 09:31:08 2016 -0600 +++ b/oembed/views.py Tue Dec 27 10:21:37 2016 -0600 @@ -51,12 +51,13 @@ return HttpResponseBadRequest( "Sorry, we could not retrieve your video (%s)" % e) - if data.get('type') != 'video': + data_type = data.get('type', '?') + if data_type not in Oembed.ALLOWED_TYPES: return HttpResponseBadRequest( - "Hey, this doesn't look like a video..??") + "Hey, this doesn't look like a media type we support..??") oembed = Oembed(url=url, - type=Oembed.VIDEO, + type=Oembed.MEDIA_TYPE_REVERSE[data_type], title=data.get('title', ''), width=int(data.get('width', 0)), height=int(data.get('height', 0)),