From b1ef77f2ad768cfb40edf4b6c80fbff04918e05c Mon Sep 17 00:00:00 2001 From: Benjamin Franzke Date: Tue, 14 Jan 2014 12:52:21 +0100 Subject: quvi/zdf: Support live streams --- .../libquvi-scripts/lua/website/zdfmediathek.lua | 67 ++++++++++++++-------- 1 file changed, 43 insertions(+), 24 deletions(-) diff --git a/.local/share/libquvi-scripts/lua/website/zdfmediathek.lua b/.local/share/libquvi-scripts/lua/website/zdfmediathek.lua index af061fc..9e75d4d 100644 --- a/.local/share/libquvi-scripts/lua/website/zdfmediathek.lua +++ b/.local/share/libquvi-scripts/lua/website/zdfmediathek.lua @@ -5,7 +5,8 @@ function ident(self) local r = {} r.domain = "zdf%.de" r.formats = "default|best" - r.categories = C.proto_http + local B = require 'quvi/bit' + r.categories = B.bit_or(C.proto_http, C.proto_rtsp) local U = require 'quvi/util' r.handles = U.handles(self.page_url, {r.domain}, {"/ZDFmediathek/"}) return r @@ -18,11 +19,44 @@ function query_formats(self) return self end +function parse_video(self, c) + local url = c:match('veryhigh%s*' .. + '(http://n?rodl%.zdf%.de/[^<]+%.mp4)') + or error("no match: url") + + local meta_url = c:match('hd%s*([^>]+%.meta)') + if meta_url then + url = http_mp4_from_meta(meta_url) or url + -- OLD code: + -- known replacements from veryhigh mp4 to hd mp4: + -- either: suffix _hd instead of _vh + --url = string.gsub(url, "_vh.mp4", "_hd.mp4") + -- or: + --url = string.gsub(url, "1596k_p13v9", "3056k_p15v9") + end + + if (c:match('576%s*1024')) then + url = string.gsub(url, "1456k_p13v11", "2256k_p14v11") + end + + self.url = { url } + + return self +end + +function parse_live_video(self, c) + self.url = { c:match("veryhigh%s*" .. + "(rtsp://[^<]+)") + or error("no match: rtsp url") } + return self +end + -- Parse media URL. function parse(self) self.host_id = "zdfmediathek" - self.id = self.page_url:match("/ZDFmediathek/#?/?beitrag/video/(%d+)") + self.id = self.page_url:match("/ZDFmediathek/#?/?beitrag/video/(%d+)") or + self.page_url:match("/ZDFmediathek/#?/?beitrag/live/(%d+)") or error ("no match: media id") local xml = { "http://www.zdf.de/", @@ -35,34 +69,19 @@ function parse(self) error(table.concat(msg)) end + local type = xml_get(c, 'type', false) self.title = xml_get(c, 'title', false) self.thumbnail_url = c:match(''.. '([^<]+)') - - local url = c:match('veryhigh%s*' .. - '(http://n?rodl%.zdf%.de/[^<]+%.mp4)') - - if (c:match('576%s*1024')) then - url = string.gsub(url, "1456k_p13v11", "2256k_p14v11") + if type == "video" then + return parse_video(self, c) + elseif type == "livevideo" then + return parse_live_video(self, c) + else + error("unknown video type") end - - meta = c:match('hd%s*([^>]+%.meta)') - if meta then - url = http_mp4_from_meta(meta) or url - -- OLD code: - -- known replacements from veryhigh mp4 to hd mp4: - -- either: suffix _hd instead of _vh - --url = string.gsub(url, "_vh.mp4", "_hd.mp4") - -- or: - --url = string.gsub(url, "1596k_p13v9", "3056k_p15v9") - end - - self.url = { url } - - return self end - -- utlity -- -- cgit