Move share/lua/ contents to share/
[libquvi-scripts.git] / share / media / gaskrank.lua
blob729efe94fbc48def66d4532fb29e63fec58bf1ea
1 -- libquvi-scripts
2 -- Copyright (C) 2010-2012 Toni Gundogdu <legatvs@gmail.com>
3 --
4 -- This file is part of libquvi-scripts <http://quvi.sourceforge.net/>.
5 --
6 -- This library is free software; you can redistribute it and/or
7 -- modify it under the terms of the GNU Lesser General Public
8 -- License as published by the Free Software Foundation; either
9 -- version 2.1 of the License, or (at your option) any later version.
11 -- This library is distributed in the hope that it will be useful,
12 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
13 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 -- Lesser General Public License for more details.
16 -- You should have received a copy of the GNU Lesser General Public
17 -- License along with this library; if not, write to the Free Software
18 -- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 -- 02110-1301 USA
22 local Gaskrank = {} -- Utility functions unique to this script
24 -- Identify the media script.
25 function ident(qargs)
26 local A = require 'quvi/accepts'
27 local C = require 'quvi/const'
28 local r = {
29 accepts = A.accepts(qargs.input_url, {"gaskrank%.tv"}, {"/tv/"}),
30 categories = C.qmspc_http
32 return r
33 end
35 -- Parse media properties.
36 function parse(qargs)
37 local p = quvi.fetch(qargs.input_url)
39 qargs.thumb_url = p:match('"og:image" content="(.-)"') or ''
41 qargs.title = p:match('"og:title" content="(.-)"') or ''
43 qargs.id = qargs.input_url:match("%-(%d+)%.h")
44 or error("no match: media ID")
46 qargs.streams = Gaskrank.iter_streams(p)
48 return qargs
49 end
52 -- Utility functions.
55 function Gaskrank.iter_streams(p)
56 local u = p:match("(http://movies.-%.flv)")
57 or error("no match: media stream URL")
58 local S = require 'quvi/stream'
59 return {S.stream_new(u)}
60 end
62 -- vim: set ts=2 sw=2 tw=72 expandtab: