Back to the overview

Embedding videos in feincms3

I have been using oEmbed services for about 10 years now to embed content from YouTube and Vimeo on other sites, first using feincms-oembed and later using feincms3.plugins.external. This worked well enough despite some problems such as introducing API keys and Noembed being more or less unmaintained since 2017.

However, the requirement to fetch data from a different service always bothered me, especially since all I wanted (most of the time) was to generate a bare <iframe> containing the embed, nothing more.

django-embed-video was almost what I needed but it had some worrysome thumbnail fetching code in there; also I didn’t understand the reason for defining backends, dynamically importing them etc. when all I wanted was a function where I would get back some HTML when passing a supported URL, or nothing if the URL wasn’t supported.

Since I really like writing code1 here’s my solution to embedding YouTube and Vimeo videos as a part of feincms3, feincms3.embedding. Since it doesn’t depend on an external service (except the obvious ones) it is never gonna give you up if you just call:

from feincms3.embedding import embed
html = embed("")

  1. Maybe it’s just a really strong NIH syndrome. Either way, since most other content providers are sadly/luckily irrelevant for the sites I help create and maintain it should be fine. 

© 2005 - 2020 Matthias Kestenholz