本网站正在建设中(~ ̄▽ ̄)~

  • 你好~!欢迎来到中文歌声合成个人收集站-VCPedia.cn!
  • 若发现页面信息有误投稿至本站,请联系管理员。

Module:BilibiliVideoIDValidator

VCPedia.cn ——关于中文歌声合成的一切。
跳到导航 跳到搜索
Template-info.svg 模块文档  [创建] [刷新]
  1. return {
  2. validation = function(frame)
  3. local flag = false
  4. local id = mw.text.trim(frame.args.id or "")
  5. local regex = "[A-HJ-NP-Za-km-z1-9]+$"
  6. -- 1. 有明确的 av 前缀且符合 aid 规则
  7. if mw.ustring.match(id, "^[Aa][Vv][1-9]%d*$") then
  8. flag = true
  9. -- 2. 有明确的 bv 前缀且符合 bvid 规则
  10. elseif string.len(id) == 12 and mw.ustring.match(id, "^[bB][vV]1" .. regex) then
  11. flag = true
  12. -- 3. 没有明确的前缀,但符合 aid 规则
  13. elseif mw.ustring.match(id, "^[1-9]%d*$") then
  14. flag = true
  15. -- 4. 没有明确的前缀,但符合 bvid 规则且不符合 aid 规则
  16. elseif string.len(id) == 10 and mw.ustring.match(id, "^1" .. regex)
  17. or string.len(id) == 9 and mw.ustring.match(id, "^" .. regex) then
  18. flag = true
  19. -- 5. 无法判断
  20. end
  21. if flag then
  22. return ""
  23. else
  24. return frame.args.result or frame:expandTemplate { title = "ArticleCategory", args = { "Bilibili视频ID错误", }, } ..
  25. '<strong class="error BilibiliVideoIDValidatorArgument" style="display:none">' ..
  26. frame.args.id .. "</strong>"
  27. end
  28. end,
  29. }
  30. -- 同步自MGP,来自萌娘百科用户鬼影233、AnnAngela、Dreammu的编辑