kopia lustrzana https://github.com/wagtail/wagtail
Removed requests dependency
rodzic
9023432f5a
commit
c4875dfd4d
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':
|
||||
|
|
Ładowanie…
Reference in New Issue