Module:Video: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 4: | Line 4: | ||
fileexists = frame:expandTemplate{title = 'exist', args = {'file:'..frame.args[1]..'.webm', 'yes'}} | fileexists = frame:expandTemplate{title = 'exist', args = {'file:'..frame.args[1]..'.webm', 'yes'}} | ||
if fileexists == 'yes' then | if fileexists == 'yes' then | ||
return | return frame.args[1]..'.webm' | ||
end | end | ||
fileexists = frame:expandTemplate{title = 'exist', args = {'file:'..frame.args[1]..'.ogg', 'yes'}} | fileexists = frame:expandTemplate{title = 'exist', args = {'file:'..frame.args[1]..'.ogg', 'yes'}} | ||
if fileexists == 'yes' then | if fileexists == 'yes' then | ||
return | return frame.args[1]..'.ogg' | ||
end | end | ||
Line 22: | Line 22: | ||
end | end | ||
-- fileexists = frame:expandTemplate{title = 'exist', args = {'file:'..parent2..'.png', 'yes'}} | -- fileexists = frame:expandTemplate{title = 'exist', args = {'file:'..parent2..'.png', 'yes'}} | ||
return | return parent2..'.png' | ||
end | end | ||
Revision as of 00:42, 13 February 2024
usage
{{#invoke:video|file|unknown file}} unknown file.png{{#invoke:video|file|RoE 1.0 CD-Heroes3-DATA-HEROES3 VID-EVIL1A-smk-EVIL1A}}
RoE 1.0 CD-Heroes3-DATA-HEROES3 VID-EVIL1A-smk-EVIL1A.webm
local p = {}
function p.file( frame )
fileexists = frame:expandTemplate{title = 'exist', args = {'file:'..frame.args[1]..'.webm', 'yes'}}
if fileexists == 'yes' then
return frame.args[1]..'.webm'
end
fileexists = frame:expandTemplate{title = 'exist', args = {'file:'..frame.args[1]..'.ogg', 'yes'}}
if fileexists == 'yes' then
return frame.args[1]..'.ogg'
end
local lines = p.split(frame.args[1], '-')
local parent2 = ''
for i, line in ipairs(lines) do
parent2 = parent2 .. line
if i + 2 >= #lines then
break
else
parent2 = parent2 .. '-'
end
end
-- fileexists = frame:expandTemplate{title = 'exist', args = {'file:'..parent2..'.png', 'yes'}}
return parent2..'.png'
end
function p.split(str, sep)
local result = {}
local regex = ("([^%s]+)"):format(sep)
for each in str:gmatch(regex) do
table.insert(result, each)
end
return result
end
return p