X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=src%2Fwebsites%2Fmentalzero.rb;fp=src%2Fwebsites%2Fmentalzero.rb;h=0000000000000000000000000000000000000000;hb=6de408333ceb0d142f8fa0fef2571228e89c8fc1;hp=60b83ac521331894f493d5b160d26ca2e7377551;hpb=8e886df259246365023322b78f58e4037cb536a4;p=dead%2Fwhatever-dl.git diff --git a/src/websites/mentalzero.rb b/src/websites/mentalzero.rb deleted file mode 100644 index 60b83ac..0000000 --- a/src/websites/mentalzero.rb +++ /dev/null @@ -1,74 +0,0 @@ -# -# 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 'src/website' -require 'cgi' - -class Mentalzero < Website - - VALID_MENTALZERO_URL_REGEX = /^(http:\/\/)?(www.)?mentalzero\.com\/[a-z0-9\-_\.]+\.html$/i - - def self.owns_url?(url) - return url =~ VALID_MENTALZERO_URL_REGEX - end - - - def get_video_url() - page_data = get_page_data(@url) - filepath = parse_video_url(page_data) - - return CGI::unescape(filepath) - end - - - def get_video_filename() - # Override the default since a nice human-readable name is right - # at the end of @url. - file_and_params = @url.split('/').pop() - - filename = file_and_params - # Unless it contains URL parameters. We don't want those. - if file_and_params.include?('?') - # There must be some parameters. Strip them off. - param_start_idx = file_and_params.index('?') - filename = file_and_params[0...(param_start_idx)] - end - - # Use the Website method to get the real extension of the file - # (the file /name/ we get back will be useless, but we can ignore - # it). - extension = super().split('.').pop() - filename.sub!('.html', '.' + extension) - - return filename - end - - protected; - - def parse_video_url(page_data) - video_url_regex = /&file=(.+?)&site/i - matches = video_url_regex.match(page_data) - - if matches.nil? or (matches.length < 2) - raise StandardError.new("Couldn't parse the 'file' object parameter.") - else - return matches[1] - end - end - -end