Module:TVChannelList: Difference between revisions
Content deleted Content added
PeaceDeadC (talk | contribs) No edit summary |
No edit summary |
||
| (2 intermediate revisions by one other user not shown) | |||
Line 4:
local i18n
-- Initialize i18n data for error
local function loadI18n()
if not i18n then
Line 60:
end
if channel.xvideos and channel.xvideos ~= '' then
table.insert(platforms, string.format('[%s
end
if channel.streaming and channel.streaming ~= '' then
Line 110:
-- Function to find and retrieve channel data from appropriate module
function getChannel(name)
if not name then return nil, i18n.errors.channelIsEmpty end
local modulesToTry = {}
table.insert(modulesToTry, firstLetter)
-- Handle "The" prefix
local nameWithoutThe = name:lower():gsub("^the%s*", ""):gsub("%s*", "")
if nameWithoutThe ~= name:lower() then
if theFirstLetter ~= firstLetter then
end
▲ table.insert(modulesToTry, name:sub(1, 1):upper())
for _, module in ipairs(modulesToTry) do
local success, channelModule = pcall(require, 'Module:TVChannelList/' .. module)
if success then
if type(channelModule
local matchedChannels = {}
-- First try direct match or aliases
▲ if channelModule.redirects and channelModule.redirects[name:lower()] then
if channel.name:lower() == name:lower() or ▼
▲ end
(channel.aliases and table.contains(channel.aliases, name:lower())) then▼
▲ if channel.name:lower() == name:lower() or
▲ (channel.aliases and table.contains(channel.aliases, name:lower())) then
▲ table.insert(matchedChannels, channel)
end
-- If found matches, return results
return nil, i18n.errors.duplicateChannels
-- If no direct matches found, try redirects
if channelModule.redirects and channelModule.redirects[name:lower()] then
return getChannel(channelModule.redirects[name:lower()])
end
else
mw.log('Invalid module structure: Module:TVChannelList/' .. module)
end
else
| |||