Skip to content

Instantly share code, notes, and snippets.

@fishman
Created December 19, 2014 13:45
Show Gist options
  • Save fishman/33fbe21db2c923b1ba60 to your computer and use it in GitHub Desktop.
Save fishman/33fbe21db2c923b1ba60 to your computer and use it in GitHub Desktop.
-- libquvi-scripts
local Vidwoot = {}
function ident(qargs)
return {
can_parse_url = Vidwoot.can_parse_url(qargs),
domains = table.concat({'embed.vidwoot.com'}, ',')
}
end
-- Parse the media properties.
function parse(qargs)
-- Make mandatory: the ID is required for the json URL.
qargs.id = qargs.input_url:match("/embed.vidwoot.com/(%w+)") or error('no match: media ID')
local p = quvi.http.fetch(qargs.input_url).data
qargs.thumbnail_url = p:match('"og:image" content="(.-)"')
or error("no match: Thumbnail URL")
qargs.title = p:match('"og:title" content="(.-)"')
or error('no match: media title')
local u = p:match('"og:video" content="(.-)"')
or error("no match: media stream URL")
qargs.streams = Vidwoot.iter_streams(u)
return qargs
end
--
-- Utility functions
--
function Vidwoot.can_parse_url(qargs)
local U = require 'socket.url'
local t = U.parse(qargs.input_url)
if t and t.scheme and t.scheme:lower():match('^http$')
and t.host and t.host:lower():match('embed.vidwoot%.com$')
then
return true
else
return false
end
end
function Vidwoot.iter_streams(url)
local S = require 'quvi/stream'
return {S.stream_new(url)}
end
-- vim: set ts=4 sw=4 tw=72 expandtab:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment