3
* Copyright (C) 2010 Toni Gundogdu.
5
* This file is part of quvi, see http://quvi.googlecode.com/
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.
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.
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/>.
22
-- If you make improvements to this script, drop a line. Thanks.
23
-- <http://quvi.googlecode.com/>
25
-- Returns script details.
26
function ident (page_url)
28
-- This is what I return.
34
-- This is my formats-string.
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)
41
-- Here are my details.
46
-- Fetches video page and parses the video URL.
47
function parse (video)
49
-- This is my "host ID".
50
video.host_id = "cctv"
53
local page = quvi.fetch(video.page_url)
55
-- This is my video title.
56
local _,_,s = page:find('<meta name="description"%s+content="(.-)"')
57
video.title = s or error ("no match: video title")
59
-- This is my video ID.
60
local _,_,s = page:find("videoId=(.-)&")
61
video.id = s or error ("no match: video id")
63
-- This is the domain string used to fetch the config.
64
local _,_,s = video.page_url:find("http://(.-)/")
65
local domain = s or error ("no match: domain")
67
-- This is the config URL.
69
string.format("http://%s/playcfg/flv_info_new.jsp?videoId=%s",
73
local config = quvi.fetch(config_url, "config")
75
-- These are my other details used to construct the video URL.
76
local _,_,s = config:find('"chapters":%[(.-)%]')
77
local chapters = s or error ("no match: chapters")
78
video.url = {} -- Array. Make a mental note of this.
80
-- Some of the cctv videos have "segments", include all of them.
81
for path in chapters:gfind('{"url":"(.-)",') do
82
table.insert(video.url,
83
string.format("http://v.cctv.com/flash/%s", path))
86
-- We should have at least one in the array.
87
if (table.getn(video.url) == 0) then
88
error ("no match: chapter url path")
91
-- Return the updated video properties.