/usr/share/libquvi-scripts/lua/website/spiegel.lua is in libquvi-scripts 0.4.21-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | -- libquvi-scripts v0.4.21
-- Copyright (C) 2010-2011,2013 Toni Gundogdu <legatvs@gmail.com>
--
-- This file is part of libquvi-scripts <http://quvi.sourceforge.net/>.
--
-- 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
--
--
-- NOTE: mp4s do not appear to be available (404) even if listed.
--
local Spiegel = {} -- Utility functions unique to this script
-- Identify the script.
function ident(self)
package.path = self.script_dir .. '/?.lua'
local C = require 'quvi/const'
local r = {}
r.domain = "spiegel%.de"
r.formats = "default|best"
r.categories = C.proto_http
local U = require 'quvi/util'
r.handles = U.handles(self.page_url, {r.domain}, {"/video/"})
return r
end
-- Query available formats.
function query_formats(self)
Spiegel.get_media_id(self)
local config = Spiegel.get_config(self)
local formats = Spiegel.iter_formats(config)
local t = {}
for _,v in pairs(formats) do
table.insert(t, Spiegel.to_s(v))
end
table.sort(t)
self.formats = table.concat(t, "¦")
return self
end
-- Parse media URL.
function parse(self)
self.host_id = "spiegel"
local p = quvi.fetch(self.page_url)
self.title = p:match('"module%-title">(.-)</')
or p:match('"og:title".-content="(.-)%s+%-%s+SP')
or error('no match: media title')
self.thumbnail_url = p:match('"og:image" content="(.-)"') or ''
Spiegel.get_media_id(self)
local config = Spiegel.get_config(self)
local formats = Spiegel.iter_formats(config)
local U = require 'quvi/util'
local format = U.choose_format(self, formats,
Spiegel.choose_best,
Spiegel.choose_default,
Spiegel.to_s)
or error("unable to choose format")
self.duration = (format.duration or 0) * 1000 -- to msec
self.url = {format.url or error("no match: media url")}
return self
end
--
-- Utility functions
--
function Spiegel.get_media_id(self)
self.id = self.page_url:match("/video/.-video%-(.-)%.")
or error ("no match: media id")
end
function Spiegel.get_config(self)
local fmt_s = "http://video.spiegel.de/flash/%s.xml"
local config_url = string.format(fmt_s, self.id)
return quvi.fetch(config_url, {fetch_type = 'config'})
end
function Spiegel.iter_formats(config)
local p = '<filename>(.-)<'
.. '.-<codec>(.-)<'
.. '.-<totalbitrate>(%d+)'
.. '.-<width>(%d+)'
.. '.-<height>(%d+)'
.. '.-<duration>(%d+)'
local t = {}
for fn,c,b,w,h,d in config:gmatch(p) do
local cn = fn:match('%.(%w+)$') or error('no match: container')
local u = 'http://video.spiegel.de/flash/' .. fn
-- print(u,c,b,w,h,cn,d)
table.insert(t, {codec=string.lower(c), url=u,
width=tonumber(w), height=tonumber(h),
bitrate=tonumber(b), duration=tonumber(d),
container=cn})
end
return t
end
function Spiegel.choose_best(formats) -- Highest quality available
local r = {width=0, height=0, bitrate=0, url=nil}
local U = require 'quvi/util'
for _,v in pairs(formats) do
if U.is_higher_quality(v,r) then
r = v
end
end
return r
end
function Spiegel.choose_default(formats)
return formats[1]
end
function Spiegel.to_s(t)
return string.format('%s_%s_%sk_%sp',
t.container, t.codec, t.bitrate, t.height)
end
-- vim: set ts=4 sw=4 tw=72 expandtab:
|