datasette-youtube-embed by simonw

25 downloads this week        Star

README source code

datasette-youtube-embed

PyPI Changelog Tests License

Turn YouTube URLs into embedded players in Datasette

Installation

Install this plugin in the same environment as Datasette.

datasette install datasette-youtube-embed

Usage

Once installed, any columns containing URLs that look like one of these:

  • https://www.youtube.com/watch?v=xyz
  • https://www.youtube.com/watch?v=xyz&start=30
  • https://www.youtube.com/watch?v=xyz&start=30&end=50

Will be turned into YouTube embeds like this:

<lite-youtube videoid="xyz" params="start=30" style="min-width: 200px"></lite-youtube>

These will then be rendered using Lite YouTube Embed, which avoids loading the full YouTube embed until someone interacts with it.

Development

To set up this plugin locally, first checkout the code. Then create a new virtual environment:

cd datasette-youtube-embed
python3 -m venv venv
source venv/bin/activate

Now install the dependencies and test dependencies:

pip install -e '.[test]'

To run the tests:

pytest