From 39245715416edba68b1fa2d183451d37ff274e95 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Tue, 19 Nov 2013 10:41:46 -0500 Subject: [PATCH] New website: http://www.pornhd.com/. --- lib/whatever-dl/websites/pornhd.rb | 55 ++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 lib/whatever-dl/websites/pornhd.rb diff --git a/lib/whatever-dl/websites/pornhd.rb b/lib/whatever-dl/websites/pornhd.rb new file mode 100644 index 0000000..b6f985a --- /dev/null +++ b/lib/whatever-dl/websites/pornhd.rb @@ -0,0 +1,55 @@ +# +# Copyright Michael Orlitzky +# +# http://michael.orlitzky.com/ +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# http://www.fsf.org/licensing/licenses/gpl.html +# + +require 'whatever-dl/website' +require 'cgi' + +class Pornhd < Website + + VALID_PORNHD_URL_REGEX = /^(http:\/\/)?(www\.)?pornhd\.com\/videos\/\d+\/(.+)$/ + + def self.owns_url?(url) + return url =~ VALID_PORNHD_URL_REGEX + end + + + def get_video_url() + page_data = self.get_page_data(@url) + video_url = self.parse_video_url(page_data) + return CGI::unescape(video_url) + end + + + protected; + + # Get the FLV file URL from the HTML page for this movie. + # It's stored in some Flash variable. + def parse_video_url(page_data) + video_url_regex = /&hd=(http.+?)&/ + matches = video_url_regex.match(page_data) + + puts matches + if (matches.nil? || matches.length < 2) + raise StandardError.new('Could not find the "flashvars" object param on the page.'); + end + + return matches[1] + end + + +end -- 2.44.2