0.0.1
This commit is contained in:
19
providers/youtube.py
Normal file
19
providers/youtube.py
Normal file
@@ -0,0 +1,19 @@
|
||||
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)
|
||||
Reference in New Issue
Block a user