##// END OF EJS Templates
Simplify heading structure, and only document __init__ when present.
Simplify heading structure, and only document __init__ when present.

File last commit:

r8680:2efeba04
r8794:2c650997
Show More
display.py
51 lines | 1.4 KiB | text/x-python | PythonLexer
Brian E. Granger
Added lib/display.py for extra display related things.
r4408 """Various display related classes.
Danny Staple
Adding myself as an author
r8665 Authors : MinRK, dannystaple
Brian E. Granger
Added lib/display.py for extra display related things.
r4408 """
Danny Staple
Swapped specific start param for any params...
r8645 import urllib
Brian E. Granger
Added lib/display.py for extra display related things.
r4408
class YouTubeVideo(object):
"""Class for embedding a YouTube Video in an IPython session, based on its video id.
Bernardo B. Marques
remove all trailling spaces
r4872
Brian E. Granger
Added lib/display.py for extra display related things.
r4408 e.g. to embed the video on this page:
Bernardo B. Marques
remove all trailling spaces
r4872
Brian E. Granger
Added lib/display.py for extra display related things.
r4408 http://www.youtube.com/watch?v=foo
Bernardo B. Marques
remove all trailling spaces
r4872
Brian E. Granger
Added lib/display.py for extra display related things.
r4408 you would do:
Bernardo B. Marques
remove all trailling spaces
r4872
Brian E. Granger
Added lib/display.py for extra display related things.
r4408 vid = YouTubeVideo("foo")
display(vid)
Danny Staple
Adding time offsets to the video...
r8639
Danny Staple
Swapped specific start param for any params...
r8645 To start from 30 seconds:
Danny Staple
Adding time offsets to the video...
r8639
Danny Staple
Swapped specific start param for any params...
r8645 vid = YouTubeVideo("abc", start=30)
Danny Staple
Adding time offsets to the video...
r8639 display(vid)
Danny Staple
Swapped specific start param for any params...
r8645
Danny Staple
Shortening documentation line length. ...
r8666 To calculate seconds from time as hours, minutes, seconds use:
start=int(timedelta(hours=1, minutes=46, seconds=40).total_seconds())
Danny Staple
Fixed some silly mistakes...
r8651
Danny Staple
Swapped specific start param for any params...
r8645 Other parameters can be provided as documented at
https://developers.google.com/youtube/player_parameters#parameter-subheader
Brian E. Granger
Added lib/display.py for extra display related things.
r4408 """
Bernardo B. Marques
remove all trailling spaces
r4872
Danny Staple
Swapped specific start param for any params...
r8645 def __init__(self, id, width=400, height=300, **kwargs):
Brian E. Granger
Added lib/display.py for extra display related things.
r4408 self.id = id
self.width = width
self.height = height
Danny Staple
Fixed some silly mistakes...
r8651 self.params = kwargs
Bernardo B. Marques
remove all trailling spaces
r4872
Brian E. Granger
Added lib/display.py for extra display related things.
r4408 def _repr_html_(self):
"""return YouTube embed iframe for this video id"""
Danny Staple
Swapped specific start param for any params...
r8645 if self.params:
params = "?" + urllib.urlencode(self.params)
else:
params = ""
Brian E. Granger
Added lib/display.py for extra display related things.
r4408 return """
Bernardo B. Marques
remove all trailling spaces
r4872 <iframe
width="%i"
height="%i"
Danny Staple
Swapped specific start param for any params...
r8645 src="http://www.youtube.com/embed/%s%s"
Bernardo B. Marques
remove all trailling spaces
r4872 frameborder="0"
Brian E. Granger
Added lib/display.py for extra display related things.
r4408 allowfullscreen
></iframe>
Danny Staple
Add newline, spaces on string format...
r8680 """ % (self.width, self.height, self.id, params)