summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.local/share/libquvi-scripts/lua/website/zdfmediathek.lua67
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
--