~ubuntu-branches/ubuntu/trusty/libquvi/trusty-proposed

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Alejandro Garrido Mota
  • Date: 2010-05-16 12:12:51 UTC
  • Revision ID: james.westby@ubuntu.com-20100516121251-oku70h33ycn8m6xe
Tags: upstream-0.2.0
ImportĀ upstreamĀ versionĀ 0.2.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
--[[
 
2
/* 
 
3
* Copyright (C) 2010 Toni Gundogdu.
 
4
*
 
5
* This file is part of quvi, see http://quvi.googlecode.com/
 
6
*
 
7
* This program is free software: you can redistribute it and/or modify
 
8
* it under the terms of the GNU General Public License as published by
 
9
* the Free Software Foundation, either version 3 of the License, or
 
10
* (at your option) any later version.
 
11
*
 
12
* This program is distributed in the hope that it will be useful,
 
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
* GNU General Public License for more details.
 
16
*
 
17
* You should have received a copy of the GNU General Public License
 
18
* along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
19
*/
 
20
]]--
 
21
 
 
22
-- If you make improvements to this script, drop a line. Thanks.
 
23
--   <http://quvi.googlecode.com/>
 
24
 
 
25
-- Returns script details.
 
26
function ident (page_url)
 
27
    
 
28
    -- This is what I return.
 
29
    local t = {}
 
30
 
 
31
    -- This is my domain.
 
32
    t.domain = "myubo.com"
 
33
 
 
34
    -- This is my formats-string.
 
35
    t.formats = "default"
 
36
 
 
37
    -- This is my response to "Will you handle this URL?"
 
38
    -- Note that page_url may be nil.
 
39
    t.will_handle = (page_url ~= nil and page_url:find(t.domain) ~= nil)
 
40
 
 
41
    -- Here are my details.
 
42
    return t
 
43
 
 
44
end
 
45
 
 
46
-- Fetches video page and parses the video URL.
 
47
function parse (video)
 
48
 
 
49
    -- This is my "host ID".
 
50
    video.host_id = "myubo"
 
51
 
 
52
    -- Fetch video page.
 
53
    local page = quvi.fetch(video.page_url)
 
54
 
 
55
    -- This is my video title.
 
56
    local _,_,s = page:find('<div id="movieDetail"><h1>(.-)</')
 
57
    video.title = s or error ("no match: video title")
 
58
 
 
59
    -- This is my video ID.
 
60
    local _,_,s = page:find('movieid=(.-)"')
 
61
    video.id    = s or error ("no match: video id")
 
62
 
 
63
    -- This is my video URL.
 
64
    local _,_,s = page:find("writeFlashPlayer%('(.-)'")
 
65
    video.url   = {s or error ("no match: writeFlashPlayer")}
 
66
 
 
67
    -- Return the updated video properties.
 
68
    return video
 
69
 
 
70
end
 
71
 
 
72