Package: yt-iframe
YT iframe Generatoryt_iframeis a python module which can convert a youtube video link into an embeddable iframe.Getting startedIn order to use this module, install it through your terminal.foo@bar:~$pipinstallyt-iframeImport the module in Python.fromyt_iframeimportytUsing the moduleyt.video()Generates a YouTube embed video iFrame from a YouTube video link.url='https://www.youtube.com/watch?v=UzIQOQGKeyI'# (Required)width='560'# (Optional)height='315'# (Optional)iframe=yt.video(url,width=width,height=height)Parameterslink : str(required)A link to a YouTube video.width : str(optional. default="560")The width of the iFrame in pixels.height : str(optional. default="315")The height of the iFrame in pixels.Returnshtml : strThe iFrame for the YouTube video.yt.channel()Generates a list of YouTube video links from a YouTube channel.url='https://www.youtube.com/user/ouramazingspace'# (Required)videolist=yt.channel(url)Parameterslink : str(required)A link to a YouTube channel.Returnslinks : listA list of links to YouTube videos.yt.channelDict()Generates videos and metadata from a YouTube channel.url='https://www.youtube.com/user/ouramazingspace'videolist=yt.channelDict(url)videolist['name']# Name of channelvideolist['videos']# Nested dictionary. Key = video title, Value = linkParameterslink : str(required)A link to a YouTube channel.Returnschannel : dictA dictionary of the YouTube channel's information.Key/value pairs:name = the name of the YouTube channelvideos = List of video linksyt.getFrames()Generates a list of iFrames from a list of YouTube videos.channel=yt.channel('https://www.youtube.com/user/ouramazingspace')# (Required)width='560'# (Optional)height='315'# (Optional)responsive=True# (Optional)# Fixed size iframesiframes=yt.getFrames(channel,width=width,height=height)# Responsive iframesiframes=yt.getFrames(channel,responsive=responsive)Parameterslinks : list(required)_A list of links to YouTube videos.width : str(optional. default="560")The width of each iFrame in pixels.height : str(optional. default="315")The height of each iFrame in pixels.responsive : bool(optional. default = False)Determines whether each iFrame is dynamically or statically sized.Returnsiframes : listList of iFrames.yt.linkResponsive()Get link to css for styling the iFrames.
Alternatively, you can add this line of html in your head tag.
''ReturnsstrHTML link tag to import css for iFramesyt.videoResponsive()Generates a responsive iFrame video. Make sure you have the css file imported with the linkResponsive() function. You can wrap a bunch of these generated tags in a container and the iFrames will resize to fit the layout within that container.url='https://www.youtube.com/watch?v=UzIQOQGKeyI'# (Required)layout='singlecolumn'# (Optional)video=yt.videoResponsive(url,layout=layout)# Get HTMLParameterslink : str(required)A link to a YouTube video.layout : str(optional. default="onecolumn")Soecifies the relative size of the iFrame.Acceptable values:'onecolumn' - Generates one column layout'twocolumn' - Generates two column videoReturnsiframes : listList of iFrames.Changelog== v1.0.5 ==Fix css import linkFix argument error in videoResponsive()Fix xml parsing (the lxml dependency issue)Add docstrings for all functionsRefactor functions to improve readability== v1.0.4 ==Add layout argument to videoResponsive() and getFrames()Add two column layout option to videoResponsive()== v1.0.3 ==Add responsive iframesgetFrames() arguments changed from framewidth and frameheight to width and height== v1.0.1 ==Allow size of iframe to be specified in video() functionAllow sizes of iframes to be specified in getFrames() function== v1.0.0 ==Initial release