Difference between revisions of "Module:Franchise total episodes"
Jump to navigation
Jump to search
blackwiki>TheTVExpert m (TheTVExpert moved page Module:Franchise Total Episodes to Module:Franchise total episodes without leaving a redirect) |
blackwiki>TheTVExpert (Sync with Sandbox) |
||
| Line 32: | Line 32: | ||
return I1 | return I1 | ||
end | end | ||
| + | |||
| + | local expand = function(frame,page,template,one,two,three) | ||
| + | local result = (frame:expandTemplate{title='Template parameter value',args={page,template,one,two,three}}) | ||
| + | return result | ||
| + | end | ||
| + | |||
| + | local getDateDFull = function(frame,value,i) | ||
| + | |||
| + | if(value ~= 'none none none none') then | ||
| + | local number = (expand(frame,value,"Infobox television",1,"num_episodes",1)+i) | ||
| + | value = expand(frame,value,"Episode list",number,"OriginalAirDate",1) | ||
| + | end | ||
| + | |||
| + | value = string.gsub(value, ",", "") | ||
| + | |||
| + | local t = {} | ||
| + | |||
| + | for substring in value:gmatch("%w+") do | ||
| + | table.insert(t,substring) | ||
| + | end | ||
| + | |||
| + | return t | ||
| + | end | ||
| + | |||
| + | local getDateDPart = function(num,t) | ||
| + | local value | ||
| + | if(num==1) then | ||
| + | value = tonumber(monthNum(t[5])) | ||
| + | if(value == nil) then value = 0 end | ||
| + | end | ||
| + | if(num==2) then | ||
| + | value = tonumber(monthNum(t[1])) | ||
| + | if(value == nil) then value = 0 end | ||
| + | end | ||
| + | if(num==3) then | ||
| + | value = tonumber(monthNum(t[3])) | ||
| + | if(value == nil) then value = 0 end | ||
| + | end | ||
| + | return value | ||
| + | end | ||
| + | |||
| + | local getDateL = function(frame,num,L,T) | ||
| + | local value | ||
| + | if(num==1) then | ||
| + | value = tonumber(expand(frame,L,T,1,1,1)) | ||
| + | if(value == nil) then value = 0 end | ||
| + | end | ||
| + | if(num==2) then | ||
| + | value = tonumber(expand(frame,L,T,1,2,1)) | ||
| + | if(value == nil) then value = 0 end | ||
| + | end | ||
| + | if(num==3) then | ||
| + | value = tonumber(expand(frame,L,T,1,3,1)) | ||
| + | if(value == nil) then value = 0 end | ||
| + | end | ||
| + | return value | ||
| + | end | ||
| + | |||
| + | local getS = function(frame,S,T1,T2) | ||
| + | local value = tonumber(expand(frame,S,T1,1,T2,1)) | ||
| + | if(value == nil) then value = 0 end | ||
| + | return value | ||
| + | end | ||
p.main = function( frame ) | p.main = function( frame ) | ||
| Line 56: | Line 119: | ||
local D4I = mw.getCurrentFrame():getParent().args.D4I or frame.args.D4I or 0 | local D4I = mw.getCurrentFrame():getParent().args.D4I or frame.args.D4I or 0 | ||
local D5I = mw.getCurrentFrame():getParent().args.D5I or frame.args.D5I or 0 | local D5I = mw.getCurrentFrame():getParent().args.D5I or frame.args.D5I or 0 | ||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
local L1 = mw.getCurrentFrame():getParent().args.L1 or frame.args.L1 | local L1 = mw.getCurrentFrame():getParent().args.L1 or frame.args.L1 | ||
| Line 115: | Line 125: | ||
local L4 = mw.getCurrentFrame():getParent().args.L4 or frame.args.L4 | local L4 = mw.getCurrentFrame():getParent().args.L4 or frame.args.L4 | ||
local L5 = mw.getCurrentFrame():getParent().args.L5 or frame.args.L5 | local L5 = mw.getCurrentFrame():getParent().args.L5 or frame.args.L5 | ||
| − | local T1 = | + | local T1 = 'Aired episodes' |
local T2 = 'Infobox television' | local T2 = 'Infobox television' | ||
local T3 = 'num_episodes' | local T3 = 'num_episodes' | ||
| Line 133: | Line 143: | ||
local Date = mw.getCurrentFrame():getParent().args.Date or frame.args.Date | local Date = mw.getCurrentFrame():getParent().args.Date or frame.args.Date | ||
local sum = mw.getCurrentFrame():getParent().args.sum or frame.args.sum | local sum = mw.getCurrentFrame():getParent().args.sum or frame.args.sum | ||
| + | |||
| + | local D1t = getDateDFull(frame,D1,D1I) | ||
| + | local D2t = getDateDFull(frame,D2,D2I) | ||
| + | local D3t = getDateDFull(frame,D3,D3I) | ||
| + | local D4t = getDateDFull(frame,D4,D4I) | ||
| + | local D5t = getDateDFull(frame,D5,D5I) | ||
| − | local L1_1 = | + | local L1_1 = getDateL(frame,1,L1,T1) |
| − | + | local L1_2 = getDateL(frame,2,L1,T1) | |
| − | local L1_2 = | + | local L1_3 = getDateL(frame,3,L1,T1) |
| − | |||
| − | local L1_3 = | ||
| − | |||
| − | local L2_1 = | + | local L2_1 = getDateL(frame,1,L2,T1) |
| − | + | local L2_2 = getDateL(frame,2,L2,T1) | |
| − | local L2_2 = | + | local L2_3 = getDateL(frame,3,L2,T1) |
| − | |||
| − | local L2_3 = | ||
| − | |||
| − | local L3_1 = | + | local L3_1 = getDateL(frame,1,L3,T1) |
| − | + | local L3_2 = getDateL(frame,2,L3,T1) | |
| − | local L3_2 = | + | local L3_3 = getDateL(frame,3,L3,T1) |
| − | |||
| − | local L3_3 = | ||
| − | |||
| − | local L4_1 = | + | local L4_1 = getDateL(frame,1,L4,T1) |
| − | + | local L4_2 = getDateL(frame,2,L4,T1) | |
| − | local L4_2 = | + | local L4_3 = getDateL(frame,3,L4,T1) |
| − | |||
| − | local L4_3 = | ||
| − | |||
| − | local L5_1 = | + | local L5_1 = getDateL(frame,1,L5,T1) |
| − | + | local L5_2 = getDateL(frame,2,L5,T1) | |
| − | local L5_2 = | + | local L5_3 = getDateL(frame,3,L5,T1) |
| − | |||
| − | local L5_3 = | ||
| − | |||
| − | local D1Y = | + | local D1Y = getDateDPart(1,D1t) |
| − | + | local D1M = getDateDPart(2,D1t) | |
| − | local D1M = | + | local D1D = getDateDPart(3,D1t) |
| − | |||
| − | local D1D = | ||
| − | |||
| − | local D2Y = | + | local D2Y = getDateDPart(1,D2t) |
| − | + | local D2M = getDateDPart(2,D2t) | |
| − | local D2M = | + | local D2D = getDateDPart(3,D2t) |
| − | |||
| − | local D2D = | ||
| − | |||
| − | local D3Y = | + | local D3Y = getDateDPart(1,D3t) |
| − | + | local D3M = getDateDPart(2,D3t) | |
| − | local D3M = | + | local D3D = getDateDPart(3,D3t) |
| − | |||
| − | local D3D = | ||
| − | |||
| − | local D4Y = | + | local D4Y = getDateDPart(1,D4t) |
| − | + | local D4M = getDateDPart(2,D4t) | |
| − | local D4M = | + | local D4D = getDateDPart(3,D4t) |
| − | |||
| − | local D4D = | ||
| − | |||
| − | local D5Y = | + | local D5Y = getDateDPart(1,D5t) |
| − | + | local D5M = getDateDPart(2,D5t) | |
| − | local D5M = | + | local D5D = getDateDPart(3,D5t) |
| − | |||
| − | local D5D = | ||
| − | |||
local year, month, day | local year, month, day | ||
| + | local month1=0 | ||
| + | local month2=0 | ||
| + | local month3=0 | ||
| + | local month4=0 | ||
| + | local month5=0 | ||
| + | local month1D=0 | ||
| + | local month2D=0 | ||
| + | local month3D=0 | ||
| + | local month4D=0 | ||
| + | local month5D=0 | ||
local day1=0 | local day1=0 | ||
local day2=0 | local day2=0 | ||
| Line 218: | Line 214: | ||
year = math.max(L1_1,L2_1,L3_1,L4_1,L5_1,D1Y,D2Y,D3Y,D4Y,D5Y) | year = math.max(L1_1,L2_1,L3_1,L4_1,L5_1,D1Y,D2Y,D3Y,D4Y,D5Y) | ||
| − | month = monthName(math.max( | + | |
| + | if(year == L1_1) then month1=L1_2 end | ||
| + | if(year == L2_1) then month2=L2_2 end | ||
| + | if(year == L3_1) then month3=L3_2 end | ||
| + | if(year == L4_1) then month4=L4_2 end | ||
| + | if(year == L5_1) then month5=L5_2 end | ||
| + | if(year == D1Y) then month1D=D1M end | ||
| + | if(year == D2Y) then month2D=D2M end | ||
| + | if(year == D3Y) then month3D=D3M end | ||
| + | if(year == D4Y) then month4D=D4M end | ||
| + | if(year == D5Y) then month5D=D5M end | ||
| + | |||
| + | month = monthName(math.max(month1,month2,month3,month4,month5,month1D,month2D,month3D,month4D,month5D)) | ||
if(monthNum(month) == L1_2) then day1=L1_3 end | if(monthNum(month) == L1_2) then day1=L1_3 end | ||
| Line 233: | Line 241: | ||
day = math.max(day1,day2,day3,day4,day5,day1D,day2D,day3D,day4D,day5D) | day = math.max(day1,day2,day3,day4,day5,day1D,day2D,day3D,day4D,day5D) | ||
| − | local S1 = | + | local S1 = getS(frame,S1,T2,T3) |
| − | + | local S2 = getS(frame,S2,T2,T3) | |
| − | local S2 = | + | local S3 = getS(frame,S3,T2,T3) |
| − | + | local S4 = getS(frame,S4,T2,T3) | |
| − | local S3 = | + | local S5 = getS(frame,S5,T2,T3) |
| − | + | local S6 = getS(frame,S6,T2,T3) | |
| − | local S4 = | + | local S7 = getS(frame,S7,T2,T3) |
| − | + | local S8 = getS(frame,S8,T2,T3) | |
| − | local S5 = | + | local S9 = getS(frame,S9,T2,T3) |
| − | + | local S10 = getS(frame,S10,T2,T3) | |
| − | local S6 = | ||
| − | |||
| − | local S7 = | ||
| − | |||
| − | local S8 = | ||
| − | |||
| − | local S9 = | ||
| − | |||
| − | local S10 = | ||
| − | |||
if(year == nil) then year = "year" end | if(year == nil) then year = "year" end | ||
Revision as of 16:00, 10 June 2020
Implements {{Franchise total episodes}}
local p = {};
local monthName = function(I1)
if(I1 == 1) then return 'January' end
if(I1 == 2) then return 'February' end
if(I1 == 3) then return 'March' end
if(I1 == 4) then return 'April' end
if(I1 == 5) then return 'May' end
if(I1 == 6) then return 'June' end
if(I1 == 7) then return 'July' end
if(I1 == 8) then return 'August' end
if(I1 == 9) then return 'September' end
if(I1 == 10) then return 'October' end
if(I1 == 11) then return 'November' end
if(I1 == 12) then return 'December' end
if(I1 == 0) then return 0 end
end
local monthNum = function(I1)
if(I1 == 'January') then return 1 end
if(I1 == 'February') then return 2 end
if(I1 == 'March') then return 3 end
if(I1 == 'April') then return 4 end
if(I1 == 'May') then return 5 end
if(I1 == 'June') then return 6 end
if(I1 == 'July') then return 7 end
if(I1 == 'August') then return 8 end
if(I1 == 'September') then return 9 end
if(I1 == 'October') then return 10 end
if(I1 == 'November') then return 11 end
if(I1 == 'December') then return 12 end
return I1
end
local expand = function(frame,page,template,one,two,three)
local result = (frame:expandTemplate{title='Template parameter value',args={page,template,one,two,three}})
return result
end
local getDateDFull = function(frame,value,i)
if(value ~= 'none none none none') then
local number = (expand(frame,value,"Infobox television",1,"num_episodes",1)+i)
value = expand(frame,value,"Episode list",number,"OriginalAirDate",1)
end
value = string.gsub(value, ",", "")
local t = {}
for substring in value:gmatch("%w+") do
table.insert(t,substring)
end
return t
end
local getDateDPart = function(num,t)
local value
if(num==1) then
value = tonumber(monthNum(t[5]))
if(value == nil) then value = 0 end
end
if(num==2) then
value = tonumber(monthNum(t[1]))
if(value == nil) then value = 0 end
end
if(num==3) then
value = tonumber(monthNum(t[3]))
if(value == nil) then value = 0 end
end
return value
end
local getDateL = function(frame,num,L,T)
local value
if(num==1) then
value = tonumber(expand(frame,L,T,1,1,1))
if(value == nil) then value = 0 end
end
if(num==2) then
value = tonumber(expand(frame,L,T,1,2,1))
if(value == nil) then value = 0 end
end
if(num==3) then
value = tonumber(expand(frame,L,T,1,3,1))
if(value == nil) then value = 0 end
end
return value
end
local getS = function(frame,S,T1,T2)
local value = tonumber(expand(frame,S,T1,1,T2,1))
if(value == nil) then value = 0 end
return value
end
p.main = function( frame )
local D1 = mw.getCurrentFrame():getParent().args.D1 or frame.args.D1
if(D1 == nil) then D1 = "none none none none" end
D1 = tostring(D1)
local D2 = mw.getCurrentFrame():getParent().args.D2 or frame.args.D2
if(D2 == nil) then D2 = "none none none none" end
D2 = tostring(D2)
local D3 = mw.getCurrentFrame():getParent().args.D3 or frame.args.D3
if(D3 == nil) then D3 = "none none none none" end
D3 = tostring(D3)
local D4 = mw.getCurrentFrame():getParent().args.D4 or frame.args.D4
if(D4 == nil) then D4 = "none none none none" end
D4 = tostring(D4)
local D5 = mw.getCurrentFrame():getParent().args.D5 or frame.args.D5
if(D5 == nil) then D5 = "none none none none" end
D5 = tostring(D5)
local D1I = mw.getCurrentFrame():getParent().args.D1I or frame.args.D1I or 0
local D2I = mw.getCurrentFrame():getParent().args.D2I or frame.args.D2I or 0
local D3I = mw.getCurrentFrame():getParent().args.D3I or frame.args.D3I or 0
local D4I = mw.getCurrentFrame():getParent().args.D4I or frame.args.D4I or 0
local D5I = mw.getCurrentFrame():getParent().args.D5I or frame.args.D5I or 0
local L1 = mw.getCurrentFrame():getParent().args.L1 or frame.args.L1
local L2 = mw.getCurrentFrame():getParent().args.L2 or frame.args.L2
local L3 = mw.getCurrentFrame():getParent().args.L3 or frame.args.L3
local L4 = mw.getCurrentFrame():getParent().args.L4 or frame.args.L4
local L5 = mw.getCurrentFrame():getParent().args.L5 or frame.args.L5
local T1 = 'Aired episodes'
local T2 = 'Infobox television'
local T3 = 'num_episodes'
local S1 = mw.getCurrentFrame():getParent().args.S1 or frame.args.S1
local S2 = mw.getCurrentFrame():getParent().args.S2 or frame.args.S2
local S3 = mw.getCurrentFrame():getParent().args.S3 or frame.args.S3
local S4 = mw.getCurrentFrame():getParent().args.S4 or frame.args.S4
local S5 = mw.getCurrentFrame():getParent().args.S5 or frame.args.S5
local S6 = mw.getCurrentFrame():getParent().args.S6 or frame.args.S6
local S7 = mw.getCurrentFrame():getParent().args.S7 or frame.args.S7
local S8 = mw.getCurrentFrame():getParent().args.S8 or frame.args.S8
local S9 = mw.getCurrentFrame():getParent().args.S9 or frame.args.S9
local S10 = mw.getCurrentFrame():getParent().args.S10 or frame.args.S10
local name = mw.getCurrentFrame():getParent().args.name or frame.args.name
name = tostring(name)
if(name == 'nil') then name = "name" end
local Date = mw.getCurrentFrame():getParent().args.Date or frame.args.Date
local sum = mw.getCurrentFrame():getParent().args.sum or frame.args.sum
local D1t = getDateDFull(frame,D1,D1I)
local D2t = getDateDFull(frame,D2,D2I)
local D3t = getDateDFull(frame,D3,D3I)
local D4t = getDateDFull(frame,D4,D4I)
local D5t = getDateDFull(frame,D5,D5I)
local L1_1 = getDateL(frame,1,L1,T1)
local L1_2 = getDateL(frame,2,L1,T1)
local L1_3 = getDateL(frame,3,L1,T1)
local L2_1 = getDateL(frame,1,L2,T1)
local L2_2 = getDateL(frame,2,L2,T1)
local L2_3 = getDateL(frame,3,L2,T1)
local L3_1 = getDateL(frame,1,L3,T1)
local L3_2 = getDateL(frame,2,L3,T1)
local L3_3 = getDateL(frame,3,L3,T1)
local L4_1 = getDateL(frame,1,L4,T1)
local L4_2 = getDateL(frame,2,L4,T1)
local L4_3 = getDateL(frame,3,L4,T1)
local L5_1 = getDateL(frame,1,L5,T1)
local L5_2 = getDateL(frame,2,L5,T1)
local L5_3 = getDateL(frame,3,L5,T1)
local D1Y = getDateDPart(1,D1t)
local D1M = getDateDPart(2,D1t)
local D1D = getDateDPart(3,D1t)
local D2Y = getDateDPart(1,D2t)
local D2M = getDateDPart(2,D2t)
local D2D = getDateDPart(3,D2t)
local D3Y = getDateDPart(1,D3t)
local D3M = getDateDPart(2,D3t)
local D3D = getDateDPart(3,D3t)
local D4Y = getDateDPart(1,D4t)
local D4M = getDateDPart(2,D4t)
local D4D = getDateDPart(3,D4t)
local D5Y = getDateDPart(1,D5t)
local D5M = getDateDPart(2,D5t)
local D5D = getDateDPart(3,D5t)
local year, month, day
local month1=0
local month2=0
local month3=0
local month4=0
local month5=0
local month1D=0
local month2D=0
local month3D=0
local month4D=0
local month5D=0
local day1=0
local day2=0
local day3=0
local day4=0
local day5=0
local day1D=0
local day2D=0
local day3D=0
local day4D=0
local day5D=0
year = math.max(L1_1,L2_1,L3_1,L4_1,L5_1,D1Y,D2Y,D3Y,D4Y,D5Y)
if(year == L1_1) then month1=L1_2 end
if(year == L2_1) then month2=L2_2 end
if(year == L3_1) then month3=L3_2 end
if(year == L4_1) then month4=L4_2 end
if(year == L5_1) then month5=L5_2 end
if(year == D1Y) then month1D=D1M end
if(year == D2Y) then month2D=D2M end
if(year == D3Y) then month3D=D3M end
if(year == D4Y) then month4D=D4M end
if(year == D5Y) then month5D=D5M end
month = monthName(math.max(month1,month2,month3,month4,month5,month1D,month2D,month3D,month4D,month5D))
if(monthNum(month) == L1_2) then day1=L1_3 end
if(monthNum(month) == L2_2) then day2=L2_3 end
if(monthNum(month) == L3_2) then day3=L3_3 end
if(monthNum(month) == L4_2) then day4=L4_3 end
if(monthNum(month) == L5_2) then day5=L5_3 end
if(monthNum(month) == D1M) then day1D=D1D end
if(monthNum(month) == D2M) then day2D=D2D end
if(monthNum(month) == D3M) then day3D=D3D end
if(monthNum(month) == D4M) then day4D=D4D end
if(monthNum(month) == D5M) then day5D=D5D end
day = math.max(day1,day2,day3,day4,day5,day1D,day2D,day3D,day4D,day5D)
local S1 = getS(frame,S1,T2,T3)
local S2 = getS(frame,S2,T2,T3)
local S3 = getS(frame,S3,T2,T3)
local S4 = getS(frame,S4,T2,T3)
local S5 = getS(frame,S5,T2,T3)
local S6 = getS(frame,S6,T2,T3)
local S7 = getS(frame,S7,T2,T3)
local S8 = getS(frame,S8,T2,T3)
local S9 = getS(frame,S9,T2,T3)
local S10 = getS(frame,S10,T2,T3)
if(year == nil) then year = "year" end
if(month == nil) then month = "month" end
if(day == nil) then day = "day" end
if(Date == nil) then Date = month .. " " .. day .. ", " .. year end
if(sum == nil) then sum = (mw.getContentLanguage():formatNum(S1+S2+S3+S4+S5+S6+S7+S8+S9+S10)) end
return "As of " .. Date .. ", " .. sum .. " episodes of the ''" .. name .. "'' franchise have aired."
end
return p