Mercurial > public > sg101
comparison gpp/oembed/views.py @ 361:6d6fdc58487c
Changes to oembed to support vimeo.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sat, 05 Mar 2011 03:23:29 +0000 |
parents | 47a7138fcccb |
children |
comparison
equal
deleted
inserted
replaced
360:2e90b63520b8 | 361:6d6fdc58487c |
---|---|
6 | 6 |
7 from django.http import HttpResponse | 7 from django.http import HttpResponse |
8 from django.http import HttpResponseBadRequest | 8 from django.http import HttpResponseBadRequest |
9 from django.http import HttpResponseForbidden | 9 from django.http import HttpResponseForbidden |
10 import django.utils.simplejson as json | 10 import django.utils.simplejson as json |
11 from django.conf import settings | |
11 | 12 |
12 from oembed.models import Provider | 13 from oembed.models import Provider |
13 from oembed.models import Oembed | 14 from oembed.models import Oembed |
14 from oembed.core import get_oembed | 15 from oembed.core import get_oembed |
15 | 16 |
39 # It isn't in the database, try to find it from our providers | 40 # It isn't in the database, try to find it from our providers |
40 providers = Provider.objects.all() | 41 providers = Provider.objects.all() |
41 for provider in providers: | 42 for provider in providers: |
42 if re.match(provider.url_regex, url): | 43 if re.match(provider.url_regex, url): |
43 try: | 44 try: |
44 data = get_oembed(provider.api_endpoint, url) | 45 data = get_oembed(provider.api_endpoint, |
46 url, | |
47 maxwidth=settings.OEMBED_MAXWIDTH, | |
48 maxheight=settings.OEMBED_MAXHEIGHT) | |
45 except IOError, e: | 49 except IOError, e: |
46 return HttpResponseBadRequest( | 50 return HttpResponseBadRequest( |
47 "Sorry, we could not retrieve your video (%s)" % e) | 51 "Sorry, we could not retrieve your video (%s)" % e) |
48 | 52 |
49 if 'type' not in data or data['type'] != 'video': | 53 if 'type' not in data or data['type'] != 'video': |