Module:Episodes2

local p = {}

function p.peanuts(frame) local tArgs = frame:getParent if not(tArgs.args[1]) then tArgs = frame end local result result = '' title = mw.title.getCurrentTitle.text user = '' ytuser = 'UCH-_hzb2ILSCo9ftVSnrCIQ' collapse = 'mw-collapsed' dash = '' for key, value in ipairs(tArgs.args) do       -- remove spaces and \n of values to test editedvalue = string.gsub(string.gsub(value, "\n", "")," ","") if (tonumber(key) ~= nil) then -- Title of video if (key % 2 == 1) then result = result .. '|-\n! style="text-align:left;font-weight:normal;padding-left:5px" |' .. string.gsub(string.gsub(value, "\\", "&#124;"),"!","&#33;") .. '\n' -- YouTube link elseif (key % 2 == 0) then if (editedvalue == 'N/A') then result = result .. '| style="text-align:center" | N/A \n' elseif (string.len(editedvalue) ~= 11) then -- Error: YouTube link does not exist return ' Error! Please check that you have used the template right by checking the documentation here. ' ..                    'Reason: This is meant to be an 11 character YouTube link. There was an error at [' .. key .. ']: ' .. value .. ' '               else result = result .. '| style="text-align:center" |[https://www.youtube.com/watch?v=' .. editedvalue .. ' Watch]\n' end -- Yogscast link else result = result end elseif (key == 'ytuser') then ytuser = value elseif (key == 'collapse') then if (editedvalue == '1') then -- do not collapse the module collapse = '' end else -- Error: Unknown key return ' Error! Please check that you have used the template right by checking the documentation here. ' ..            'Reason: Unknown key (|randomname=). There was an error at [' .. key .. ']: ' .. value .. ' '       end end user = frame.args.user title = frame.args.title if (title ==  or title == ) then title = mw.title.getCurrentTitle.text end title = title:gsub("_", " ") if (title ~=  and user ~= ) then -- removes dash if either title or user don't exist dash = ' — ' end return '{| class="wikitable mw-collapsible ' .. collapse .. ' episodeguide" style="width:100%;clear:both;"' .. '\n' .. '!style="padding:10px;text-align:left;" colspan="4"|' .. user .. dash .. title .. '\n' .. '|-\n' .. '! width="70%" style="padding:10px;text-align:left" |Video Name\n' .. '! width="15%" style="text-align:center" |\n' .. '|-\n' .. result .. '|}' end

return p