打开/关闭菜单
打开/关闭外观设置菜单
打开/关闭个人菜单
未登录
未登录用户的IP地址会在进行任意编辑后公开展示。

Module:BilibiliVideoIDValidator

来自OGAS数据中枢

此模块的文档可以在Module:BilibiliVideoIDValidator/doc创建

return {
    validation = function(frame)
        local flag = false
        local id = mw.text.trim(frame.args.id or "")
        local regex = "[A-HJ-NP-Za-km-z1-9]+$"
        -- 1. 有明确的 av 前缀且符合 aid 规则
        if mw.ustring.match(id, "^[Aa][Vv][1-9]%d*$") then
            flag = true
            -- 2. 有明确的 bv 前缀且符合 bvid 规则
        elseif string.len(id) == 12 and mw.ustring.match(id, "^[bB][vV]1" .. regex) then
            flag = true
            -- 3. 没有明确的前缀,但符合 aid 规则
        elseif mw.ustring.match(id, "^[1-9]%d*$") then
            flag = true
            -- 4. 没有明确的前缀,但符合 bvid 规则且不符合 aid 规则
        elseif string.len(id) == 10 and mw.ustring.match(id, "^1" .. regex)
            or string.len(id) == 9 and mw.ustring.match(id, "^" .. regex) then
            flag = true
            -- 5. 无法判断
        end

        if flag then
            return ""
        else
            return frame.args.result or frame:expandTemplate { title = "ArticleCategory", args = { "Bilibili视频ID错误", }, } ..
                '<strong class="error BilibiliVideoIDValidatorArgument" style="display:none">' ..
                frame.args.id .. "</strong>"
        end
    end,
}