From 968143bf35adbe3dd9a4ebceb6945b43cdec07d4 Mon Sep 17 00:00:00 2001 From: PaulK Date: Wed, 8 Feb 2012 20:03:10 +0100 Subject: [PATCH] Added support for pornhub.com (NSFW) --- share/Makefile.am | 1 + share/lua/website/pornhub.lua | 61 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 share/lua/website/pornhub.lua diff --git a/share/Makefile.am b/share/Makefile.am index f8353a5..61059ba 100644 --- a/share/Makefile.am +++ b/share/Makefile.am @@ -55,6 +55,7 @@ DIST_lua=\ if WITH_NSFW DIST_lua+=\ lua/website/keezmovies.lua \ + lua/website/pornhub.lua \ lua/website/spankwire.lua \ lua/website/tcmag.lua \ lua/website/tnaflix.lua \ diff --git a/share/lua/website/pornhub.lua b/share/lua/website/pornhub.lua new file mode 100644 index 0000000..d3ef2ea --- /dev/null +++ b/share/lua/website/pornhub.lua @@ -0,0 +1,61 @@ + +-- libquvi-scripts +-- Copyright (C) 2012 Paul Kocialkowski +-- +-- This file is part of libquvi-scripts . +-- +-- This library is free software; you can redistribute it and/or +-- modify it under the terms of the GNU Lesser General Public +-- License as published by the Free Software Foundation; either +-- version 2.1 of the License, or (at your option) any later version. +-- +-- This library is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +-- Lesser General Public License for more details. +-- +-- You should have received a copy of the GNU Lesser General Public +-- License along with this library; if not, write to the Free Software +-- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +-- 02110-1301 USA +-- + +-- Identify the script. +function ident(self) + package.path = self.script_dir .. '/?.lua' + local C = require 'quvi/const' + local r = {} + r.domain = "pornhub%.com" + r.formats = "default" + r.categories = C.proto_http + local U = require 'quvi/util' + r.handles = U.handles(self.page_url, {r.domain}, {"view_video.php"}) + return r +end + +-- Query available formats. +function query_formats(self) + self.formats = 'default' + return self +end + +-- Parse media URL. +function parse(self) + self.host_id = "pornhub" + local page = quvi.fetch(self.page_url) + local U = require 'quvi/util' + + self.title = page:match('(.-) - Pornhub.com') + or error("no match: media title") + + local _,_,s = page:find('\'video_url\'.-:.-"(.-)"') + s = s or error ("no match: config url") + self.url = { U.unescape(s) } + + local _,_,s = self.page_url:find('viewkey=(%d+)') + self.id = s or error ("no match: media id") + + return self +end + +-- vim: set ts=4 sw=4 tw=72 expandtab: -- 2.11.4.GIT