Please remember that WiKirby contains spoilers, which you read at your own risk! See our general disclaimer for details.

Module:MPvid

From WiKirby, your independent source of Kirby knowledge.
Jump to navigationJump to search

A version of MPvid that doesn't use #var. Pulls the videos from Module:MPvid/videos.

{{subst:#invoke:MPvid|random}}

--[[
	This module throws a random video from Module:MPvid/videos on every page refresh.
	If you can somehow spot server-side performance issues because of this
	module, please contact tech support.
]]--
local d = {}
local result = {}
local lang = mw.language.getContentLanguage()

function d.random (frame)
	-- The list of facts
	local z = require('Module:MPvid/videos')
	
	-- Generates a seed with the current server time.
	math.randomseed(os.time())

	-- The random selected video
	local choice = z[math.random(1,#z)]
	
	table.insert(result, '<div style="display: flex; align-items: center; flex-direction: column">'..frame:preprocess('{{Youtube|'.. choice.url ..'|350}}')..'<div>Today\'s video '.. choice.caption ..'</div></div>')
	return table.concat(result, '')
end

return d