From beb2d24f8019b7eee4851fa7adf6f6455a521696 2015-12-20 21:20:08 From: Ben Kasel Date: 2015-12-20 21:20:08 Subject: [PATCH] ENH added _repr_jpeg_ method for YouTubeVideo object to allow conversion to latex and pdf. --- diff --git a/IPython/lib/display.py b/IPython/lib/display.py index f65ee41..c50f5fa 100644 --- a/IPython/lib/display.py +++ b/IPython/lib/display.py @@ -255,8 +255,12 @@ class YouTubeVideo(IFrame): """ def __init__(self, id, width=400, height=300, **kwargs): + self.id=id src = "https://www.youtube.com/embed/{0}".format(id) super(YouTubeVideo, self).__init__(src, width, height, **kwargs) + def _repr_jpeg_(self): + from urllib import urlopen + return urlopen("https://img.youtube.com/vi/{id}/0.jpg".format(id=self.id)).read() class VimeoVideo(IFrame): """