##// END OF EJS Templates
Merge pull request #9086 from bkasel/master...
Min RK -
r21883:fa27f966 merge
parent child Browse files
Show More
@@ -252,11 +252,25 b' class YouTubeVideo(IFrame):'
252
252
253 Other parameters can be provided as documented at
253 Other parameters can be provided as documented at
254 https://developers.google.com/youtube/player_parameters#parameter-subheader
254 https://developers.google.com/youtube/player_parameters#parameter-subheader
255
256 When converting the notebook using nbconvert, a jpeg representation of the video
257 will be inserted in the document.
255 """
258 """
256
259
257 def __init__(self, id, width=400, height=300, **kwargs):
260 def __init__(self, id, width=400, height=300, **kwargs):
261 self.id=id
258 src = "https://www.youtube.com/embed/{0}".format(id)
262 src = "https://www.youtube.com/embed/{0}".format(id)
259 super(YouTubeVideo, self).__init__(src, width, height, **kwargs)
263 super(YouTubeVideo, self).__init__(src, width, height, **kwargs)
264
265 def _repr_jpeg_(self):
266 try:
267 from urllib.request import urlopen # Py3
268 except ImportError:
269 from urllib2 import urlopen
270 try:
271 return urlopen("https://img.youtube.com/vi/{id}/hqdefault.jpg".format(id=self.id)).read()
272 except IOError:
273 return None
260
274
261 class VimeoVideo(IFrame):
275 class VimeoVideo(IFrame):
262 """
276 """
General Comments 0
You need to be logged in to leave comments. Login now