summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Franzke <benjaminfranzke@googlemail.com>2014-02-04 21:26:55 +0100
committerBenjamin Franzke <benjaminfranzke@googlemail.com>2014-02-06 13:03:46 +0100
commit686da6ec55e74000948ac35e5c5e2816ff579147 (patch)
tree1cb1856189b652569381bff08507eb96b5933bb3
parent08e78b449ddb71ca7ec1c580ec5b3f738a34f495 (diff)
downloaddotfiles-686da6ec55e74000948ac35e5c5e2816ff579147.tar.gz
dotfiles-686da6ec55e74000948ac35e5c5e2816ff579147.tar.bz2
dotfiles-686da6ec55e74000948ac35e5c5e2816ff579147.zip
quvi 0.9: Add radiode script
-rw-r--r--.local/share/libquvi-scripts/media/radiode.lua42
1 files changed, 42 insertions, 0 deletions
diff --git a/.local/share/libquvi-scripts/media/radiode.lua b/.local/share/libquvi-scripts/media/radiode.lua
new file mode 100644
index 0000000..7b0f1c6
--- /dev/null
+++ b/.local/share/libquvi-scripts/media/radiode.lua
@@ -0,0 +1,42 @@
+-- libquvi-scripts
+
+local Radio = {}
+
+-- Identify the script.
+function ident(qargs)
+ return {
+ domains = table.concat({'radio.de'}, ','),
+ can_parse_url = Radio.can_parse_url(qargs)
+ }
+end
+
+-- Parse media URL.
+function parse(qargs)
+ local S = require 'quvi/stream'
+ local c = quvi.http.fetch(qargs.input_url).data
+
+ if c:match('<error>') then
+ local s = c:match('<message>(.-)[\n<]')
+ error((not s) and "no match: error message" or s)
+ end
+
+ qargs.id = qargs.input_url:match('http://(.-)%.radio%.de')
+ qargs.title = c:match('property="og:title" content="(.-)">')
+ qargs.thumb_url = c:match('property="og:image" content="(.-)"')
+
+ local url = c:match('_getPlaylist.*"stream":"(.-)"')
+ qargs.streams = { S.stream_new(url) }
+
+ return qargs
+end
+
+function Radio.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('.-%.radio%.de$')
+ and t.host ~= "www.radio.de" and true or false
+end
+
+-- vim: set ts=2 sw=2 tw=72 expandtab: