Module:RandomArchiveVideo: Difference between revisions
Jump to navigation
Jump to search
(THE SATELLITE MAN IS MAKING ME USE TEMPORARY CODE) |
mNo edit summary |
||
Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
function p.main(frame) | function p.main(frame) | ||
local xmlData = p.fetchXmlData() | local http = require('http') -- Loads the http module explicitly now | ||
local xmlData = p.fetchXmlData(http) | |||
local videoUrl = p.getRandomVideoUrl(xmlData) | local videoUrl = p.getRandomVideoUrl(xmlData) | ||
return p.embedVideo(videoUrl) | return p.embedVideo(videoUrl) | ||
end | end | ||
function p.fetchXmlData() | function p.fetchXmlData(http) | ||
local url = 'https://tonyy.us-southeast-1.linodeobjects.com/' | local url = 'https://tonyy.us-southeast-1.linodeobjects.com/' | ||
local result, data = pcall( | local result, data = pcall(http.get, url) | ||
if result then | if result then | ||
return data | return data | ||
Line 21: | Line 19: | ||
function p.getRandomVideoUrl(xmlData) | function p.getRandomVideoUrl(xmlData) | ||
return 'https://example.com/sample.mp4' -- Replace with actual logic pls | |||
end | end | ||
function p.embedVideo(videoUrl) | function p.embedVideo(videoUrl) | ||
local width = 640 | local width = 640 | ||
local height = 360 | local height = 360 |
Latest revision as of 21:38, 17 January 2024
Documentation for this module may be created at Module:RandomArchiveVideo/doc
local p = {} function p.main(frame) local http = require('http') -- Loads the http module explicitly now local xmlData = p.fetchXmlData(http) local videoUrl = p.getRandomVideoUrl(xmlData) return p.embedVideo(videoUrl) end function p.fetchXmlData(http) local url = 'https://tonyy.us-southeast-1.linodeobjects.com/' local result, data = pcall(http.get, url) if result then return data else return '' end end function p.getRandomVideoUrl(xmlData) return 'https://example.com/sample.mp4' -- Replace with actual logic pls end function p.embedVideo(videoUrl) local width = 640 local height = 360 return mw.getCurrentFrame():expandTemplate{ title = '#widget:Html5media', args = { url = videoUrl, width = width, height = height } } end return p