Module:Television episode short description: Difference between revisions

Created page with "--- @module local television = {} -- Unique suffix list. local uniqueSuffix = { [1] = "st", [2] = "nd", [3] = "rd", } -- Common suffix. local commonSuffix = "th" -- Test validation. local test = false local descriptions = { no_series = { type = 1, text = "Television episode", category = "%s", }, only_series_name = { type = 2, text = "Episode of %s", category = "[[Cat..."
 
No edit summary
 
Line 283: Line 283:
--- Returns true if the TV series is a limited series.
--- Returns true if the TV series is a limited series.
--- @param limitedSeries string Any value will be considered as true.
--- @param limitedSeries string Any value will be considered as true.
local function isLimitedSeries(limitedSeries)
--- @param tvSeriesNameDab string The disambiguation used in the series name article title.
local function isLimitedSeries(limitedSeries, tvSeriesNameDab)
if (limitedSeries) then
if (limitedSeries) then
return true
return true
end
end
if tvSeriesNameDab and string.find(tvSeriesNameDab, "miniseries") then
return true
end
return false
return false
end
end
Line 426: Line 432:
end
end


--- Returns the TV series title without disambiguation, or nil if no TV series name was set.
--- Returns the TV series title without disambiguation, and the disambiguation, or nil if no TV series name was set.
--- @param tvSeriesName string The TV series name.
--- @param tvSeriesName string The TV series name.
--- @param notDab string If set, the parenthesis in the title is not disambiguation.
--- @param notDab string If set, the parenthesis in the title is not disambiguation.
Line 432: Line 438:
if (tvSeriesName) then
if (tvSeriesName) then
if (not notDab) then
if (not notDab) then
return string.gsub(tvSeriesName, "%s+%b()$", "", 1, false)
local title, disambiguation = string.match(tvSeriesName, "^(.+) %((.*)%)$")
if not title then
title = tvSeriesName
end
return title, disambiguation
end
end
return tvSeriesName
return tvSeriesName, nil
end
end
return nil
return nil, nil
end
end


Line 442: Line 452:
--- @param args table The values that should be processed.
--- @param args table The values that should be processed.
local function cleanValues(args)
local function cleanValues(args)
for _, v in ipairs({"episode_num", "season_num", "season_num_uk", "series_name"}) do
for i, v in ipairs({"episode_num", "season_num", "season_num_uk", "series_name"}) do
if (args[v]) then
if (args[v]) then
args[v] = args[v]:gsub("\127[^\127]*UNIQ%-%-(%a+)%-%x+%-QINU[^\127]*\127", "") -- Remove all strip-markers.
args[v] = args[v]:gsub("\127[^\127]*UNIQ%-%-(%a+)%-%x+%-QINU[^\127]*\127", "") -- Remove all strip-markers.
Line 448: Line 458:
args[v] = args[v]:gsub("%b<>[^<]+%b<>", "") -- Remove html markup.
args[v] = args[v]:gsub("%b<>[^<]+%b<>", "") -- Remove html markup.
args[v] = args[v]:gsub("%b<>", "") -- Remove self-closed html tags.
args[v] = args[v]:gsub("%b<>", "") -- Remove self-closed html tags.
args[v] = args[v]:gsub("%[%[[^|]+|([^%]]+)%]%]", "%1") -- Remove wiki-link retain label.
if i ~= 4 then
args[v] = args[v]:gsub("%[%[[^|]+|([^%]]+)%]%]", "%1") -- Remove wiki-link retain label.
else
args[v] = args[v]:gsub("%[%[([^|]+)|.*%]%]", "%1") -- Remove wiki-link retain article.
end
args[v] = args[v]:gsub("%[%[([^%]]+)%]%]", "%1") -- Remove wiki-link retain article.
args[v] = args[v]:gsub("%[%[([^%]]+)%]%]", "%1") -- Remove wiki-link retain article.
args[v] = args[v]:gsub("%[%S+ +([^%]]-)%]", "%1") -- Remove URLs retain label.
args[v] = args[v]:gsub("%[%S+ +([^%]]-)%]", "%1") -- Remove URLs retain label.
Line 466: Line 480:
function television._getShortDescription(frame, args)
function television._getShortDescription(frame, args)
args = cleanValues(args)
args = cleanValues(args)
local tvSeriesName = getTVSeriesName(args.series_name, args.not_dab)
local tvSeriesName, tvSeriesNameDab = getTVSeriesName(args.series_name, args.not_dab)
     local seasonNumber, seasonTextStyle = getSeasonNumberAndTextStyle(args.season_num, args.season_num_uk)
     local seasonNumber, seasonTextStyle = getSeasonNumberAndTextStyle(args.season_num, args.season_num_uk)
local seasonOrdinalNumber = getSeasonOrdinalNumber(seasonNumber)
local seasonOrdinalNumber = getSeasonOrdinalNumber(seasonNumber)
local episodeOrdinalNumbers = getEpisodeOrdinalNumbers(args.episode_num)
local episodeOrdinalNumbers = getEpisodeOrdinalNumbers(args.episode_num)
local limitedSeries = isLimitedSeries(args.limited)
local limitedSeries = isLimitedSeries(args.limited, tvSeriesNameDab)
local descriptionType = getDescriptionType(
local descriptionType = getDescriptionType(
tvSeriesName,
tvSeriesName,