Jump to content

Module:Infobox television disambiguation check

Permanently protected module
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by MusikBot II (talk | contribs) at 18:01, 4 May 2019 (Protected "Module:Infobox television disambiguation check": High-risk template or module (more info) ([Edit=Require template editor access] (indefinite) [Move=Require template editor access] (indefinite))). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

-- This module requires the use of Module:Arguments.
local getArgs = require('Module:Arguments').getArgs

local p = {}

local validNameList = {
	"TV series",
	"TV program",
	"TV programme",
	"TV film",
	"film",
	"miniseries",
	"serial",
	"game show",
	"talk show",
	"web series"
}

local franchise = "franchise"

local categoryList = {
	["incorrect"] = "[[Category:Television articles with incorrect naming style]]",
	["franchise"] = "[[Category:Television articles using incorrect infobox|F]]"
}

local isValid = false
local category = ""

local function _main(args)
	if (args[1] == nil or args[1] == "") then
		return ""
	end
	
	local disambiguation = string.match(args[1], "%s%((.-)%)")
	
	if (not disambiguation) then
		-- Nothing to check.
		return ""
	end

	for _, v in ipairs(validNameList) do
		if (not string.match(disambiguation, v)) then
			-- Name not valid, do nothing.
		else
			-- Name valid, set isValid to true.
			isValid = true
			break
		end
	end
	
	if (string.match(disambiguation, franchise)) then
		isValid = true
		category = categoryList["franchise"]
	end
	
	if (not isValid) then
		category = categoryList["incorrect"]
	end
	
	return category
end

function p.main(frame)
	local args = getArgs(frame)
	return _main(args)
end

return p