23
23
-- Identify the script.
24
function ident (page_url)
26
t.domain = "video.google."
28
t.handles = (page_url ~= nil and page_url:find(t.domain) ~= nil)
25
package.path = self.script_dir .. '/?.lua'
26
local C = require 'quvi/const'
28
r.domain = "video.google."
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-]+"})
32
37
-- Parse video URL.
33
function parse (video)
34
video.host_id = "google"
35
local page = quvi.fetch(video.page_url)
39
self.host_id = "google"
40
local page = quvi.fetch(self.page_url)
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")
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")
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)}
56
-- vim: set ts=4 sw=4 tw=72 expandtab: