<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://mywikibiz.com/index.php?action=history&amp;feed=atom&amp;title=Module%3ATelevision_episode_disambiguation_description</id>
	<title>Module:Television episode disambiguation description - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://mywikibiz.com/index.php?action=history&amp;feed=atom&amp;title=Module%3ATelevision_episode_disambiguation_description"/>
	<link rel="alternate" type="text/html" href="https://mywikibiz.com/index.php?title=Module:Television_episode_disambiguation_description&amp;action=history"/>
	<updated>2026-05-13T02:45:03Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.3</generator>
	<entry>
		<id>https://mywikibiz.com/index.php?title=Module:Television_episode_disambiguation_description&amp;diff=479715&amp;oldid=prev</id>
		<title>Zoran: Pywikibot 6.4.0</title>
		<link rel="alternate" type="text/html" href="https://mywikibiz.com/index.php?title=Module:Television_episode_disambiguation_description&amp;diff=479715&amp;oldid=prev"/>
		<updated>2021-07-16T07:34:35Z</updated>

		<summary type="html">&lt;p&gt;Pywikibot 6.4.0&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;-- Do not add a style which is not supported by the [[WP:NCTV]] guidelines.&lt;br /&gt;
&lt;br /&gt;
-- This module requires the use of Module:Extract short description.&lt;br /&gt;
local extract = require('Module:Extract short description')&lt;br /&gt;
&lt;br /&gt;
-- Release version template list.&lt;br /&gt;
local releaseTemplates = {&lt;br /&gt;
	'Infobox television episode',&lt;br /&gt;
	'Infobox Television episode',&lt;br /&gt;
	'Television episode short description',&lt;br /&gt;
	'Short description',&lt;br /&gt;
	'Television episode redirect handler'&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
-- Local function used to create the stylized article disambiguation.&lt;br /&gt;
local function getStylizedDisambiguation(disambiguation)&lt;br /&gt;
	local isDisambiguationExtended = string.find(disambiguation, &amp;quot;episode&amp;quot;)				-- Search for the word &amp;quot;episode&amp;quot; in the article name disambiguation (disambiguation is extended).&lt;br /&gt;
	&lt;br /&gt;
	if (not isDisambiguationExtended) then												-- Check if the article name has extended disambiguation.&lt;br /&gt;
		return &amp;quot;(''&amp;quot; .. disambiguation .. &amp;quot;'')&amp;quot;											-- Article does not have extended disambiguation; &lt;br /&gt;
																						-- Add italics to the disambiguation which should only be the TV series name per [[MOS:ITALICTITLE]] and [[WP:NCTV]].&lt;br /&gt;
	else																				-- Articles has extended disambiguation;&lt;br /&gt;
		local tvSeries = string.gsub(disambiguation, &amp;quot;episode&amp;quot;, &amp;quot;&amp;quot;, 1, true)			-- Get the TV series name without the extended disambiguation.&lt;br /&gt;
		tvSeries = mw.text.trim(tvSeries)												-- Remove trailing whitespaces.&lt;br /&gt;
		return &amp;quot;(''&amp;quot; .. tvSeries .. &amp;quot;'' episode)&amp;quot;										-- Add italics to the disambiguation which should only be the TV series name per [[MOS:ITALICTITLE]] and [[WP:NCTV]]; &lt;br /&gt;
	end																					-- and add back the extended disambiguation.&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Local function used to create the stylized article title.&lt;br /&gt;
local function getStylizedArticleTitle(articleName)&lt;br /&gt;
	local articleTitle = string.gsub(articleName, &amp;quot;%s+%b()$&amp;quot;, &amp;quot;&amp;quot;, 1, false)				-- Get the article title without the disambiguation.&lt;br /&gt;
	return &amp;quot;\&amp;quot;&amp;quot; .. articleTitle .. &amp;quot;\&amp;quot;&amp;quot;													-- Add quotation marks to the title per [[MOS:QUOTETITLE]].&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Local function used to get the disambiguated formatted episode link.&lt;br /&gt;
local function getDisambiguatedFormattedLink(articleName)&lt;br /&gt;
	local disambiguation = string.match(articleName, &amp;quot;%s%((.-)%)&amp;quot;)						-- Get the text inside the disambiguation parentheses.&lt;br /&gt;
&lt;br /&gt;
	if (not disambiguation) then														-- Check if the article name does not have disambiguation parentheses.&lt;br /&gt;
		return &amp;quot;\&amp;quot;[[&amp;quot; .. articleName .. &amp;quot;]]\&amp;quot;&amp;quot;											-- Article does not have disambiguation parentheses; Add quotation marks to the title per [[MOS:QUOTETITLE]] and return it.&lt;br /&gt;
	else																				-- Article has disambiguation parentheses;&lt;br /&gt;
		local stylizedArticleTitle = getStylizedArticleTitle(articleName)				-- Call getStylizedArticleTitle() to get the stylized article title.&lt;br /&gt;
		local stylizedDisambiguation = getStylizedDisambiguation(disambiguation)		-- Call getStylizedDisambiguation() to get the stylized disambiguation.&lt;br /&gt;
		local stylizedName = stylizedArticleTitle .. &amp;quot; &amp;quot; .. stylizedDisambiguation		-- Recreate the article name from the title and disambiguation.&lt;br /&gt;
		return &amp;quot;[[&amp;quot; .. articleName .. &amp;quot;|&amp;quot; .. stylizedName .. &amp;quot;]]&amp;quot;						-- Create a pipped link and return it.&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return &lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Local function used to create a formatted episode link.&lt;br /&gt;
local function getFormmatedArticleLink(articleName, parenthesesPartOfTitle)&lt;br /&gt;
	local formattedLink																	-- Variable to save the formatted link.&lt;br /&gt;
&lt;br /&gt;
	if (parenthesesPartOfTitle ~= nil) then												-- Check if the parentheses is part of the episode title.&lt;br /&gt;
		formattedLink = &amp;quot;\&amp;quot;[[&amp;quot; .. articleName .. &amp;quot;]]\&amp;quot;&amp;quot;									-- Parentheses is part of the title; Add quotation marks to the title per [[MOS:QUOTETITLE]].&lt;br /&gt;
	else																				-- Parentheses is not part of the title; &lt;br /&gt;
		formattedLink = getDisambiguatedFormattedLink(articleName)						-- Call getDisambiguatedFormmatedLink() to get the disambiguated formatted episode link.&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
    return formattedLink																-- Return the formatted link.&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Local function used to retrieve the short description&lt;br /&gt;
-- from an episode article's template - either Template:Infobox television episode or Template:Short description.&lt;br /&gt;
-- See the table list for the complete template list.&lt;br /&gt;
local function getShortDescription(frame, articleName)&lt;br /&gt;
	local templatesTable = releaseTemplates												-- Get the release version template list by default.&lt;br /&gt;
&lt;br /&gt;
	local shortDescription																-- Create a variable to store the short description.&lt;br /&gt;
	local descriptionFound																-- Create a variable to store the success result.&lt;br /&gt;
	shortDescription, descriptionFound = &lt;br /&gt;
	extract.extract_from_template(frame, articleName, templatesTable)					-- Call extract_from_template() from Module:Extract short description to get the short description.&lt;br /&gt;
		&lt;br /&gt;
	-- Currently this is redundant as it always returns the same item,&lt;br /&gt;
	-- however this is in place for future possibilities.&lt;br /&gt;
	if (descriptionFound) then															-- Check if a short description was found.&lt;br /&gt;
		shortDescription = shortDescription:gsub(&amp;quot;^%a&amp;quot;, string.lower)                   -- The description should start with a lowercase letter.&lt;br /&gt;
		return shortDescription															-- A short description was found; Return it.&lt;br /&gt;
	else&lt;br /&gt;
		return shortDescription															-- A short description was not found; Return the error message.&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Local function that does the actual main process.&lt;br /&gt;
local function _main(frame, articleName, parenthesesPartOfTitle, formattedLinkOnly, shortDescriptionOnly)&lt;br /&gt;
	local formattedLink = getFormmatedArticleLink(articleName, parenthesesPartOfTitle)	-- Call getFormmatedArticleLink() and return a formatted link.&lt;br /&gt;
	if (formattedLinkOnly) then															-- Check if only a formatted link is needed.&lt;br /&gt;
		return formattedLink															-- Only a formatted link is needed; Call getFormmatedArticleLink() and return a formatted link.&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local shortDescription = getShortDescription(frame, articleName)					-- Call getShortDescription() and return the episode's short description.&lt;br /&gt;
	if shortDescriptionOnly then&lt;br /&gt;
		return shortDescription&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return	formattedLink .. &amp;quot;, &amp;quot; .. shortDescription									-- Return a complete entry.&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Local function used to create an error message.&lt;br /&gt;
local function getErrorMsg(errorMsg)&lt;br /&gt;
	return '&amp;lt;span style=&amp;quot;font-size:100%;&amp;quot; class=&amp;quot;error&amp;quot;&amp;gt;error: ' .. errorMsg .. '.&amp;lt;/span&amp;gt;'&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[[&lt;br /&gt;
Public function used to create an entry for a television episode &lt;br /&gt;
in a disambiguation page.&lt;br /&gt;
The entry is in the form of: &amp;quot;&amp;lt;article name&amp;gt;&amp;quot;, &amp;lt;short description&amp;gt;&lt;br /&gt;
If set to &amp;quot;link_only&amp;quot;, only a formatted episode link will be returned.&lt;br /&gt;
See documentation for examples.&lt;br /&gt;
&lt;br /&gt;
Parameters:&lt;br /&gt;
	--	{{{1}}} or |article=	— required; The name of the episode's article name.&lt;br /&gt;
	--	|not_disambiguated=		— optional; Set if the parentheses is part of the episode name.&lt;br /&gt;
	--	|link_only=				— optional; Set if only a formatted article link should return.&lt;br /&gt;
	--	|dab_only=				— optional; Set if only a short description should return.&lt;br /&gt;
--]]&lt;br /&gt;
function p.main(frame)&lt;br /&gt;
	local getArgs = require('Module:Arguments').getArgs									-- Use Module:Arguments to access module arguments.&lt;br /&gt;
	local args = getArgs(frame)															-- Get the arguments sent via the template.&lt;br /&gt;
&lt;br /&gt;
	local articleName = args[&amp;quot;name&amp;quot;]													-- Get the article name.&lt;br /&gt;
	&lt;br /&gt;
	if (articleName == nil) then														-- Check if the article name was entered.&lt;br /&gt;
		return getErrorMsg(&amp;quot;an article title is required&amp;quot;)								-- No article name was entered; Call getErrorMsg() to create an error message and return it.&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local parenthesesPartOfTitle = args[&amp;quot;not_disambiguated&amp;quot;]&lt;br /&gt;
	local formattedLinkOnly = args[&amp;quot;link_only&amp;quot;]&lt;br /&gt;
	local shortDescriptionOnly = args[&amp;quot;dab_only&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
	return _main(frame, articleName, parenthesesPartOfTitle, formattedLinkOnly, shortDescriptionOnly)	-- Call _main() to perform the actual process.&lt;br /&gt;
&lt;br /&gt;
end	&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Zoran</name></author>
	</entry>
</feed>