Skip to content

Commit

Permalink
Allow embedding YouTube live videos
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiask committed Nov 18, 2024
1 parent 0653758 commit 1fd6e8c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Next version
- Updated all pre-commit hooks.
- Added the ``RedirectMixin.admin_fieldset`` convenience method.
- Added Python 3.13 to the CI.
- Added support for YouTube live URLs to the embedding code.


5.2 (2024-06-07)
Expand Down
2 changes: 1 addition & 1 deletion feincms3/embedding.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
YOUTUBE_RE = re.compile(
r"""youtu(\.?)be(\.com)?/ # match youtube's domains
(\#/)? # for mobile urls
(embed/|shorts/|watch/)? # match the embed/shorts/watch url syntax
(embed/|shorts/|watch/|live/)? # match the embed/shorts/watch url syntax
(v/)?
(watch\?v=)? # match the youtube page url
(ytscreeningroom\?v=)?
Expand Down
6 changes: 6 additions & 0 deletions tests/testapp/test_embedding.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ def test_youtube(self):
self.assertTrue(embed("https://www.youtube.com/watch/ZumRshfKdtM"))
self.assertTrue(embed("https://www.youtube.com/shorts/ZumRshfKdtM"))

self.assertEqual(
embed("https://www.youtube.com/live/ljSZ0xrJjCs"),
"""\
<div class="responsive-embed widescreen youtube"><iframe src="https://www.youtube.com/embed/ljSZ0xrJjCs?rel=0" frameborder="0" allow="autoplay; fullscreen" allowfullscreen=""></iframe></div>""",
)

def test_vimeo(self):
"""Vimeo video embedding works"""
self.assertEqual(
Expand Down

0 comments on commit 1fd6e8c

Please sign in to comment.