3 -- Copyright (C) 2013 Toni Gundogdu <legatvs@gmail.com>
4 -- Copyright (C) 2012 Guido Leisker <guido@guido-leisker.de>
6 -- This file is part of libquvi-scripts <http://quvi.sourceforge.net/>.
8 -- This library is free software; you can redistribute it and/or
9 -- modify it under the terms of the GNU Lesser General Public
10 -- License as published by the Free Software Foundation; either
11 -- version 2.1 of the License, or (at your option) any later version.
13 -- This library is distributed in the hope that it will be useful,
14 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
15 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 -- Lesser General Public License for more details.
18 -- You should have received a copy of the GNU Lesser General Public
19 -- License along with this library; if not, write to the Free Software
20 -- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
24 -- Each video url ends with an id composed of digits.
25 -- This id leads us to a metadata xml file (see function
26 -- MySpass.getMetadataValue) containing all necessary information
27 -- including download link.
29 local MySpass
= {} -- Utility functions unique to this script
31 -- Identify the script.
33 package
.path
= self
.script_dir
.. '/?.lua'
34 local C
= require
'quvi/const'
36 r
.domain
= "myspass%.de"
38 r
.categories
= C
.proto_http
39 local U
= require
'quvi/util'
40 -- expect all urls ending with digits to be videos
41 r
.handles
= U
.handles(self
.page_url
, {r
.domain
},{"/myspass/.-/%d+/?$"})
45 -- Query available formats.
46 function query_formats(self
)
47 self
.formats
= 'default'
53 self
.host_id
= "myspass"
55 self
.id
= self
.page_url
:match("(%d+)/?$") or error("no match: media ID")
58 'http://www.myspass.de/myspass/',
59 'includes/apps/video/getvideometadataxml.php?id=',
62 local m
= quvi
.fetch(table.concat(u
,''))
64 local format = MySpass
.getMetadataValue(m
, 'format')
65 MySpass
.chk_expired(format)
67 local season
= MySpass
.getMetadataValue(m
, 'season')
68 local episode
= MySpass
.getMetadataValue(m
, 'episode')
69 local title
= MySpass
.getMetadataValue(m
, 'title')
71 self
.title
= string.format("%s %03d %03d %s",
77 self
.thumbnail_url
= MySpass
.getMetadataValue(m
, 'imagePreview') or ''
78 self
.url
= {MySpass
.getMetadataValue(m
, 'url_flv')}
87 function MySpass
.getMetadataValue(m
, k
)
88 local p
= string.format("<%s>(.-)</%s>", k
, k
)
89 local s
= m
:match(p
) or error(string.format('no match: %s', k
))
90 return s
:match('<!%[CDATA%[(.+)]]>') or ''
93 function MySpass
.chk_expired(s
)
95 error('no match: metadata: "format": video no longer available?')
99 -- vim: set ts=4 sw=4 tw=72 expandtab: