Module:YouTubeSubscribers: Difference between revisions

Content deleted Content added
m Protected "Module:YouTubeSubscribers": High-risk template or module: 2510 transclusions (more info) ([Edit=Require extended confirmed access] (indefinite) [Move=Require extended confirmed access] (indefinite))
Trimmed redundancy, made code easier to read, and fixed a minor error from attempting to escape a character with a backslash like in Regex. If this edit somehow breaks Wikipedia, please inform me via trout.
Line 37:
if i then
-- year
parts[index] = tonumber(mw.ustring.gsub(dateStr:sub(ptr, i-1), "^\%+(.+)$", "%1"), 10) -- remove '+' sign (explicitly give base 10 to prevent error)
 
if parts[index] == -0 then
Line 87:
if aY < bY then
return true
ifelseif aY > bY then
end
 
if aY > bY then
return false
ifelseif aM < bM then
end
 
if aM < bM then
return true
ifelseif aM > bM then
end
 
if aM > bM then
return false
ifelseif aD < bD then
end
 
if aD < bD then
return true
end
Line 179 ⟶ 171:
qid = mw.wikibase.getEntityIdForCurrentPage()
end
error assert(qid, "No qid found for page. Please make a Wikidata item for this article")
if not qid then
error("No qid found for page. Please make a Wikidata item for this article")
end
local e = mw.wikibase.getEntity(qid)
error assert(e, "No such item found: " .. qid)
if not e then
error("No such item found: " .. qid)
end
return e
end
Line 209 ⟶ 197:
local e = getEntity(frame)
local chanId = getBestYtChanId(e)
error assert(chanId, "Could not find a single best YouTube channel ID for this item. Add a YouTube channel ID or set the rank of one channel ID to be preferred")
if not chanId then
error("Could not find a single best YouTube channel ID for this item. Add a YouTube channel ID or set the rank of one channel ID to be preferred")
end
local s = newestMatching(e, SUB_COUNT_PID, YT_CHAN_ID_PID, chanId)
if s then