Content deleted Content added
No edit summary |
|||
Line 1:
require('strict')
local match = require("Module:String")._match
Line 52 ⟶ 53:
return "season"
end
--- Returns the season number from the title.
Line 64 ⟶ 59:
local function getSeasonNumberNew(title)
return match(title , "%d+", 1, -1, false, "")
end▼
--- Returns the disambiguation from the title.
--- @param title string The article's title.
--- @return string | nil
local function getDisambiguation(title)▼
if disambiguation and disambiguation == "" then
return nil
end▼
return disambiguation
end
Line 70 ⟶ 76:
--- @return string | nil
local function getTitleWithoutDisambiguation(title)
local disambiguation =
if disambiguation
return string.gsub(title, "%(" .. disambiguation .. "%)", "")
end
return title
▲end
▲local function getDisambiguation(title)
▲ return match(title, "%s%((.-)%)", 1, -1, false, "")
end
Line 128 ⟶ 129:
--- @return string
local function getShowName(title)
local name, _ = mw.ustring.gsub(title, "season %
name, _ = mw.ustring.gsub(name, "series %d*$", "")
name, _ = mw.ustring.gsub(name, "specials", "")
name = string.match(name, "^%s*(.-)%s*$") -- Trim spaces.
return name
end
Line 184 ⟶ 188:
--- -- Style: <showName> (<year> TV series) <seasonType> <seasonNumber>
--- Example: Love Island (2015 TV series) series 2
--- -- Style: <showName> (<country> <seasonType>)
--- Example: Big Brother 2 (American season).
Line 198 ⟶ 202:
seasonNumber = seasonNumber + seasonNumberDiff
local modifiedTitle = string.gsub(title, "%d+$", seasonNumber)
local pipedLink = seasonType:gsub("^%l", string.upper) .. " " .. seasonNumber
local disambiguation = getDisambiguation(title)
-- Titles such as "Big Brother 2 (American season) and Teenage Mutant Ninja Turtles (1987 TV series) season 2".
if disambiguation
local titleWithoutDisambiguation = string.gsub(title, disambiguation, "_DAB_")
modifiedTitle = string.gsub(titleWithoutDisambiguation, "%d+", seasonNumber)
Line 213 ⟶ 217:
-- Invalid usages of TV series articles with the television season infobox.
elseif disambiguation and string.find(disambiguation, "TV series") and not (string.find(disambiguation, ", season") or string.find(disambiguation, ", series")) then
return "", nil
Line 301 ⟶ 305:
title = getTitleWithoutDisambiguation(title)
local seasonType = getSeasonType(title)
▲ end
return seasonType
end
Line 330:
if not seasonNumber then
local title = getTitle(frame)
seasonNumber = getSeasonNumberNew(
seasonType = getSeasonType(
-- For pages like "Doctor Who specials (2008–2010)".
if seasonType == "specials" then
return getDisambiguation(title) or "" .. " " .. seasonType
end
seasonType = seasonType:sub(1, 1):upper() .. seasonType:sub(2)
Line 371:
local title = getTitle(frame)
local showName = getShowName(getTitleWithoutDisambiguation(title))
mw.log(title)
mw.log(showName)
if showName then
local disambiguation = getDisambiguation(title)
if disambiguation then
mw.log(showName)
local listOfEpisodesArticle = string.format("List of %s%s episodes", showName, TVProgramDisambiguation)▼
disambiguation = " (" .. disambiguation .. ")"
end
▲ local listOfEpisodesArticle = string.format("List of %s%s episodes", showName,
return getListOfEpisodesLink(listOfEpisodesArticle)
end
|