~ubuntu-branches/ubuntu/saucy/libquvi/saucy-proposed

« back to all changes in this revision

Viewing changes to share/lua/website/sapo.lua

  • Committer: Bazaar Package Importer
  • Author(s): Alejandro Garrido Mota
  • Date: 2011-04-25 01:07:41 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20110425010741-nalzd12y180qs082
Tags: 0.2.15-1
* New upstream release (Closes: #622253). 
* Update d/watch to sf.net
* Update homepage field to quvi.sourceforge.net (Closes: #615554) 
* d/rules: Add dh_auto_test before NO_INTERNET=1 in override_dh_auto_test 
* Update Standards-Version field to 3.9.2 
* Add symbol (d/libquvi0.symbols) file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
-- 02110-1301  USA
21
21
--
22
22
 
23
 
--
24
 
--
25
 
 
26
23
-- Identify the script.
27
 
function ident (page_url)
28
 
    local t   = {}
29
 
    t.domain  = "videos.sapo.pt"
30
 
    t.formats = "default"
31
 
    t.handles = (page_url ~= nil and page_url:find (t.domain) ~= nil)
32
 
    return t
 
24
function ident (self)
 
25
    package.path = self.script_dir .. '/?.lua'
 
26
    local C      = require 'quvi/const'
 
27
    local r      = {}
 
28
    r.domain     = "videos.sapo.pt"
 
29
    r.formats    = "default"
 
30
    r.categories = C.proto_http
 
31
    -- TODO: Replace with LUA equivalent to Perl's "\w{20}".
 
32
    local p      = "/"
 
33
    for i=1,20 do p = p.."%w" end
 
34
    p = p .. "$"
 
35
    local U      = require 'quvi/util'
 
36
    r.handles    = U.handles(self.page_url, {r.domain}, {p})
 
37
    return r
 
38
 
33
39
end
34
40
 
35
41
-- Parse video URL.
36
 
function parse (video)
 
42
function parse (self)
37
43
 
38
 
    video.host_id = "sapo"
39
 
    local page    = quvi.fetch (video.page_url)
 
44
    self.host_id = "sapo"
 
45
    local page   = quvi.fetch (self.page_url)
40
46
 
41
47
    if (page:find ('rtmp:%/%/')) then
42
48
        error ("video requires rtmp which we do not currently support")
47
52
    if (s == nil) then
48
53
        _,_,s = page:find ('<title>(.-)%s+-%s+')
49
54
    end
50
 
    video.title = s or error ("no match: video title")
 
55
    self.title = s or error ("no match: video title")
51
56
 
52
57
    local _,_,s = page:find ('?file=(.-)/mov')
53
58
    if (s == nil) then error ("no match: video url") end
54
 
    video.url   = {s .. "/mov"}
55
 
 
56
 
    local _,_,s = video.url[1]:find ('.*/(.-)/mov')
57
 
    video.id    = s or error ("no match: video id")
58
 
 
59
 
    return video
 
59
    self.url = {s .. "/mov"}
 
60
 
 
61
    local _,_,s = self.url[1]:find ('.*/(.-)/mov')
 
62
    self.id     = s or error ("no match: video id")
 
63
 
 
64
    return self
60
65
end
61
66
 
62
 
 
 
67
-- vim: set ts=4 sw=4 tw=72 expandtab: