Content deleted Content added
No edit summary
Cozy (talk | contribs)
No edit summary
 
(2 intermediate revisions by one other user not shown)
Line 4:
local i18n
 
-- Initialize i18n data for error messagesmessagesx
local function loadI18n()
if not i18n then
Line 60:
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
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,local firstLetter = name:sub(1, 1):upper())
table.insert(modulesToTry, firstLetter)
-- Handle "The" prefix in channel names
local nameWithoutThe = name:lower():gsub("^the%s*", ""):gsub("%s*", "")
if nameWithoutThe ~= name:lower() then
table.insert(modulesToTry,local theFirstLetter = nameWithoutThe:sub(1, 1):upper())
if theFirstLetter ~= firstLetter then
table.insert(matchedChannelsmodulesToTry, channeltheFirstLetter)
end
end
 
-- Add original first letter to modules to try
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.redirects) == "table" and type(channelModule.redirects[name:lower(channels)] == "table" then
local matchedChannels = {}
local matchedChannels = {}
-- Check redirects first
-- First try direct match or aliases
if channelModule.redirects and channelModule.redirects[name:lower()] then
returnfor getChannel_, channel in pairs(channelModule.redirects[name:lower()]channels) do
if channel.name:lower() == name:lower() or
end
(channel.aliases and table.contains(channel.aliases, name:lower())) then
-- Look for matches in channel names and aliases table.insert(matchedChannels, channel)
for _, channel in pairs(channelModule.channels) do end
if channel.name:lower() == name:lower() or
(channel.aliases and table.contains(channel.aliases, name:lower())) then
table.insert(matchedChannels, channel)
end
end
-- If found matches, return results
-- Handle multiple matches if #matchedChannels > 1 then
return nil, i18n.errors.duplicateChannels
if #matchedChannels > 1 then
returnelseif nil,#matchedChannels i18n.errors.duplicateChannels== 1 then
elseif #matchedChannels == 1 then return matchedChannels[1]
return matchedChannels[1]end
-- 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