Created
December 19, 2014 13:44
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 Mp4upload = {} | |
function ident(qargs) | |
return { | |
can_parse_url = Mp4upload.can_parse_url(qargs), | |
domains = table.concat({'mp4upload.com'}, ',') | |
} | |
end | |
-- Parse the media properties. | |
function parse(qargs) | |
qargs.id = qargs.input_url:match("embed%-(%w+)") or error("no match: id") | |
qargs.title = qargs.id | |
local p = quvi.http.fetch(qargs.input_url).data | |
qargs.thumbnail_url = p:match("'?image'?: '(.-)'") or error("no match: thumbnail") | |
local f = p:match("'?file'?: '(.-)'") or error("no match: file") | |
qargs.streams = Mp4upload.iter_streams(f) | |
return qargs | |
end | |
-- | |
-- Utility functions | |
-- | |
function Mp4upload.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('mp4upload%.com$') | |
then | |
return true | |
else | |
return false | |
end | |
end | |
function Mp4upload.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