From 686da6ec55e74000948ac35e5c5e2816ff579147 Mon Sep 17 00:00:00 2001 From: Benjamin Franzke Date: Tue, 4 Feb 2014 21:26:55 +0100 Subject: quvi 0.9: Add radiode script --- .local/share/libquvi-scripts/media/radiode.lua | 42 ++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 .local/share/libquvi-scripts/media/radiode.lua 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('') then + local s = c:match('(.-)[\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: -- cgit