Skip to main content

YouTube video iframe generator

Project description

YT iframe Generator

yt_iframe is a python module which can convert a youtube video link into an embeddable iframe. In order to use this module, install it through your terminal.

foo@bar:~$ pip install yt-iframe

# Import statement
from yt_iframe import yt

Using the module

yt.video()

The video() function takes the youtube video link as a string argument. There are width and height optional arguments, so the size of the iframe can be specified. It returns the iframe as a string.

url = 'https://www.youtube.com/watch?v=UzIQOQGKeyI' # (Required)
width = '560' # (Optional)
height = '315' # (Optional)
iframe = yt.video(url, width=width, height=height)

yt.channel()

The channel() function takes a youtube channel link as a string argument. It returns a list of youtube video links.

url = 'https://www.youtube.com/user/ouramazingspace' # (Required)
videolist = yt.channel(url)

yt.channelDict()

The channelDict() function takes a youtube channel link as a string argument. It returns a nested dictionary containing the name of the channel, and video titles.

url = 'https://www.youtube.com/user/ouramazingspace'
videolist = yt.channelDict(url)

videolist['name'] # Name of channel
videolist['videos'] # Nested dictionary. Key = video title, Value = link

yt.getFrames()

The getFrames() function takes a list of youtube videos as a list argument. There are width and height arguments (defaults are 560 and 315 respectively), so the size of the iframes can be specified. There is also a responsive argument (defaults to false) which returns html for responsive iframes. It returns a list of iframes.

channel = yt.channel('https://www.youtube.com/user/ouramazingspace') # (Required)
framewidth = '560' # (Optional)
frameheight = '315' # (Optional)
responsive = True # (Optional)

# Fixed size iframes
iframes = yt.getFrames(channel, width=framewidth, height=frameheight)

# Responsive iframes
iframes = yt.getFrames(channel, responsive=responsive)

yt.linkResponsive()

The linkResponsive() function returns a line of html which links the stylesheet needed for responsive iframes. Alternatively, you can add this line of html in your head tag. ''


yt.videoResponsive()

The videoResponsive() function is similar to the video() function, except it returns the html for a responsive iframe. In order to use responsive iframes, make sure the css file is linked in the html file with the linkResponsive() function. Responsive iframes will either take up 100% of the width of the screen, or 100% the width of their parent element.

url = 'https://www.youtube.com/watch?v=UzIQOQGKeyI' # (Required)

video = yt.videoResponsive(url)

Changelog

== v1.0.3 ==

  • Add responsive iframes

== v1.0.1 ==

  • Allow size of iframe to be specified in video() function
  • Allow sizes of iframes to be specified in getFrames() function

== v1.0.0 ==

  • Initial release

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

yt_iframe-1.0.3.tar.gz (4.5 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page