X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=src%2Fwebsites%2Fyikers.rb;h=8cf407aa4d4ec18083cb2f7f99dfd4ada7227e20;hb=5185d100c0406dab1f9013e5b0e86289558225e9;hp=4b13a023371d6ce94bd92c7fd1d7ed25ff4bc4ea;hpb=e756e0b650774f2503702512ccdc02e86eee1788;p=dead%2Fwhatever-dl.git diff --git a/src/websites/yikers.rb b/src/websites/yikers.rb index 4b13a02..8cf407a 100644 --- a/src/websites/yikers.rb +++ b/src/websites/yikers.rb @@ -29,18 +29,18 @@ class Yikers < Website def get_video_url() - # First we download the page. Each page contains a flash parameter - # called 'xml' which contains the relative path to the video's XML file. - # We download their XML file (passing it the video id as a side effect), - # and that contains the URL of the video file we want. - page_data = get_page_data(@url) - xml_path = self.parse_xml_path(page_data) - - # The XML path parameter doesn't contain a host name. - xml_url = "http://#{self.server}#{xml_path}" - xml_data = get_page_data(xml_url) + # The video URL is usually just a fixed location, with the file + # name from the page URL slightly modified. For example, + # + # http://www.yikers.com/video_the_best_rapper_in_the_world.html + # + # gets mapped to, + # + # http://cdn.yikers.com/flv/flash8/yikers_the_best_rapper_in_the_world.flv + # + file_name = get_video_filename().sub('video_', 'yikers_') - video_url = parse_video_url(xml_data) + video_url = "http://cdn.yikers.com/flv/flash8/#{file_name}" return video_url end @@ -61,38 +61,5 @@ class Yikers < Website return (filename + '.flv') end - - protected; - - def parse_video_url(data) - video_url_regex = /http:\/\/(cdn\.)?yikers\.com\/([[:alnum:]_\/]+)\.flv/ - matches = video_url_regex.match(data) - video_url = matches[0] if not matches.nil? - - return video_url - end - - - def parse_xml_path(data) - xml_path_regex = /addVariable\(\'xml\', \'(.*?)\'\)/ - matches = xml_path_regex.match(data) - xml_path = matches[1] if not (matches.nil? || matches.length < 2) - - return xml_path - end - - - def get_page_data(url) - uri = URI.parse(url) - - response = Net::HTTP.start(uri.host, uri.port) do |http| - http_path = uri.path - http_path += ('?' + uri.query) if not uri.query.nil? - http.get(http_path) - end - return response.body - end - - end