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

« back to all changes in this revision

Viewing changes to share/lua/website/google.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:
21
21
--
22
22
 
23
23
-- Identify the script.
24
 
function ident (page_url)
25
 
    local t   = {}
26
 
    t.domain  = "video.google."
27
 
    t.formats = "default"
28
 
    t.handles = (page_url ~= nil and page_url:find(t.domain) ~= nil)
29
 
    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     = "video.google."
 
29
    r.formats    = "default"
 
30
    r.categories = C.proto_http
 
31
    local U      = require 'quvi/util'
 
32
    r.handles    = U.handles(self.page_url,
 
33
                    {r.domain}, {"videoplay"}, {"docid=[%w-]+"})
 
34
    return r
30
35
end
31
36
 
32
37
-- Parse video URL.
33
 
function parse (video)
34
 
    video.host_id = "google"
35
 
    local page    = quvi.fetch(video.page_url)
 
38
function parse (self)
 
39
    self.host_id = "google"
 
40
    local page   = quvi.fetch(self.page_url)
36
41
 
37
42
    local _,_,s = page:find("<title>(.-)</title>")
38
 
    video.title = s or error ("no match: video title")
 
43
    self.title  = s or error ("no match: video title")
39
44
 
40
45
    local _,_,s = page:find("docid:'(.-)'")
41
 
    video.id    = s or error ("no match: video id")
 
46
    self.id     = s or error ("no match: video id")
42
47
 
43
48
    local _,_,s = page:find("videoUrl%Wx3d(.-)%Wx26")
44
49
    s           = s or error ("no match: url")
45
 
    video.url   = {quvi.unescape(s)}
 
50
    local U     = require 'quvi/util'
 
51
    self.url    = {U.unescape(s)}
46
52
 
47
 
    return video
 
53
    return self
48
54
end
49
55
 
50
 
 
 
56
-- vim: set ts=4 sw=4 tw=72 expandtab: