X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=lib%2Fwhatever-dl%2Fwebsites%2Finfoq.rb;fp=lib%2Fwhatever-dl%2Fwebsites%2Finfoq.rb;h=1829c8c2c5fd846682adb63b9e3b9b9e6b132585;hb=6de408333ceb0d142f8fa0fef2571228e89c8fc1;hp=0000000000000000000000000000000000000000;hpb=8e886df259246365023322b78f58e4037cb536a4;p=dead%2Fwhatever-dl.git diff --git a/lib/whatever-dl/websites/infoq.rb b/lib/whatever-dl/websites/infoq.rb new file mode 100644 index 0000000..1829c8c --- /dev/null +++ b/lib/whatever-dl/websites/infoq.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' +require 'base64' + +class Infoq < Website + + VALID_INFOQ_URL_REGEX = /^(http:\/\/)?(www\.)?infoq\.com\/(.+)$/ + + def self.owns_url?(url) + return url =~ VALID_INFOQ_URL_REGEX + end + + + def get_video_url() + page_data = self.get_page_data(@url) + video_url = self.parse_video_url(page_data) + return video_url + end + + + protected; + + # Get the FLV file URL from the HTML page for this movie. + # It's encoded in base64 -- no big deal. + def parse_video_url(page_data) + # Get the base64 string. It's stored in a javascript + # variable called "jsclassref". This regex should match + # a javascript variable declaration preceded, separated, + # and/or terminated by zero or more whitespace characters. + base64_regex = /^\s*var\s+jsclassref=\'(.*)\';\s*$/ + matches = base64_regex.match(page_data) + + if (matches.nil? || matches.length < 2) + raise StandardError.new('There were no base64-encoded video URLs found on the page: '); + end + + return Base64.decode64(matches[1]) + end + + +end