Jump to content

Module:Infobox television season disambiguation check

From WikipediNyah
Revision as of 02:38, 2 July 2026 by NeonWabbit (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

For actual documentation, view the corresponding Wikipedia pages.


require("strict")

local getArgs = require("Module:Arguments").getArgs
local validateDisambiguation = require("Module:Television infoboxes disambiguation check")

local p = {}

-----------------------------------------------------------------------
-- Valid disambiguation types for SEASON pages
-- Only "TV series" is allowed as the base type.
-----------------------------------------------------------------------
local validDisambiguationTypeList = {
	"TV series",
	"season",
	"series"
}

-----------------------------------------------------------------------
-- Valid disambiguation patterns for SEASON pages
-- These patterns match the NEW naming conventions:
--
--  "Lost season 1"
--  "Big Brother (American TV series) season 5"
--  "Gladiators (2008 British TV series) series 2"
--
-- After getDisambiguation(), the disambiguation string becomes:
--
--  "season 1"
--  "American TV series season 5"
--  "2008 British TV series series 2"
--
-----------------------------------------------------------------------
local validDisambiguationPatternList = {

	-- SEASON
	-- "TV series season 2"
	validateDisambiguation.DisambiguationPattern{
		pattern = "^TV series%s+season%s+(%d+)$",
		type = validateDisambiguation.VALIDATION_TYPE_SEASON_NUMBER
	},

	-- YEAR + COUNTRY + SEASON
	-- "2008 British TV series season 2"
	validateDisambiguation.DisambiguationPattern{
		pattern = "^(%d+)%s+([%D]+)%s+TV series%s+%a+%s+(%d+)$",
		type = validateDisambiguation.VALIDATION_TYPE_YEAR_COUNTRY_SEASON_NUMBER
	},

	-- YEAR + SEASON
	-- "2008 TV series season 2"
	validateDisambiguation.DisambiguationPattern{
		pattern = "^(%d+)%s+TV series%s+%a+%s+(%d+)$",
		type = validateDisambiguation.VALIDATION_TYPE_YEAR_SEASON_NUMBER
	},

	-- COUNTRY + SEASON
	-- "British TV series season 2"
	validateDisambiguation.DisambiguationPattern{
		pattern = "^([%D]+)%s+TV series%s+%a+%s+(%d+)$",
		type = validateDisambiguation.VALIDATION_TYPE_COUNTRY_SEASON_NUMBER
	},

	-- SEASON ONLY
	-- "season 2"
	validateDisambiguation.DisambiguationPattern{
		pattern = "^season%s+(%d+)$",
		type = validateDisambiguation.VALIDATION_TYPE_SEASON_NUMBER
	},

	-- SERIES ONLY (UK usage)
	-- "series 2"
	validateDisambiguation.DisambiguationPattern{
		pattern = "^series%s+(%d+)$",
		type = validateDisambiguation.VALIDATION_TYPE_SEASON_NUMBER
	}
}

-----------------------------------------------------------------------
-- Titles where parentheses are NOT disambiguation
-----------------------------------------------------------------------
local exceptionList = {
	"^Bigg Boss %(Bangla season %d+%)$",
	"^Bigg Boss %(Hindi season %d+%)$",
	"^Bigg Boss %(Malayalam season %d+%)$",
	"^Bigg Boss %(Tamil season %d+%)$",
	"^Bigg Boss %(Telugu season %d+%)$"
}

-----------------------------------------------------------------------
-- Infoboxes that should NOT use this module
-----------------------------------------------------------------------
local otherInfoboxList = {
	["^[^,]*TV series$"] = "[[Category:Television articles using incorrect infobox|T]]"
}

-----------------------------------------------------------------------
-- Invalid title styles for season pages
-----------------------------------------------------------------------
local invalidTitleStyleList = {
	"List of",
	"%(.-season%s+%d+%)",
	"%(.-series%s+%d+%)"
}

-----------------------------------------------------------------------
-- Merge infobox television disambiguation types
-- This ensures season pages don't use the wrong infobox.
-----------------------------------------------------------------------
local function getOtherInfoboxListMerged()
	local infoboxTelevisionDisambiguation = require("Module:Infobox television disambiguation check")
	local list = infoboxTelevisionDisambiguation.getDisambiguationTypeList()

	for i = 1, #list do
		otherInfoboxList[list[i]] = "[[Category:Television articles using incorrect infobox|T]]"
	end

	return otherInfoboxList
end

-----------------------------------------------------------------------
-- Internal main
-----------------------------------------------------------------------
local function _main(args)
	local title = args[1]

	local merged = getOtherInfoboxListMerged()

	return validateDisambiguation.main(
		title,
		"infobox television season",
		validDisambiguationTypeList,
		validDisambiguationPatternList,
		exceptionList,
		merged,
		invalidTitleStyleList
	)
end

-----------------------------------------------------------------------
-- Public entry point
-----------------------------------------------------------------------
function p.main(frame)
	local args = getArgs(frame)
	local category = _main(args)
	return category
end

-----------------------------------------------------------------------
-- Test entry point (returns debug string)
-----------------------------------------------------------------------
function p.test(frame)
	local args = getArgs(frame)
	local _, debugString = _main(args)
	return debugString
end

return p