mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-04-11 02:20:59 +00:00
Merge branch 'master' of github.com:torchbox/wagtail
This commit is contained in:
commit
e32fdcd6ce
3 changed files with 12 additions and 6 deletions
|
|
@ -1,4 +1,7 @@
|
|||
[](https://travis-ci.org/torchbox/wagtail)
|
||||
|BuildStatus|_
|
||||
|
||||
.. |BuildStatus| image:: https://travis-ci.org/torchbox/wagtail.png?branch=master
|
||||
.. _BuildStatus: https://travis-ci.org/torchbox/wagtail
|
||||
|
||||
Wagtail CMS
|
||||
===========
|
||||
|
|
|
|||
1
setup.py
1
setup.py
|
|
@ -48,7 +48,6 @@ setup(
|
|||
"beautifulsoup4>=4.3.2",
|
||||
"lxml>=3.3.0",
|
||||
"BeautifulSoup==3.2.1", # django-compressor gets confused if we have lxml but not BS3 installed
|
||||
"requests==2.2.1",
|
||||
],
|
||||
zip_safe=False,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
import sys
|
||||
from importlib import import_module
|
||||
import requests
|
||||
from django.conf import settings
|
||||
from datetime import datetime
|
||||
from django.utils import six
|
||||
from wagtail.wagtailembeds.oembed_providers import get_oembed_provider
|
||||
from wagtail.wagtailembeds.models import Embed
|
||||
import urllib2, urllib
|
||||
import json
|
||||
|
||||
|
||||
class EmbedNotFoundException(Exception): pass
|
||||
|
|
@ -91,10 +92,13 @@ def oembed(url, max_width=None):
|
|||
params['maxwidth'] = max_width
|
||||
|
||||
# Perform request
|
||||
r = requests.get(provider, params=params)
|
||||
if r.status_code != 200:
|
||||
request = urllib2.Request(provider + '?' + urllib.urlencode(params))
|
||||
request.add_header('User-agent', 'Mozilla/5.0')
|
||||
try:
|
||||
r = urllib2.urlopen(request)
|
||||
except urllib2.URLError:
|
||||
raise EmbedNotFoundException
|
||||
oembed = r.json()
|
||||
oembed = json.loads(r.read())
|
||||
|
||||
# Convert photos into HTML
|
||||
if oembed['type'] == 'photo':
|
||||
|
|
|
|||
Loading…
Reference in a new issue