From: Michael Orlitzky Date: Sun, 24 Jul 2011 06:03:47 +0000 (-0400) Subject: Add HTML5 source element src parsing to the Redtube class. X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=9a0f311962f0348bb676e513e18b378e4ad11086;p=dead%2Fwhatever-dl.git Add HTML5 source element src parsing to the Redtube class. Prefer the HTML5 videos over Flash ones where applicable. --- diff --git a/src/websites/redtube.rb b/src/websites/redtube.rb index 825a4ea..4de8772 100644 --- a/src/websites/redtube.rb +++ b/src/websites/redtube.rb @@ -22,7 +22,7 @@ require 'cgi' class Redtube < Website VALID_REDTUBE_URL_REGEX = /^(http:\/\/)?(www\.)?redtube\.com\/(\d+)$/ - + def self.owns_url?(url) return url =~ VALID_REDTUBE_URL_REGEX end @@ -30,7 +30,13 @@ class Redtube < Website def get_video_url() page_data = self.get_page_data(@url) - return self.parse_hashlink(page_data) + begin + # We prefer to parse the HTML5 version because it can come in a + # nicer container format. + return parse_html5_src(page_data) + rescue StandardError => e + return self.parse_hashlink(page_data) + end end @@ -41,17 +47,31 @@ class Redtube < Website end + def parse_html5_src(page_data) + html5_src_regex = /\"