Skip to main content

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

Release files for yt-iframe 1.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for yt-iframe 1.0.5
File Size Uploaded
yt_iframe-1.0.5.tar.gz 7.3 kB Details

Release files / yt_iframe-1.0.5.tar.gz

Download URL yt_iframe-1.0.5.tar.gz
Size 7.3 kB
Tags Source
SHA-256 checksum
How to use checksums
635524e0929702edf00d98832740b83b156a0be915652f722652a95db28266bf
BLAKE2b-256 checksum
How to use checksums
024aa6765864e56e967b99203c484fb1d71a6728dc97ea7a8907d090e16faf8b
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

This release

1.0.5 This release

1 release file

1.0.4

1 release file

1.0.3

1 release file

1.0.1

1 release file

1.0.0

1 release file

0.9

1 release file

0.8

1 release file

0.7

1 release file

0.6

1 release file

0.5

1 release file

0.4

1 release file

0.3

1 release file

0.2

1 release file

0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page