19 lines
572 B
Python
19 lines
572 B
Python
from .base import EmbedProvider
|
|
|
|
class YouTubeProvider(EmbedProvider):
|
|
name = "youtube"
|
|
pattern = r"\{\{YOUTUBE:([A-Za-z0-9_-]+)\}\}"
|
|
|
|
def replace(self, match):
|
|
video_id = match.group(1)
|
|
nocookie = self.config.get("nocookie", True)
|
|
domain = "www.youtube-nocookie.com" if nocookie else "www.youtube.com"
|
|
|
|
embed_html = f'''
|
|
<iframe width="560" height="315"
|
|
src="https://{domain}/embed/{video_id}"
|
|
frameborder="0"
|
|
allowfullscreen>
|
|
</iframe>
|
|
'''
|
|
return self.wrap_template("youtube", embed_html) |