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.
Getting started
In order to use this module, install it through your terminal.
foo@bar:~$ pip install yt-iframe
Import the module in Python.
from yt_iframe import yt
Using the module
yt.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)
Parameters
- link : 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.
Returns
- html : str
- The 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)
Parameters
- link : str (required)
- A link to a YouTube channel.
Returns
- links : list
- A 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 channel
videolist['videos'] # Nested dictionary. Key = video title, Value = link
Parameters
- link : str (required)
- A link to a YouTube channel.
Returns
- channel : dict
- A dictionary of the YouTube channel's information.
- Key/value pairs:
- name = the name of the YouTube channel
- videos = List of video links
yt.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 iframes
iframes = yt.getFrames(channel, width=width, height=height)
# Responsive iframes
iframes = yt.getFrames(channel, responsive=responsive)
Parameters
- links : 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.
Returns
- iframes : list
- List of iFrames.
yt.linkResponsive()
Get link to css for styling the iFrames. Alternatively, you can add this line of html in your head tag. ''
Returns
- str
- HTML link tag to import css for iFrames
yt.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 HTML
Parameters
- link : 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 video
Returns
- iframes : list
- List of iFrames.
Changelog
== v1.0.5 ==
- Fix css import link
- Fix argument error in videoResponsive()
- Fix xml parsing (the lxml dependency issue)
- Add docstrings for all functions
- Refactor 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 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file yt_iframe-1.0.5.tar.gz
.
File metadata
- Download URL: yt_iframe-1.0.5.tar.gz
- Upload date:
- Size: 7.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.4.2 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 635524e0929702edf00d98832740b83b156a0be915652f722652a95db28266bf |
|
MD5 | c2225a8e5f2134fafa5790ab01af22ca |
|
BLAKE2b-256 | 024aa6765864e56e967b99203c484fb1d71a6728dc97ea7a8907d090e16faf8b |