From c0add2d044fded209666dc789ce29b8b59915d65 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Thomas=20Wei=C3=9Fschuh?= Date: Sun, 14 Oct 2012 20:17:15 +0000 Subject: [PATCH] Add ard.lua MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This adds support for the 'ARD mediathek', the movie archive of the primary national television broadcaster of Germany. It's mediathek also servers videos from many smaller german broadcasters. Note: films are only available online for two weeks after airing. Certain films are only available at certain daytimes. In this case an error is raised. Signed-off-by: Thomas Weißschuh Tested-by: Toni Gundogdu --- share/Makefile.am | 1 + share/lua/website/ard.lua | 171 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 172 insertions(+) create mode 100644 share/lua/website/ard.lua diff --git a/share/Makefile.am b/share/Makefile.am index a457c39..27f7152 100644 --- a/share/Makefile.am +++ b/share/Makefile.am @@ -15,6 +15,7 @@ DIST_lua=\ lua/website/101greatgoals.lua \ lua/website/1tvru.lua \ lua/website/academicearth.lua \ + lua/website/ard.lua \ lua/website/audioboo.lua \ lua/website/bbc.lua \ lua/website/break.lua \ diff --git a/share/lua/website/ard.lua b/share/lua/website/ard.lua new file mode 100644 index 0000000..9b63367 --- /dev/null +++ b/share/lua/website/ard.lua @@ -0,0 +1,171 @@ +-- libquvi-scripts +-- Copyright (C) 2013 Thomas Weißschuh +-- +-- This file is part of libquvi-scripts . +-- +-- This library is free software; you can redistribute it and/or +-- modify it under the terms of the GNU Lesser General Public +-- License as published by the Free Software Foundation; either +-- version 2.1 of the License, or (at your option) any later version. +-- +-- This library is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +-- Lesser General Public License for more details. +-- +-- You should have received a copy of the GNU Lesser General Public +-- License along with this library; if not, write to the Free Software +-- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +-- 02110-1301 USA + +local Ard = {} + +function ident(self) + local C = require 'quvi/const' + local U = require 'quvi/util' + local B = require 'quvi/bit' + local r = {} + r.domain = 'www%.ardmediathek%.de' + r.formats = 'default|best' + r.categories = B.bit_or(C.proto_http, C.proto_rtmp) + r.handles = U.handles(self.page_url, {r.domain}, + nil, {"documentId=%d+$"}) + return r +end + +function query_formats(self) + local config = Ard.get_config(self) + local formats = Ard.iter_formats(config) + + local t = {} + for _,v in pairs(formats) do + table.insert(t, Ard.to_s(v)) + end + + table.sort(t) + self.formats = table.concat(t, "|") + + return self +end + +function parse(self) + + local config = Ard.get_config(self) + local Util = require 'quvi/util' + + Ard.test_availability(config) + + self.host_id = 'ard' + self.title = config:match( + 'ARD Mediathek %- Fehlerseite') then + error('invalid URL, maybe the media is no longer available') + end + + return c +end + +function Ard.choose_best(t) + return t[#t] -- return the last from the array +end + +function Ard.choose_default(t) + return t[1] -- return the first from the array +end + +function Ard.to_s(t) + s = t.container + + if t.encoding then + s = s .. '_' .. t.encoding + end + + if t.height then + s = s .. '_' .. t.height + elseif t.webx then + s = s .. '_' .. t.webx + else + s = s .. '_' .. t.quality + end + + return s +end + +function Ard.iter_formats(page) + local r = {} + local s = 'mediaCollection%.addMediaStream' + .. '%(0, (%d), "(.-)", "(.-)", "%w+"%);' + + for quality, prefix, suffix in page:gmatch(s) do + local u = prefix .. suffix + -- remove querystring + u = u:match('^(.-)?') or u + + -- .webs. or Web-S or .s. + local webx = suffix:match('%.web(%w)%.') or suffix:match('%.(%w)%.') + or suffix:match('[=%.]Web%-(%w)') + if webx then webx = 'web' .. webx:lower() end + + local height = suffix:match('_%d+x(%d+)[_%.]') + if height then height = 'p' .. height end + + local t = { + url = u, + container = suffix:match('^(...):') or suffix:match('%.(...)$') + or suffix:match('%.(...)$') or 'mp4', + quality = tonumber(quality), + encoding = suffix:match('%.(h264)%.'), + height = height, + webx = webx + } + table.insert(r,t) + end + + if #r == 0 then + error('no media urls found') + end + + return r +end + +-- vim: set ts=4 sw=4 sts=4 tw=72 expandtab: -- 2.11.4.GIT