diff gpp/oembed/core.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 8fd4984d5c3b
children
line wrap: on
line diff
--- a/gpp/oembed/core.py	Sat Mar 05 02:30:53 2011 +0000
+++ b/gpp/oembed/core.py	Sat Mar 05 03:23:29 2011 +0000
@@ -31,7 +31,7 @@
     api_url = "%s?%s" % (api_endpoint, urllib.urlencode(opts))
 
     headers = {
-        'User-Agent': USER_AGENT, 
+        'User-Agent': USER_AGENT,
         'Accept-Encoding': 'gzip',
     }
     request = urllib2.Request(api_url, headers=headers)
@@ -43,15 +43,15 @@
     f.close()
 
     if headers.get('content-encoding') == 'gzip':
-        with gzip.GzipFile(fileobj=StringIO(result)) as f:
-            result = f.read()
+        f = gzip.GzipFile(fileobj=StringIO(result))
+        result = f.read()
+        f.close()
 
     return json.loads(result)
 
 if __name__ == "__main__":
     try:
         print get_oembed("http://www.youtube.com/oembed",
-                #"http://www.youtube.com/watch?v=7_IMzJldOf4")
-                "http://www.youtube.com/watch?v=99999999999")
+                "http://www.youtube.com/watch?v=7_IMzJldOf4")
     except urllib2.HTTPError, e:
         print e