diff options
author | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2014-01-14 12:52:21 +0100 |
---|---|---|
committer | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2014-01-14 12:52:21 +0100 |
commit | b1ef77f2ad768cfb40edf4b6c80fbff04918e05c (patch) | |
tree | 30c96a0ee2cf28260e26fc97d553b00f375d2fdc /.local | |
parent | 952242168babec26e4c80a321ce5abc3e551eabd (diff) | |
download | dotfiles-b1ef77f2ad768cfb40edf4b6c80fbff04918e05c.tar.gz dotfiles-b1ef77f2ad768cfb40edf4b6c80fbff04918e05c.tar.bz2 dotfiles-b1ef77f2ad768cfb40edf4b6c80fbff04918e05c.zip |
quvi/zdf: Support live streams
Diffstat (limited to '.local')
-rw-r--r-- | .local/share/libquvi-scripts/lua/website/zdfmediathek.lua | 67 |
1 files 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('<quality>veryhigh</quality>%s*' .. + '<url>(http://n?rodl%.zdf%.de/[^<]+%.mp4)</url>') + or error("no match: url") + + local meta_url = c:match('<quality>hd</quality>%s*<url>([^>]+%.meta)</url>') + 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('<height>576</height>%s*<width>1024</width>')) 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("<quality>veryhigh</quality>%s*" .. + "<url>(rtsp://[^<]+)</url>") + 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('<teaserimage alt=".-" key="946x532">'.. '([^<]+)</teaserimage>') - - local url = c:match('<quality>veryhigh</quality>%s*' .. - '<url>(http://n?rodl%.zdf%.de/[^<]+%.mp4)</url>') - - if (c:match('<height>576</height>%s*<width>1024</width>')) 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('<quality>hd</quality>%s*<url>([^>]+%.meta)</url>') - 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 -- |