2 -- Copyright (C) 2012 Guido Leisker <guido@guido-leisker.de>
4 -- This file is part of libquvi-scripts <http://quvi.sourceforge.net/>.
6 -- This program is free software: you can redistribute it and/or
7 -- modify it under the terms of the GNU Affero General Public
8 -- License as published by the Free Software Foundation, either
9 -- version 3 of the License, or (at your option) any later version.
11 -- This program is distributed in the hope that it will be useful,
12 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
13 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 -- GNU Affero General Public License for more details.
16 -- You should have received a copy of the GNU Affero General
17 -- Public License along with this program. If not, see
18 -- <http://www.gnu.org/licenses/>.
22 -- Each video url ends with an id composed of digits.
23 -- This id leads us to a metadata xml file (see function
24 -- MySpass.getMetadataValue) containing all necessary information
25 -- including download link.
27 local MySpass
= {} -- Utility functions unique to this script
29 -- Identify the script.
31 package
.path
= self
.script_dir
.. '/?.lua'
32 local C
= require
'quvi/const'
34 r
.domain
= "myspass%.de"
36 r
.categories
= C
.proto_http
37 local U
= require
'quvi/util'
38 -- expect all urls ending with digits to be videos
39 r
.handles
= U
.handles(self
.page_url
, {r
.domain
}, {"/myspass/.-/%d+/?$"})
43 -- Query available formats.
44 function query_formats(self
)
45 self
.formats
= 'default'
51 self
.host_id
= "myspass"
53 self
.id
= self
.page_url
:match("(%d+)/?$")
54 or error("no match: media ID")
56 local format = MySpass
.getMetadataValue(self
, 'format')
57 local title
= MySpass
.getMetadataValue(self
, 'title')
58 local season
= MySpass
.getMetadataValue(self
, 'season')
59 local episode
= MySpass
.getMetadataValue(self
, 'episode')
60 self
.thumbnail_url
= MySpass
.getMetadataValue(self
, 'imagePreview') or ''
62 self
.title
= string.format("%s %03d %03d %s", format, season
,
65 self
.url
= {MySpass
.getMetadataValue(self
, 'url_flv')}
74 function MySpass
.getMetadataValue(self
, key
)
75 if self
.metadata
== nil then
76 self
.metadata
= quvi
.fetch(
77 'http://www.myspass.de/myspass/'
78 .. 'includes/apps/video/getvideometadataxml.php?id='
79 .. self
.id
) or error("cannot fetch meta data xml file")
81 local p
= string.format("<%s>(.-)</%s>", key
, key
)
82 local temp
= self
.metadata
:match(p
) or error("meta data: no match: " .. key
)
83 local value
= temp
:match('<!%[CDATA%[(.+)]]>') or temp
87 -- vim: set ts=2 sw=2 tw=72 expandtab: