X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=src%2Fwebsites%2Fveoh.rb;h=951d87dabc9975dc959bd2d327f25acbd8bcd0bc;hb=8e886df259246365023322b78f58e4037cb536a4;hp=e10d9853d7ccaf45f4ffb823d6e5f13cd2362cec;hpb=cb1b5a8a87ec46656e3d860c208210a5cc24a32e;p=dead%2Fwhatever-dl.git diff --git a/src/websites/veoh.rb b/src/websites/veoh.rb index e10d985..951d87d 100644 --- a/src/websites/veoh.rb +++ b/src/websites/veoh.rb @@ -18,22 +18,17 @@ require 'src/website' -# Needed to download the page, which is in turn -# needed because it contains the video (redirect) URL. -require 'net/http' -require 'uri' - class Veoh < Website - VALID_VEOH_URL_REGEX = /^(http:\/\/)?(www\.)?veoh\.com\/videos\/([[:alnum:]]+)$/ + VALID_VEOH_URL_REGEX = /^(http:\/\/)?(www\.)?veoh\.com\/.*?(v[[:alnum:]]+)$/ def self.owns_url?(url) return url =~ VALID_VEOH_URL_REGEX end - def get_video_url(url) + def get_video_url() # First, figure out the video id from the URL. # Then, use the video id to construct the video details URL. # Get the video details page, and parse the redirect @@ -41,23 +36,25 @@ class Veoh < Website # id from the redirect, but for now we're going to rely # on our HTTP library to follow the redirect for us and # save us a step. - video_id = parse_video_id(url) + video_id = self.parse_video_id() details_url = "http://www.veoh.com/rest/video/#{video_id}/details" details_data = get_page_data(details_url) redirect_url = parse_redirect_url(details_data) - # Being slightly explicit about what we're doing here... - video_url = redirect_url - - return video_url + # We trust our HTTP library to do the right thing here. + return redirect_url end + + def get_video_filename() + return (self.parse_video_id() + '.flv') + end protected; - def parse_video_id(url) - video_id_regex = /[[:alnum:]]+$/ - matches = video_id_regex.match(url) + def parse_video_id() + video_id_regex = /v[[:alnum:]]+$/ + matches = video_id_regex.match(@url) video_id = matches[0] if not matches.nil? return video_id @@ -69,20 +66,10 @@ class Veoh < Website def parse_redirect_url(page_data) redirect_url_regex = /fullPreviewHashPath=\"(.*?)\"/ matches = redirect_url_regex.match(page_data) - redirect_url = matches[1] if not (matches.nil? || matches.length < 1) + redirect_url = matches[1] if not matches.nil? || matches.length < 2 return redirect_url end - def get_page_data(url) - uri = URI.parse(url) - - response = Net::HTTP.start(uri.host, uri.port) do |http| - http.get(uri.path) - end - - return response.body - end - end