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)
width = '560' # (Optional)
height = '315' # (Optional)
responsive = True # (Optional)

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

# 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. There are two possible layout options for responsive iframes. singlecolumn takes up 100% the width of the parent element, twocolumn will take up 50% and float left.

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

video = yt.videoResponsive(url, layout=layout) # Get HTML

Changelog

== v1.0.4 ==

  • Add layout argument to videoResponsive() and getFrames()
  • Add two column layout option to videoResponsive()

== v1.0.3 ==

  • Add responsive iframes
  • getFrames() arguments changed from framewidth and frameheight to width and height

== 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.4.tar.gz (4.7 kB view details)

Uploaded Source

File details

Details for the file yt_iframe-1.0.4.tar.gz.

File metadata

  • Download URL: yt_iframe-1.0.4.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.20.1 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.5.2

File hashes

Hashes for yt_iframe-1.0.4.tar.gz
Algorithm Hash digest
SHA256 8ef98cc84399de3dc1902b9fbb167a66e06b03119d6b11249fd0ccdb483e910a
MD5 e19c3aca94b63486b1d6bcc5161ae1e6
BLAKE2b-256 ead32fd776c148f6aecda1349c24d6c26f1965697d7b60078351964357d71e8e

See more details on using hashes here.

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