Module:Source medium

From Tardis Wiki, the free Doctor Who reference
Revision as of 15:42, 16 July 2023 by Bongolium500 (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Documentation for this module may be created at Module:Source medium/doc

local textUtil = require('Module:TextUtil')
local p = {}

function p.getMedium(frame)
	local pageName = frame.args[1]
	local dab = textUtil.split(textUtil.split(string.gsub(pageName, "%)", ""), "(", true)[2], " ", true)
	if dab[#dab] == "story" then
		if dab[#dab-1] == "short" then
			return "short story"
		else
			return dab[#dab-1]:lower()
		end
	elseif dab[#dab] == "webcast" or dab[#dab] == "feature" or dab[#dab] == "script" or dab[#dab] == "illustration" or dab[#dab] == "poem" then
		return dab[#dab]
	elseif dab[#dab] == "novel" or dab[#dab] == "novelisation" then
		return "novel"
	elseif dab[#dab] == "video" then
		return "home video"
	elseif dab[#dab] == "game" then
		if dab[#dab-1] == "video" then
			return "video game"
		elseif dab[#dab-1] == "escape" then
			return "escape game"
		else
			return "game"
		end
	elseif dab[#dab] == "play" then
		return "stage play"
	elseif dab[#dab] == "film" then
		return "theatrical film"
	else
		return textUtil.split(string.gsub(pageName, "%)", ""), "(", true)[2]
	end
end

return p