コード例 #1
0
ファイル: models.py プロジェクト: BakethemPie/tendenci
 def get_code(url, width, height):
     try:
         return OembedlyCache.objects.filter(url=url, width=width, height=height)[0].code
     except IndexError:
         try:
             result = get_oembed(url, format='json', maxwidth=width, maxheight=height)
             thumbnail = result['thumbnail_url']
             code = result['html']
         except KeyError:
             return 'Unable to embed code for video <a href="%s">%s</a>' % (url, url)
         except Exception, e:
             return 'Unable to embed code for video <a href="%s">%s</a><br>Error: %s' % (url, url, e) 
         obj = OembedlyCache(url=url, width=width, height=height, code=code, thumbnail=thumbnail)
         obj.save()
         return code
コード例 #2
0
ファイル: models.py プロジェクト: BakethemPie/tendenci
 def get_thumbnail(url, width, height):
     try:
         return OembedlyCache.objects.filter(url=url, width=width, height=height)[0].thumbnail
     except IndexError:
         try:
             result = get_oembed(url, format='json', maxwidth=width, maxheight=height)
             thumbnail = result['thumbnail_url']
             code = result['html']
         except KeyError:
             return False
         except Exception, e:
             return False
         obj = OembedlyCache(url=url, width=width, height=height, thumbnail=thumbnail, code=code)
         obj.save()
         return thumbnail
コード例 #3
0
ファイル: client.py プロジェクト: djinn/embedly_client
import embedly

# print out response
import pprint
oembed_json = embedly.get_oembed('http://www.youtube.com/watch?v=60og9gwKh1o')
pprint.pprint(oembed_json)