Module:Random Video
From Comprehensible Input Wiki
Documentation for this module may be created at Module:Random Video/doc
local p = {}
function randomVideo()
local g = mw.ext.externaldata.getWebData {
url = 'https://comprehensibleinputwiki.com/randomvideo.php',
format = 'JSON'
}
vidJson = '['
for k, v in ipairs(g) do
main_index = v['main_index']
id = v['id']
difficulty = v['difficulty']
title = v['title']
language_name = v['language_name']
channel = v['channel']
vidJson = vidJson .. '{"main_index": ' .. main_index .. ', "id": "' .. id .. '", "difficulty": "' .. difficulty .. '", "title": "' .. title .. '", "language": "' .. language_name .. '", "channel": "' .. channel .. '"},'
end
vidJson = vidJson .. ']'
return vidJson
end
function dump(o)
if type(o) == 'table' then
local s = '{ '
for k,v in pairs(o) do
if type(k) ~= 'number' then k = '"'..k..'"' end
s = s .. '\n['..k..'] = ' .. dump(v) .. ','
end
return s .. '} '
else
return tostring(o)
end
end
p.randomVideo = function()
return randomVideo()
end
return p