Jump to content
 







Main menu
   


Navigation  



Main page
Contents
Current events
Random article
About Wikipedia
Contact us
Donate
 




Contribute  



Help
Learn to edit
Community portal
Recent changes
Upload file
 








Search  

































Create account

Log in
 









Create account
 Log in
 




Pages for logged out editors learn more  



Contributions
Talk
 



















Contents

   



(Top)
 


1 Usage  





2 Tracking categories  














Module:Aired episodes






فارسی
Tiếng Vit
 

Edit links
 









Module
Talk
 

















Read
View source
View history
 








Tools
   


Actions  



Read
View source
View history
 




General  



What links here
Related changes
Upload file
Special pages
Permanent link
Page information
Get shortened URL
Download QR code
Wikidata item
 




Print/export  



Download as PDF
Printable version
 
















Appearance
   

 





Permanently protected module

From Wikipedia, the free encyclopedia
 


Usage

Creates a standard aired episodes statement with

{{#invoke:Aired episodes|main}}

With the parameters defined in the documentation of the template.

Tracking categories

local spellnum = require('Module:Spellnum per MOS').spellnum

function oneEpisode(value, one_return, more_return)
 return (tonumber(value) == 1 and one_return or more_return)
end

function parseNumber(value)
 return tonumber(string.gsub(value, '^([%d]*).*', '%1'), 10)
end

local p = {}

function p.main(frame)
 local args = require('Module:Arguments').getArgs(frame, {
  wrappers = 'Template:Aired episodes'
 })
 args = args or {}
 
 local airedEpisodes = ''
 local numberEpisodes = args.num or frame:expandTemplate{title='Template parameter value',args={args.showpage or args.title, 'Infobox television', 1, 'num_episodes', 1}}
 numberEpisodes = parseNumber(numberEpisodes:gsub(",", ''))
 local showName = (args.showpage and frame:expandTemplate{title='PAGENAMEBASE',args={args.showpage}} or args.title):gsub("''", '')
 local isAllFinished = (args.finished == 'all')
 
 if isAllFinished then
  airedEpisodes = airedEpisodes .. 'During the course of the ' .. (args.uk and 'programme' or 'series') .. ','
 else
  if args.date then
   airedEpisodes = airedEpisodes .. 'As of' .. args.date .. ','
  else
   airedEpisodes = airedEpisodes .. frame:expandTemplate{title='As of',args={args[1], args[2], args[3], post=',', df=((args.uk or args.df) and '' or 'US')}}
  end
 end
  
 airedEpisodes = airedEpisodes .. ' ' .. spellnum{numberEpisodes, zero = 'no', forcenum = 'yes'} .. ' episode' .. oneEpisode(numberEpisodes, '', 's') .. " of ''" .. showName .. "''"
 
 if not isAllFinished then
  airedEpisodes = airedEpisodes .. ' ' .. oneEpisode(numberEpisodes, 'has', 'have')
 end
 
 airedEpisodes = airedEpisodes .. ' ' .. (args.released and ((isAllFinished and 'were' or 'been') .. ' released') or 'aired')
 
 if args.specials then
  airedEpisodes = airedEpisodes .. ', including ' .. spellnum{args.specials} .. ' special' .. oneEpisode(args.specials, '', 's')
 end
 
 if args.finished then
  if isAllFinished then
   if args.seasons then
    airedEpisodes = airedEpisodes .. ' over ' .. spellnum{args.seasons} .. ' ' .. (args.uk and 'series' or ((args.part and 'part' or 'season') .. oneEpisode(args.seasons, '', 's')))
   end
   
   if args[1] then
    if args[4] then
     airedEpisodes = airedEpisodes .. ', between ' .. frame:expandTemplate{title='Date',args={args[1]..'-'..(args[2] or '')..'-'..(args[3] or ''), ((args.uk or args.df) and 'DMY' or 'MDY')}} .. ((args.uk or args.df) and '' or ',') .. ' and ' .. frame:expandTemplate{title='Date',args={(args[4] or '')..'-'..(args[5] or '')..'-'..(args[6] or ''), ((args.uk or args.df) and 'DMY' or 'MDY')}}
    else
     airedEpisodes = airedEpisodes .. ', concluding on ' .. frame:expandTemplate{title='Date',args={args[1]..'-'..(args[2] or '')..'-'..(args[3] or ''), ((args.uk or args.df) and 'DMY' or 'MDY')}}
    end
   end
  else
   airedEpisodes = airedEpisodes .. ', concluding the ' .. ((tonumber(args.finished) == math.floor(tonumber(args.finished))) and '' or 'first half of the ') .. frame:expandTemplate{title='Ordinal to word',args={math.floor(tonumber(args.finished))}} .. ' ' .. (args.part and 'part' or args.uk and 'series' or 'season')
  end
 elseif args.airing then
  airedEpisodes = airedEpisodes .. ', currently in its ' .. frame:expandTemplate{title='Ordinal to word',args={math.floor(tonumber(args.airing))}} .. ' ' .. (args.part and 'part' or args.uk and 'series' or 'season')
 end
 
 airedEpisodes = airedEpisodes .. '.'
 
 local title = mw.title.getCurrentTitle()
 if title.namespace == 0 then
  if args.showpage == args.title then
   airedEpisodes = airedEpisodes .. '[[Category:Template:Aired episodes using equal showpage and title parameters]]'
  end
  
  if args.showpage and args.title then
   airedEpisodes = airedEpisodes .. '[[Category:Template:Aired episodes using both showpage and title parameters]]'
  end
 end
 
 return airedEpisodes
end

return p

Retrieved from "https://en.wikipedia.org/w/index.php?title=Module:Aired_episodes&oldid=1150029330"

Category: 
Television-related modules
Hidden category: 
Wikipedia semi-protected modules
 



This page was last edited on 15 April 2023, at 23:06 (UTC).

Text is available under the Creative Commons Attribution-ShareAlike License 4.0; additional terms may apply. By using this site, you agree to the Terms of Use and Privacy Policy. Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc., a non-profit organization.



Privacy policy

About Wikipedia

Disclaimers

Contact Wikipedia

Code of Conduct

Developers

Statistics

Cookie statement

Mobile view



Wikimedia Foundation
Powered by MediaWiki