diff options
author | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2014-02-06 20:06:18 +0100 |
---|---|---|
committer | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2014-02-06 20:06:18 +0100 |
commit | 6692c6f9521cf497963ccfda298f7d754e39843f (patch) | |
tree | 950ad451cb0220ddd033f8b8abc1c12bbb69d9de /.local/share/libquvi-scripts | |
parent | b62ed468eb63fee751ac708e01ab214c96b3efb8 (diff) | |
download | dotfiles-6692c6f9521cf497963ccfda298f7d754e39843f.tar.gz dotfiles-6692c6f9521cf497963ccfda298f7d754e39843f.tar.bz2 dotfiles-6692c6f9521cf497963ccfda298f7d754e39843f.zip |
quvi 0.9: Add script for dvixstage.eu
Diffstat (limited to '.local/share/libquvi-scripts')
-rw-r--r-- | .local/share/libquvi-scripts/media/dvixstage.lua | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/.local/share/libquvi-scripts/media/dvixstage.lua b/.local/share/libquvi-scripts/media/dvixstage.lua new file mode 100644 index 0000000..40dbb23 --- /dev/null +++ b/.local/share/libquvi-scripts/media/dvixstage.lua @@ -0,0 +1,45 @@ +-- libquvi-scripts + +local Dvixstage = {} + +-- Identify the script. +function ident(qargs) + return { + domains = table.concat({'divxstage.eu'}, ','), + can_parse_url = Dvixstage.can_parse_url(qargs) + } +end + +-- Parse media URL. +function parse(qargs) + local c = quvi.http.fetch(qargs.input_url).data + + qargs.id = c:match('file="(.-)"') or error("no match id") + qargs.title = c:match('<div class="video_det">%s+<strong>(.-)</strong>') + qargs.streams = Dvixstage.iter_streams(c, qargs) + + return qargs +end + +function Dvixstage.iter_streams(c, qargs) + local S = require 'quvi/stream' + + filekey = c:match('filekey="(.-)"') or error("no match: filekey") + api_url = { "http://www.divxstage.eu/api/player.api.php?file=", + qargs.id, "&key=", filekey} + url = quvi.http.fetch(table.concat(api_url)).data:match("url=([^&]+)") + + return { S.stream_new(url) } +end + +function Dvixstage.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('divxstage%.eu$') + and t.path and t.path:match("^/video/[a-z0-9]+") + and true or false +end + +-- vim: set ts=2 sw=2 tw=72 expandtab: |