Mô đun:Aired episodes

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 = 'Bản mẫu: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)
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'} .. ' tập phim' .. oneEpisode(numberEpisodes, , ) .. " của " .. showName .. ""

if not isAllFinished then
airedEpisodes = airedEpisodes .. ' ' .. oneEpisode(numberEpisodes, 'được', 'được')
end

airedEpisodes = airedEpisodes .. ' ' .. (args.released and ((isAllFinished and 'đã được' or 'đã được') .. ' phát hành') or 'phát sóng')

if args.specials then
airedEpisodes = airedEpisodes .. ', bao gồm ' .. spellnum{args.specials} .. ' tập đặc biệt' .. oneEpisode(args.specials, , )
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 .. ', từ ' .. 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 ',') .. ' đến ' .. 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 'nửa đầu của ') .. 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 .. ', hiện tại đang trong ' .. (args.part and 'part' or args.uk and 'mùa phim ' or 'mùa phim ') .. frame:expandTemplate{title='Ordinal to word',args={math.floor(tonumber(args.airing))}}
end

airedEpisodes = airedEpisodes .. '.'

local title = mw.title.getCurrentTitle()
if title.namespace 0 then
if args.showpage args.title then
airedEpisodes = airedEpisodes ..
end

if args.showpage and args.title then
airedEpisodes = airedEpisodes ..
end
end

return airedEpisodes
end

return p