Update NEWS for v0.9.20131130
[libquvi-scripts.git] / share / lua / website / xhamster.lua
Commit [+]AuthorDateLineData
62cc25f1
TG
Toni Gundogdu2011-09-19 19:39:08 +03001
2-- libquvi-scripts
8a8353a5
TG
Toni Gundogdu2012-03-17 23:16:39 +02003-- Copyright (C) 2012 Toni Gundogdu <legatvs@gmail.com>
4-- Copyright (C) 2010 Paul Kocialkowski <contact@paulk.fr>
62cc25f1
TG
Toni Gundogdu2011-09-19 19:39:08 +03005--
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.
12--
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.
17--
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
22--
23
24-- Identify the script.
8a8353a5 Toni Gundogdu2012-03-17 23:16:39 +020025function ident(self)
62cc25f1
TG
Toni Gundogdu2011-09-19 19:39:08 +030026 package.path = self.script_dir .. '/?.lua'
27 local C = require 'quvi/const'
28 local r = {}
29 r.domain = "xhamster%.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}, {"/movies/%d+/"})
34 return r
35end
36
37-- Query available formats.
38function query_formats(self)
39 self.formats = 'default'
40 return self
41end
42
43-- Parse media URL.
8a8353a5 Toni Gundogdu2012-03-17 23:16:39 +020044function parse(self)
62cc25f1 Toni Gundogdu2011-09-19 19:39:08 +030045 self.host_id = "xhamster"
62cc25f1 Toni Gundogdu2011-09-19 19:39:08 +030046
8a8353a5
TG
Toni Gundogdu2012-03-17 23:16:39 +020047 local p = quvi.fetch(self.page_url)
48
49 self.title = p:match('class="mTitle">.-<h1?.>(.-)</h1>')
b2e0ed4f Toni Gundogdu2011-10-25 17:11:58 +030050 or error("no match: media title")
62cc25f1 Toni Gundogdu2011-09-19 19:39:08 +030051
8a8353a5
TG
Toni Gundogdu2012-03-17 23:16:39 +020052 self.id = self.page_url:match("/movies/(.-)/")
53 or error("no match: media ID")
62cc25f1 Toni Gundogdu2011-09-19 19:39:08 +030054
6f3e8bd8
TG
Toni Gundogdu2012-06-04 17:17:09 +030055 local U = require 'quvi/util'
56 local f = p:match("'file': '(.-)'") or error("no match: file")
62cc25f1 Toni Gundogdu2011-09-19 19:39:08 +030057
6f3e8bd8 Toni Gundogdu2012-06-04 17:17:09 +030058 f = U.unescape(f)
62cc25f1 Toni Gundogdu2011-09-19 19:39:08 +030059
6f3e8bd8
TG
Toni Gundogdu2012-06-04 17:17:09 +030060 local u = ''
61 if not f:match('^http') then
62 u = p:match("'srv': '(.-)'") or error("no match: server")
63 u = u .."/key="
64 end
65
66 self.url = {u..f}
62cc25f1
TG
Toni Gundogdu2011-09-19 19:39:08 +030067
68 return self
69end
70
71-- vim: set ts=4 sw=4 tw=72 expandtab: