FIX: videobash.lua: media URL parsing
[libquvi-scripts.git] / share / lua / website / videobash.lua
blob4bd84c4416c5406df2364cfe064e2558dfc1f2cd
2 -- libquvi-scripts
3 -- Copyright (C) 2012 Toni Gundogdu <legatvs@gmail.com>
4 -- Copyright (C) 2011 Thomas Preud'homme <robotux@celest.fr>
5 --
6 -- This file is part of libquvi-scripts <http://quvi.sourceforge.net/>.
7 --
8 -- This library is free software; you can redistribute it and/or
9 -- modify it under the terms of the GNU Lesser General Public
10 -- License as published by the Free Software Foundation; either
11 -- version 2.1 of the License, or (at your option) any later version.
13 -- This library is distributed in the hope that it will be useful,
14 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
15 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 -- Lesser General Public License for more details.
18 -- You should have received a copy of the GNU Lesser General Public
19 -- License along with this library; if not, write to the Free Software
20 -- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 -- 02110-1301 USA
24 -- Identify the script.
25 function ident(self)
26 package.path = self.script_dir .. '/?.lua'
27 local C = require 'quvi/const'
28 local r = {}
29 r.domain = "videobash%.com"
30 r.formats = "default"
31 r.categories = C.proto_http
32 local U = require 'quvi/util'
33 r.handles = U.handles(self.page_url, {r.domain}, {"/video_show/"})
34 return r
35 end
37 -- Query available formats.
38 function query_formats(self)
39 self.formats = 'default'
40 return self
41 end
43 -- Parse media URL.
44 function parse(self)
45 self.host_id = "videobash"
47 local p = quvi.fetch(self.page_url)
49 self.title = p:match("<title>(.-)%s+-")
50 or error ("no match: media title")
52 self.id = p:match("addFavorite%((%d+)")
53 or error ("no match: media ID")
55 local s = p:match('file="(.-);') or error("no match: media URL")
56 s = s:gsub("[%s+']+", '')
58 self.thumbnail_url = p:match('og:image"%s+content="(.-)"') or ''
60 local U = require 'quvi/util'
61 self.url = {U.unescape(s)}
63 return self
64 end
66 -- vim: set ts=4 sw=4 tw=72 expandtab: