Documentation for this module may be created at Module:TVChannelList/doc
local p = {}
local arg = ...
local i18n
function p.channel(frame)
local args = require('Module:Arguments').getArgs(frame, {wrappers = 'Template:TVChannelList'})
if not args.channel or args.channel == '' then
return string.format('|-\n| colspan="6" style="text-align:center;vertical-align:middle;color:red;font-weight:bold;" | Channel name is empty\n')
end
local channel, error = getChannel(args.channel)
if error then
return string.format('|-\n| colspan="6" style="text-align:center;vertical-align:middle;color:red;font-weight:bold;" | %s\n', error)
elseif channel then
-- Format channel data
local channelType = channel.type or args.type or 'Channel'
local genre = channel.genre or args.genre or 'N/A'
local alias = args.alias or channel.alias or 'N/A'
local notes = args.notes or channel.notes or 'N/A'
-- Handle multiple platforms/websites
local platforms = {}
if channel.website and channel.website ~= '' then
table.insert(platforms, string.format('[%s Website]', channel.website))
end
if channel.xvideos and channel.xvideos ~= '' then
table.insert(platforms, string.format('[%s Xvideos Channel]', channel.xvideos))
end
if channel.streaming and channel.streaming ~= '' then
table.insert(platforms, string.format('[%s Streaming]', channel.streaming))
end
local platformsStr = #platforms > 0 and table.concat(platforms, ' & ') or 'N/A'
-- Format the row
local result = string.format(
'|-\n| style="text-align:center;vertical-align:middle;" | %s\n| style="text-align:center;vertical-align:middle;" | %s\n| style="text-align:center;vertical-align:middle;" | %s\n| style="text-align:center;vertical-align:middle;" | %s\n| style="text-align:center;vertical-align:middle;" | %s\n| style="text-align:center;vertical-align:middle;" | %s\n',
channel.name,
channelType,
platformsStr,
genre,
alias,
notes
)
-- Add categories if in main namespace
local ns = mw.title.getCurrentTitle().namespace
if ns == 0 then
if type(channel.category) == "table" then
for _, cat in pairs(channel.category) do
if cat ~= '' then
result = result .. '[[Category:' .. cat .. ']]'
end
end
elseif channel.category and channel.category ~= '' then
result = result .. '[[Category:' .. channel.category .. ']]'
end
result = result .. '[[Category:Television Networks]]'
end
return result
else
return string.format('|-\n| colspan="6" style="text-align:center;vertical-align:middle;color:red;font-weight:bold;" | Invalid channel: %s\n', args.channel)
end
end