Created
December 19, 2014 13:45
-
-
Save fishman/33fbe21db2c923b1ba60 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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