diff options
author | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2014-02-07 13:40:32 +0100 |
---|---|---|
committer | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2014-02-07 13:40:32 +0100 |
commit | ec64ea9653f5537b573578667953245b070514e6 (patch) | |
tree | 829640647260e3d8327d0c6a367aaf541be48fc4 | |
parent | 8643c0593feaa1487c3d9a97b024b5235f9f966b (diff) | |
download | dotfiles-ec64ea9653f5537b573578667953245b070514e6.tar.gz dotfiles-ec64ea9653f5537b573578667953245b070514e6.tar.bz2 dotfiles-ec64ea9653f5537b573578667953245b070514e6.zip |
quvi 0.9: Add script for vidstream.in
-rw-r--r-- | .local/share/libquvi-scripts/media/vidstream.lua | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/.local/share/libquvi-scripts/media/vidstream.lua b/.local/share/libquvi-scripts/media/vidstream.lua new file mode 100644 index 0000000..916599a --- /dev/null +++ b/.local/share/libquvi-scripts/media/vidstream.lua @@ -0,0 +1,50 @@ +-- libquvi-scripts + +local Vidstream = {} + +-- Identify the script. +function ident(qargs) + return { + domains = table.concat({'vidstream.in'}, ','), + can_parse_url = Vidstream.can_parse_url(qargs) + } +end + +-- Parse media URL. +function parse(qargs) + local c = quvi.http.fetch(qargs.input_url).data + local p = { op = "download1", imhuman = "Proceed+to+video", + id = qargs.input_url:match('vidstream.in/([^/]+)'), + hash = c:match('name="hash" value="(.-)"') } + local R = require 'soup_request' + c = R.request(qargs.input_url, "POST", p) + + qargs.id = p.id + qargs.title = c:match('property="og:title"%s+content="(.-)"') + qargs.thumb_url = c:match('property="og:image"%s+content="(.-)"') + qargs.duration_ms = tonumber(c:match('duration:%s*"(%d+)"') or 0) * 1000 + qargs.streams = Vidstream.iter_streams(c, qargs) + + return qargs +end + +function Vidstream.iter_streams(c, qargs) + local S = require 'quvi/stream' + + url,container = c:match('file:%s*"(.-/)v%.(.-)"') + local s = S.stream_new(table.concat({url, "v.", container})) + s.container = container + return { s } +end + +function Vidstream.can_parse_url(qargs) + local U = require 'socket.url' + local t = U.parse(qargs.input_url) + + return t and t.scheme and t.scheme:lower():match('^http$') + and t.host and t.host:lower():match('vidstream%.in$') + and t.path and t.path:match("^/[a-z0-9]+") + and true or false +end + +-- vim: set ts=2 sw=2 tw=72 expandtab: |