Module:RecentRelease

-- local p = {} local releaseData = mw.loadData('Module:RecentRelease/data')

function removeParen(fullTitle) local title={} local length= mw.ustring.len(fullTitle) local par={} if mw.ustring.find(fullTitle,'(',1,true)==nil       then par=length        else par=mw.ustring.find(fullTitle,'(',1,true)-2 end local title=mw.ustring.sub(fullTitle,1,par) return title end function p.getInfo(frame) local obtaining= frame.args[1] local show= frame.args[2] if show=="The Flash (The CW)" then show="The Flash" end local result={} if releaseData[show] then if obtaining=="last" then result="" else if obtaining=="next" then if releaseData[show][3]=="season" then result="Season "                       ..releaseData[show][6]                        .."" else result="" end else if obtaining=="date" then result=releaseData[show][4] end end end else result=""           ..show            .."" end return frame:preprocess(result) end

function p.MPinfo(frame) local obtaining= frame.args[1] local show= frame.args[2] if show=="The Flash (The CW)" then show="The Flash" end local result={} if releaseData[show] then if obtaining=="last" then result=" "                        ..removeParen(releaseData[show][1])                        .."  " else if obtaining=="next" then if releaseData[show][3]=="season" then result=" Season "                        ..releaseData[show][6]                        .."  " else result=" "                            ..removeParen(releaseData[show][3])                            .."  " end else if obtaining=="date" then result=releaseData[show][4] end end end else result=""           ..show            .."" end return frame:preprocess(result) end

function p.current(frame) local show= frame.args[1] if show=="The Flash (The CW)" then show="The Flash" end if show=="DC&#39;s Legends of Tomorrow" then show="DC's Legends of Tomorrow" end local status1="?" local season="?" local status2="?" if releaseData[show] then season=releaseData[show][6] status1="upcoming" status2="episode" if releaseData[show][5]==releaseData[show][6] then status1="current" end if releaseData[show][3]=="season" then status1="most recent" status2="season" season=releaseData[show][5] end end local displayText="''For the " ..status1 .." season of " ..show ..", see Season "		..season		..". For the upcoming " ..status2 .." of " ..show ..", see .''" return frame:preprocess(displayText) end

function p.cc(frame) local show=frame.args[1] local ap="airs" if releaseData[removeParen(show)] then if releaseData[removeParen(show)][3]=="season" then ap="premieres" end end local CS="ColorSwitch" if show=="Black Lightning" then CS="ColorSwitch1" else if show=="Superman & Lois" then CS="ColorSwitch1" end end local displayText="* : " ..ap .." ! "	return frame:preprocess(displayText) end

return p