Skip to content

Instantly share code, notes, and snippets.

@fishman
Created December 19, 2014 13:44
Show Gist options
  • Save fishman/c973740eebffecf4d578 to your computer and use it in GitHub Desktop.
Save fishman/c973740eebffecf4d578 to your computer and use it in GitHub Desktop.
-- 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