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.
Revision as of 15:48, 6 March 2023 by Lakelimbo (talk | contribs) (let's see with mw.html.create instead of literal table concats)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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 lang = mw.language.getContentLanguage()

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

	-- The random selected video
	local choice = z[math.random(1,#z)]
	
	local root = mw.html.create('div')
	root:wikitext('{{Youtube|'.. choice.url ..'|350}}')
		:tag('div', choice.caption)
	
	return tostring(root)
end

return d