Module:RandomArchiveVideo
Documentation for this module may be created at Module:RandomArchiveVideo/doc
-- Module:RandomVideoEmbedder local p = {} function p.main(frame) local xmlData = p.fetchXmlData() local videoUrl = p.getRandomVideoUrl(xmlData) return p.embedVideo(videoUrl) end function p.fetchXmlData() -- Fetch XML data from the server and return it as a string local url = 'https://tonyy.us-southeast-1.linodeobjects.com/' local result, data = pcall(mw.ext.http.get, url) if result then return data else return '' end end function p.getRandomVideoUrl(xmlData) -- Parse XML data and return a random video URL -- Implement your XML parsing logic here -- For simplicity, let's assume the XML contains video URLs as direct text content of 'video' elements local videos = mw.text.split(xmlData, '\n') -- Change this based on your actual XML structure return videos[math.random(#videos)] end function p.embedVideo(videoUrl) -- Use the Html5media widget to embed the video local width = 640 local height = 360 return mw.getCurrentFrame():expandTemplate{ title = '#widget:Html5media', args = { url = videoUrl, width = width, height = height } } end return p