YouTube video in IPython notebook

1,734 views
Skip to first unread message

Ivica Nakić

unread,
Jan 26, 2014, 6:00:30 AM1/26/14
to sage-...@googlegroups.com
Hi,

when using IPython Notebook in SMC,

this doesn't work:

from IPython.display import YouTubeVideo
YouTubeVideo('YyEReiAYGlU')

There is empty space beneath the cell, no errors.

But this does work as expected:

from IPython.display import HTML
HTML
('<iframe width="560" height="315" src="//www.youtube.com/embed/YyEReiAYGlU" frameborder="0" allowfullscreen></iframe>')

The browser is Chrome 32 on OS X 10.9. 


Ivica

Harald Schilly

unread,
Jan 27, 2014, 2:47:07 PM1/27/14
to sage-...@googlegroups.com
The generated code by IPython is

<iframe width="400" height="300&quot;" src="http://www.youtube.com/embed/YyEReiAYGlU" frameborder="0" allowfullscreen=""></iframe>

... hence it cannot work. Maybe, somebody should post that as an upstream ticket (easy to fix) or search if there already exists one?

Harald

Ivica Nakić

unread,
Jan 28, 2014, 12:32:44 AM1/28/14
to sage-...@googlegroups.com
The code works in the local IPython notebook on my computer, and the versions on my computer and SMC are the same (1.1.0). So I don't see how that can be an upstream bug. 
The same thing happens on SMC also for IPython notebook which is run from the terminal.

Ivica

William Stein

unread,
Jan 28, 2014, 12:46:44 AM1/28/14
to sage-...@googlegroups.com, IPython Development list
I'm cross-posting this to ipython-dev. It's about user doing

from IPython.display import YouTubeVideo
YouTubeVideo('YyEReiAYGlU')

and it not working when using IPython in SageMathCloud
(https://cloud.sagemath.com), which is a hosted IPython service.
See below -- the problem is that the iframe grabs the http youtube
site instead of https...

On Mon, Jan 27, 2014 at 9:32 PM, Ivica Nakić <zzi...@gmail.com> wrote:
> The code works in the local IPython notebook on my computer, and the
> versions on my computer and SMC are the same (1.1.0). So I don't see how
> that can be an upstream bug.
> The same thing happens on SMC also for IPython notebook which is run from
> the terminal.

I think Harald didn't explain himself very clearly. IPython outputs

<iframe width="400" height="300;"
src="http://www.youtube.com/embed/YyEReiAYGlU" frameborder="0"
allowfullscreen=""></iframe>

and indeed this can't work in SMC, because SMC is served securely over
SSL. Instead, what IPython needs to do is output

<iframe width="400" height="300;"
src="https://www.youtube.com/embed/YyEReiAYGlU" frameborder="0"
allowfullscreen=""></iframe>

In fact, I just tried changing the http to https using the Chrome
debugger, and the video then works fine.
The IPython source code has http (instead of https) hard coded, unfortunately.

William


>
> Ivica
>
>
> Dana ponedjeljak, 27. siječnja 2014. 20:47:07 UTC+1, korisnik Harald Schilly
> napisao je:
>>
>> The generated code by IPython is
>>
>> <iframe width="400" height="300&quot;"
>> src="http://www.youtube.com/embed/YyEReiAYGlU" frameborder="0"
>> allowfullscreen=""></iframe>
>>
>> ... hence it cannot work. Maybe, somebody should post that as an upstream
>> ticket (easy to fix) or search if there already exists one?
>>
>> Harald
>>
> --
> You received this message because you are subscribed to the Google Groups
> "sage-cloud" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sage-cloud+...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sage-cloud/7fe1f328-e513-46f2-99eb-2be527852391%40googlegroups.com.
>
> For more options, visit https://groups.google.com/groups/opt_out.



--
William Stein
Professor of Mathematics
University of Washington
http://wstein.org

Ivica Nakić

unread,
Jan 28, 2014, 12:56:25 AM1/28/14
to sage-...@googlegroups.com, IPython Development list
OK, I see. 
I missed http(s) part, thought the problem is in height="300&quot;"
but that was just copy-paste thing.

Thanks for the help.

Harald Schilly

unread,
Jan 28, 2014, 4:50:44 AM1/28/14
to sage-...@googlegroups.com, IPython Development list
On Tue, Jan 28, 2014 at 6:46 AM, William Stein <wst...@gmail.com> wrote:
> Instead, what IPython needs to do is output
>
> <iframe width="400" height="300;"
> src="https://www.youtube.com/embed/YyEReiAYGlU" frameborder="0"
> allowfullscreen=""></iframe>


Err sorry, I thought it is obvious. what it should do is what the OP
posted in the first email!

https://groups.google.com/d/msg/sage-cloud/NotysYVKjrw/CXoQiDk-B1oJ

i.e.
src="//www.youtube.com/embed/YyEReiAYGlU"

double "//" in the beginning!

Harald
Reply all
Reply to author
Forward
0 new messages