From 07316b78b490c170e4dfb5a1ada8ae6336b6f962 Mon Sep 17 00:00:00 2001 From: bhemmer <22427415+bhemmer@users.noreply.github.com> Date: Thu, 16 Jul 2020 15:38:27 +0200 Subject: [PATCH] add config to mdx_video extension to use youtube-nocookie.com for iframe --- martor/extensions/mdx_video.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/martor/extensions/mdx_video.py b/martor/extensions/mdx_video.py index 52518df74..2af812c26 100644 --- a/martor/extensions/mdx_video.py +++ b/martor/extensions/mdx_video.py @@ -20,6 +20,7 @@ def __init__(self, **kwargs): 'yahoo_height': ['351', 'Height for Yahoo! videos'], 'youtube_width': ['560', 'Width for Youtube videos'], 'youtube_height': ['315', 'Height for Youtube videos'], + 'youtube_nocookie': [False, 'Use youtube-nocookie.com instead of youtube.com'] } # Override defaults with user settings @@ -97,7 +98,10 @@ def handleMatch(self, m): class Youtube(markdown.inlinepatterns.Pattern): def handleMatch(self, m): - url = '//www.youtube.com/embed/%s' % m.group('youtubeid') + if self.ext.config['youtube_nocookie'][0]: + url = '//www.youtube-nocookie.com/embed/%s' % m.group('youtubeid') + else: + url = '//www.youtube.com/embed/%s' % m.group('youtubeid') width = self.ext.config['youtube_width'][0] height = self.ext.config['youtube_height'][0] return render_iframe(url, width, height)