Module:Bilibili id

From Team Fortress Wiki
Revision as of 09:14, 14 July 2025 by Tark (talk | contribs) (Created page with "local p = {} function p.main(f) local input = f.args[1] if not input then error("No video ID provided") end -- aid / cid if tonumber(input) then...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Documentation for this module may be created at Module:Bilibili id/doc

local p = {}

function p.main(f)
    local input = f.args[1]

    if not input then
        error("No video ID provided")
    end

    -- aid / cid
    if tonumber(input) then
        return input
    end

    -- bvid
    local bvid = "^BV[0-9A-Za-z][0-9A-Za-z][0-9A-Za-z][0-9A-Za-z][0-9A-Za-z][0-9A-Za-z][0-9A-Za-z][0-9A-Za-z][0-9A-Za-z][0-9A-Za-z]$"
    if string.match(input, bvid) then
        return input
    else
        error("Invalid ID format")
    end
end

return p