media/bikeradar.lua: Remove query_formats function
[libquvi-scripts.git] / share / media / bikeradar.lua
blobb5baa6f4ce7fc79ab2222ed7a9e7880b46557637
1 -- libquvi-scripts
2 -- Copyright (C) 2013 Toni Gundogdu <legatvs@gmail.com>
3 -- Copyright (C) 2011-2012 quvi project
4 --
5 -- This file is part of libquvi-scripts <http://quvi.sourceforge.net/>.
6 --
7 -- This program is free software: you can redistribute it and/or
8 -- modify it under the terms of the GNU Affero General Public
9 -- License as published by the Free Software Foundation, either
10 -- version 3 of the License, or (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 Affero General Public License for more details.
17 -- You should have received a copy of the GNU Affero General
18 -- Public License along with this program. If not, see
19 -- <http://www.gnu.org/licenses/>.
22 local BikeRadar = {} -- Utility functions unique to to this script.
24 -- Identify the media script.
25 function ident(qargs)
26 return {
27 can_parse_url = BikeRadar.can_parse_url(qargs),
28 domains = table.concat({'bikeradar.com'}, ',')
30 end
32 -- Parse media URL.
33 function parse(self)
34 self.host_id = "bikeradar"
36 local p = quvi.fetch(self.page_url)
38 self.redirect_url = p:match('"embedURL" href="(.-)"')
39 or error('no match: embedURL')
41 return self
42 end
45 -- Utility functions
48 function BikeRadar.can_parse_url(qargs)
49 local U = require 'socket.url'
50 local t = U.parse(qargs.input_url)
51 if t and t.scheme and t.scheme:lower():match('^http$')
52 and t.host and t.host:lower():match('bikeradar%.com$')
53 and t.path and t.path:lower():match('^/videos/.-%-%w+$')
54 then
55 return true
56 else
57 return false
58 end
59 end
61 -- vim: set ts=4 sw=4 tw=72 expandtab: