From 2c61c0295635649193e7e97256dcfb251a6a0dd9 Mon Sep 17 00:00:00 2001 From: Benjamin Franzke Date: Thu, 16 Jan 2014 10:14:37 +0100 Subject: quvi/zdf: Use xml_get from util.lua (libquvi-scripts 0.4.21) --- .../libquvi-scripts/lua/website/zdfmediathek.lua | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/.local/share/libquvi-scripts/lua/website/zdfmediathek.lua b/.local/share/libquvi-scripts/lua/website/zdfmediathek.lua index d5075ef..0004cba 100644 --- a/.local/share/libquvi-scripts/lua/website/zdfmediathek.lua +++ b/.local/share/libquvi-scripts/lua/website/zdfmediathek.lua @@ -117,6 +117,7 @@ function ZDFmediathek.iter_formats(c) end function ZDFmediathek.get_config(self) + local U = require 'quvi/util' self.host_id = "zdfmediathek" self.id = self.page_url:match('/ZDFmediathek/#?/?beitrag/video/(%d+)') or @@ -128,16 +129,16 @@ function ZDFmediathek.get_config(self) local c = quvi.fetch(table.concat(xml), {fetch_type='config'}) if not(c:match('ok')) then - error(table.concat({'error:', xml_get(c, 'statuscode', false), '-', - xml_get(c, 'debuginfo', false)}, ' ')) + error(table.concat({'error:', U.xml_get(c, 'statuscode', false), '-', + U.xml_get(c, 'debuginfo', false)}, ' ')) end - self.title = xml_get(c, 'title', false) + self.title = U.xml_get(c, 'title', false) self.thumbnail_url = c:match('([^<]+)') -- Quirks for broken stream descriptors - if xml_get(c, 'type', false) == "livevideo" then + if U.xml_get(c, 'type', false) == "livevideo" then -- The server returns 403 without ?hdcore c = c:gsub('manifest%.f4m', 'manifest.f4m?hdcore') @@ -182,7 +183,7 @@ function ZDFmediathek.rank_type(f) end function ZDFmediathek.rank_quality(f) - local r = { + local rank = { hd = 6, veryhigh_ext = 5, veryhigh = 4, high = 3, med = 2, low = 1 } return rank[f.quality] and rank[f.quality] or 0 @@ -219,13 +220,4 @@ function ZDFmediathek.to_s(t) (t.height) and '_' .. t.height ..'p' or '') end - ---For very simple XML value extraction. -function xml_get(d, e, is_cdata) - local p = is_cdata and '.-%w+%[(.-)%].-' or '(.-)' - local t = {'<',e,'>', p, ''} - return d:match(table.concat(t)) - or error(table.concat({'no match: element: ',e})) -end - -- vim: set ts=4 sw=4 tw=72 expandtab: -- cgit