X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=src%2Fwebsites%2Fhowcast.rb;h=90cbd615ca069c8c0f4a653796e2ae14b80c2374;hb=9d28bfae2b055aacd673dabd75aaf1d68042b917;hp=5cf490e2d1dbaf77f1d428e627251392b02152b8;hpb=83e06f83d8274cb32a406739839d56e759664b09;p=dead%2Fwhatever-dl.git diff --git a/src/websites/howcast.rb b/src/websites/howcast.rb index 5cf490e..90cbd61 100644 --- a/src/websites/howcast.rb +++ b/src/websites/howcast.rb @@ -26,6 +26,17 @@ class Howcast < Website return url =~ VALID_HOWCAST_URL_REGEX end + + def get_video_url() + video_id = parse_video_id() + xml_url = "http://www.howcast.com/videos/#{video_id}.xml" + xml_data = self.get_page_data(xml_url) + filepath = parse_file_path_from_xml(xml_data) + + return "http://www.howcast.com#{filepath}" + end + + protected; def parse_video_id() # This regex just pulls out the video id @@ -39,11 +50,16 @@ class Howcast < Website return matches[1] end - - def get_video_url() - video_id = parse_video_id() - - return "http://media.howcast.com/system/videos/#{video_id}/#{video_id}.flv" + + def parse_file_path_from_xml(data) + file_path_regex = /(.*?)<\/filename>/ + matches = file_path_regex.match(data) + + if matches.nil? + raise StandardError.new("Couldn't parse the tag from the XML file.") + end + + return matches[1] end - + end