X-Git-Url: https://gitweb.michael.orlitzky.com/?a=blobdiff_plain;ds=inline;f=src%2Fwebsites%2Fmotherless.rb;fp=src%2Fwebsites%2Fmotherless.rb;h=a5b59b2d709b2aa48d88a4573167caf73ec505df;hb=1bbc47ddc336e2cba7e8449613dee97f3c58d6ef;hp=0000000000000000000000000000000000000000;hpb=9a5310260a276a57c084d07de2bb97d78ce2a8ff;p=dead%2Fwhatever-dl.git diff --git a/src/websites/motherless.rb b/src/websites/motherless.rb new file mode 100644 index 0000000..a5b59b2 --- /dev/null +++ b/src/websites/motherless.rb @@ -0,0 +1,54 @@ +# +# 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 Motherless < Website + + VALID_MOTHERLESS_URL_REGEX = /^(http:\/\/)?(www\.)?motherless\.com\/[[:alnum:]]+$/ + + def self.owns_url?(url) + return url =~ VALID_MOTHERLESS_URL_REGEX + end + + + def get_video_url() + page_data = self.get_page_data(@url) + filepath = parse_video_url(page_data) + + return filepath + end + + + protected; + + + def parse_video_url(page_data) + # If neither of the source formats are present, just grab the + # video URL from the Flash variable and be done with it. + video_url_regex = /file=(.*?\.flv)&/i + matches = video_url_regex.match(page_data) + + if matches.nil? + raise StandardError.new("Couldn't parse the video URL from flashvars.") + end + + return matches[1] + end + +end