-- This module requires the use of Module:Arguments.localgetArgs=require('Module:Arguments').getArgslocalpipedLink=""localp={}-- Local function which is used to create an pipped article link.localfunctioncreateArticleTitleWithPipedLink(article)if(pipedLink==nilorpipedLink=="")thenreturn""elsereturn"[["..article.."|"..pipedLink.."]]"endend--[[Local function which is used to check if the given article exists.The function returns "true" in the following cases: -- A season article exists. -- A redirect exists to a season section.The function returns nil in the following cases: -- A season article or redirect do not exist. -- A redirect exists, but it is a general redirect and not for any specific season section.]]--localfunctioncheckArticle(articleName)localarticle=mw.title.new(articleName)if(article~=nilandarticle.exists)thenlocalredirectTarget=article.redirectTargetif(redirectTarget)thenlocalfullLink=redirectTarget.fullTextlocalisSection=fullLink:find("#")if(isSection)thenreturn"true"-- Article is a section redirect; Valid link.elsereturnnil-- Article is a general redirect; Not a valid link.endelsereturn"true"-- Article exists and is not a redirect; Valid link.endelsereturnnil-- Article or redirect do not exist; Not a valid link.endend--[[Local function which is used to create a TV season link.The following are the supported season naming styles: -- <showName> (<seasonQualifier> <seasonType>) Example: Big Brother 1 (U.S. season). -- <showName> (<seasonType> <seasonNumber>) Example: Lost (season 3). -- <showName> (<seasonQualifier> <seasonType> <seasonNumber>) Example: The Flash (2014 season 3). -- <showName> <preSeasonQualifier> (<seasonType> <seasonNumber>) Example: Dallas (1978 TV series) (season 3). -- <showName> <preSeasonQualifier> (<seasonQualifier> <seasonType> <seasonNumber>) Example: No current example. -- <showName> (<preSeasonQualifier>, <seasonType> <seasonNumber>) - TODO Example: Teenage Mutant Ninja Turtles (1987 TV series, season 1)--]]localfunctioncreateLink(args,prevOrNextSeasonNumber)localshowName=args[1]orargs['show_name']if(showName==nil)thenreturn""endshowName=showName.." "localpreSeasonQualifier=args[2]orargs['pre_season_qualifier']if(preSeasonQualifier==nil)thenpreSeasonQualifier=""elsepreSeasonQualifier=preSeasonQualifier.." "endlocalseasonQualifier=args[3]orargs['season_qualifier']if(seasonQualifier==nil)thenseasonQualifier=""elseseasonQualifier=seasonQualifier.." "endlocalseasonType=args[4]orargs['season_type']if(seasonType==nil)thenseasonType="season"endlocalrealitySeriesStyle=falselocalshowNameModifiedlocalseasonNumber=args[5]orargs['season_number']if(seasonNumber==nil)thenif(string.match(showName,"%s+(%d+)"))then_,_,showNameModified,seasonNumber=string.find(showName,"(.*)%s+(%d+)")realitySeriesStyle=trueelsereturn""-- Not a valid next/prev season linkendendif(tonumber(seasonNumber)==nil)thenreturn""elseseasonNumber=seasonNumber+prevOrNextSeasonNumberpipedLink=seasonType:gsub("^%l",string.upper).." "..seasonNumberif(realitySeriesStyle)thenreturnshowNameModified.." "..seasonNumber.." ("..seasonQualifier..seasonType..")"elsereturnshowName..preSeasonQualifier.."("..seasonQualifier..seasonType.." "..seasonNumber..")"endendend-- Local function which is called to create a TV season link for the next season.-- Passes the value "1" to increment the current season number.localfunctioncreateNextSeasonArticle(args)returncreateLink(args,1)end-- Local function which is called to create a TV season link for the previous season.-- Passes the value "-1" to decrement the current season number.localfunctioncreatePreviousSeasonArticle(args)returncreateLink(args,-1)end--[[Wrapper function which handles the processing of the arguments from multiple public invoked functions.Parameters: -- |show_name= — required; The title of TV program. -- |pre_season_qualifier= — optional; For cases where disambiguation before the season is required (e.g. the pre-season qualifier for Dallas (1978 TV series) (season 7) is (1978 TV series)). -- |season_qualifier= — optional; For cases where disambiguation (typically of the show's origin country) before the season type is required (e.g. the season qualifier for The Apprentice (U.S. season 2) is U.S.). -- |season_type= — optional; To determine the usage of the word "season" for American-based shows, or "series" for shows using British-English. -- |season_number= — optional; Season number. The N season of this particular show. --]]localfunctionmakeInvokeFunc(funcName)returnfunction(frame)localargs=getArgs(frame)returnp[funcName](args)endendp.checkNextSeason=makeInvokeFunc('_checkNextSeason')--[[Public function which is used to check if the next season hasa created article or redirect.Parameters: See makeInvokeFunc() for documentation.--]]functionp._checkNextSeason(args)localarticleName=createNextSeasonArticle(args)returncheckArticle(articleName)endp.checkPrevSeason=makeInvokeFunc('_checkPrevSeason')--[[Public function which is used to check if the previous season hasa created article or redirect.Parameters: See makeInvokeFunc() for documentation.--]]functionp._checkPrevSeason(args)localarticleName=createPreviousSeasonArticle(args)returncheckArticle(articleName)endp.checkAll=makeInvokeFunc('_checkAll')--[[Public function which is used to check if the next or previous season havea created article or redirect.Parameters: See makeInvokeFunc() for documentation.--]]functionp._checkAll(args)if(p._checkPrevSeason(args)=="true")thenreturn"true"elsereturnp._checkNextSeason(args)endendp.getNextSeasonArticle=makeInvokeFunc('_getNextSeasonArticle')--[[Public function which is used to get the next season article title.Parameters: See makeInvokeFunc() for documentation.--]]functionp._getNextSeasonArticle(args)localarticleTitle=createNextSeasonArticle(args)returncreateArticleTitleWithPipedLink(articleTitle)endp.getPrevSeasonArticle=makeInvokeFunc('_getPrevSeasonArticle')--[[Public function which is used to get the previous season article title.Parameters: See makeInvokeFunc() for documentation.--]]functionp._getPrevSeasonArticle(args)localarticleTitle=createPreviousSeasonArticle(args)returncreateArticleTitleWithPipedLink(articleTitle)endreturnp