Module:Random Video

From Comprehensible Input Wiki
Revision as of 00:08, 4 April 2023 by Dimpizzy (talk | contribs) (Created page with "local p = {} function randomVideo() local g = mw.ext.externaldata.getWebData { url = 'https://comprehensibleinputwiki.com/randomvideo.php', data = {title, channel, id, difficulty, language_name}, format = 'JSON' } for key, value in ipairs(g) do video = mw.getCurrentFrame():callParserFunction( '#ev', 'youtube', value['id']) end return video end function dump(o) if type(o) == 'table' then...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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',
            data = {title, channel, id, difficulty, language_name},
            format = 'JSON'
        }

	    for key, value in ipairs(g) do
			video = mw.getCurrentFrame():callParserFunction( '#ev', 'youtube', value['id'])
	    end
	
        return video
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