Skip to content

Commit c95482e

Browse files
committed
removing simplejson dependency
1 parent 192b2c6 commit c95482e

2 files changed

Lines changed: 8 additions & 9 deletions

File tree

magicembed/providers.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from urlparse import parse_qs
22
import re
33
import urllib
4-
import simplejson
4+
from django.utils import simplejson
55

66
class Provider(object):
77

@@ -10,16 +10,16 @@ def __init__(self, url, size = (640, 480)):
1010
self.size = size
1111

1212
def render_video(self):
13-
'''simply returns html to render embed
13+
'''simply returns html to render embed
1414
video in a template'''
1515
raise NotImplementedError
16-
16+
1717
def render_thumbnail(self, link_to):
1818
'''Renders the html with a link_to a parameter'''
1919
raise NotImplementedError
2020

2121
class Youtube(Provider):
22-
22+
2323
def __init__(self, url, size = (640, 480)):
2424
super(Youtube, self).__init__(url, size)
2525
qs = url.split('?')
@@ -40,10 +40,10 @@ def __init__(self, url, size=(640, 480)):
4040
pattern = re.compile('http://(?:www\.)?vimeo\.com/([0-9]{1,12})')
4141
self.video_id = pattern.match(url).groups()[0]
4242
self.api_url = 'http://vimeo.com/api/v2/video/%s.json' % self.video_id
43-
43+
4444
def render_video(self):
4545
html = '''<iframe src="http://player.vimeo.com/video/%s" width="%d" height="%d" frameborder="0"></iframe><p><a href="http://vimeo.com/%s">Das Pop: The Game</a> from <a href="http://vimeo.com/bigactive">Big Active</a> on <a href="http://vimeo.com">Vimeo</a>.</p>'''
46-
return html % (self.video_id, self.size[0],
46+
return html % (self.video_id, self.size[0],
4747
self.size[1], self.video_id)
4848

4949
def render_thumbnail(self, link_to="#"):
@@ -57,7 +57,7 @@ def __init__(self, url, size=(640, 480)):
5757
self.api_url = 'http://api.embed.ly/1/oembed?url=%s&maxwidth=%s&format=json' % (url, size[0])
5858

5959
def render_video(self):
60-
return self._call_api()['html']
60+
return self._call_api()['html']
6161

6262
def render_thumbnail(self):
6363
return self._call_api()['thumbnail_url']
@@ -68,7 +68,7 @@ def _call_api(self):
6868

6969
def get_provider(url, size=None):
7070
'''returns a provider instance acording to the url'''
71-
provider_domain = dict(youtube=Youtube, vimeo=Vimeo)
71+
provider_domain = dict(youtube=Youtube, vimeo=Vimeo)
7272
for domain, provider in provider_domain.items():
7373
if domain in url:
7474
return provider(url, size) if size else provider(url)

setup.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
install_requires = [
1212
'Django>=1.0',
13-
'simplejson',
1413
]
1514

1615
setup(

0 commit comments

Comments
 (0)