Skip to content

Commit 07316b7

Browse files
committed
add config to mdx_video extension to use youtube-nocookie.com for iframe
1 parent 8cdc30c commit 07316b7

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

martor/extensions/mdx_video.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ def __init__(self, **kwargs):
2020
'yahoo_height': ['351', 'Height for Yahoo! videos'],
2121
'youtube_width': ['560', 'Width for Youtube videos'],
2222
'youtube_height': ['315', 'Height for Youtube videos'],
23+
'youtube_nocookie': [False, 'Use youtube-nocookie.com instead of youtube.com']
2324
}
2425

2526
# Override defaults with user settings
@@ -97,7 +98,10 @@ def handleMatch(self, m):
9798
class Youtube(markdown.inlinepatterns.Pattern):
9899

99100
def handleMatch(self, m):
100-
url = '//www.youtube.com/embed/%s' % m.group('youtubeid')
101+
if self.ext.config['youtube_nocookie'][0]:
102+
url = '//www.youtube-nocookie.com/embed/%s' % m.group('youtubeid')
103+
else:
104+
url = '//www.youtube.com/embed/%s' % m.group('youtubeid')
101105
width = self.ext.config['youtube_width'][0]
102106
height = self.ext.config['youtube_height'][0]
103107
return render_iframe(url, width, height)

0 commit comments

Comments
 (0)