blob: de5b8a85190fefdbc817dc4b657e856457b4e342 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
local iframe
iframe = require('mmm.dom').iframe
return {
{
inp = 'URL -> youtube/video',
out = 'mmm/dom',
cost = -4,
transform = function(self, link)
local id = link:match('youtu%.be/([^/]+)')
id = id or link:match('youtube.com/watch.*[?&]v=([^&]+)')
id = id or link:match('youtube.com/[ev]/([^/]+)')
id = id or link:match('youtube.com/embed/([^/]+)')
assert(id, "couldn't parse youtube URL: '" .. tostring(link) .. "'")
return iframe({
width = 560,
height = 315,
border = 0,
frameborder = 0,
allowfullscreen = true,
src = "//www.youtube.com/embed/" .. tostring(id)
})
end
}
}
|