From: Michael Orlitzky Date: Wed, 5 Jan 2011 02:20:55 +0000 (-0500) Subject: Add support for ehow.com. X-Git-Url: http://gitweb.michael.orlitzky.com/?p=dead%2Fwhatever-dl.git;a=commitdiff_plain;h=45c0e4f371e124d186bbd36e065ef6bb671fa846 Add support for ehow.com. --- diff --git a/src/websites/ehow.rb b/src/websites/ehow.rb new file mode 100644 index 0000000..e01f900 --- /dev/null +++ b/src/websites/ehow.rb @@ -0,0 +1,58 @@ +# +# 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' + +class Ehow < Website + + VALID_EHOW_URL_REGEX = /^(http:\/\/)?(www.)?ehow\.com\/[a-z0-9\-_\.]+$/i + + def self.owns_url?(url) + return url =~ VALID_EHOW_URL_REGEX + end + + + def get_video_url() + page_data = get_page_data(@url) + filepath = parse_video_url(page_data) + puts "FILEPATH: #{filepath}" + return filepath + end + + + protected; + + def parse_video_url(page_data) + # There's more than one JSON 'id' parameter floating around; we + # only want the one that points to the video URL. + # + # In fact, there's more than one 'id' parameter pointing to a + # video URL, but it looks like the highest-quality clips are + # listed first so the first match should give us that. + # + video_url_regex = /id:[[:space:]]?'(http:\/\/[^']+)'/i + matches = video_url_regex.match(page_data) + + if matches.nil? or (matches.length < 2) + raise StandardError.new("Couldn't parse the 'id' JSON parameter.") + else + return matches[1] + end + end + +end