From 3096ff93834e4ec719c710fd5c6492d586ff8a70 Mon Sep 17 00:00:00 2001 From: Toni Gundogdu Date: Fri, 4 Jan 2013 00:39:27 +0200 Subject: [PATCH] wdrmaus.lua: fail if required properties cannot be parsed Fail with an error of the required media properties {title,id,url} could not be parsed. Do not set self.default (unused). Cleanup code for improved readability. Signed-off-by: Toni Gundogdu --- share/lua/website/wdrmaus.lua | 46 ++++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/share/lua/website/wdrmaus.lua b/share/lua/website/wdrmaus.lua index 3ee2520..9ca35cd 100644 --- a/share/lua/website/wdrmaus.lua +++ b/share/lua/website/wdrmaus.lua @@ -99,69 +99,75 @@ end function WdrMaus.parseElefantenseite(self) self.id = self.page_url:match('\/([%w_]-)$') - or error('no match: media id') + or error('no match: media ID') local rooturl = self.page_url:match('(%w+://.+/%w+)/.*') + or error('no match: root url') + local qo = {fetch_type='config'} local configuration = quvi.fetch(rooturl .. '/data/configuration.php5', qo) + local streamingServerPath = WdrMaus.getXMLvalue(configuration, 'streamingServerPath') + local toc = quvi.fetch(rooturl .. '/data/tableOfContents.php5', qo) + local metadataPath = WdrMaus.getMetadataPathFromToc(toc, self.id) local metadata = quvi.fetch(rooturl .. '/' .. metadataPath, qo); streamingServerPath = string.gsub(streamingServerPath, '/$', '') - self.url = { streamingServerPath - .. WdrMaus.getXMLvalue(metadata, 'file') } + self.url = { streamingServerPath .. WdrMaus.getXMLvalue(metadata, 'file') } self.title = WdrMaus.getXMLvalue(metadata, 'title') + -- no idea why this url has a diffent host self.thumbnail_url = 'http://www.wdr.de/bilder/mediendb/elefant_online' .. WdrMaus.getXMLvalue(metadata, 'image') - self.format = 'default' return self end function WdrMaus.parseKaeptnblaubaerseite(self) - self.id = self.page_url:match('/([^/]-)$') + self.id = self.page_url:match('/([^/]-)$') or error('no match: media ID') + local qo = {fetch_type='config'} local metadatasite = quvi.fetch( 'http://www.wdrmaus.de/kaeptnblaubaerseite/baerchen/tv.php5', qo) + local matcher = string.gsub(self.id, '-' , '.') metadata = metadatasite:match('.*(%s-(.-)%s-%s-(.-)%s-(.-)<') - self.url = { metadata:match('(rtmp.-mp4)') } - self.format = 'default' + self.title = metadata:match('h1_019DCE">(.-)<') or error('no match: title') + self.url = { metadata:match('(rtmp.-mp4)') + or error('no match: media stream URL') } return self end function WdrMaus.getXMLvalue(str, value) ret = str:match('<' .. value .. '>(.-)') - or error('Cannot match ' .. value) - ret = ret:match('') or ret - return ret + or error('Cannot match ' .. value) + return ret:match('') or ret end function WdrMaus.getMetadataPathFromToc(toc, id) -- the toc contains all paths for this root (f.i. elefantenkino) - local page = string.match(toc, '.-(' .. id .. '.-)') + local page = toc:match('.-(' .. id .. '.-)') + or error('no match: metadata path') return WdrMaus.getXMLvalue(page, 'xmlPath') end -- vim: set ts=2 sw=2 tw=72 expandtab: - -- 2.11.4.GIT