]>
gitweb.michael.orlitzky.com - dead/whatever-dl.git/blob - lib/whatever-dl/websites/veoh.rb
2 # Copyright Michael Orlitzky
4 # http://michael.orlitzky.com/
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # http://www.fsf.org/licensing/licenses/gpl.html
24 VALID_VEOH_URL_REGEX
= /^(http:\/\
/)?(www\.)?veoh\.com\/.*?(v
[[:alnum:]]+
)$/
26 def self.owns_url
?(url
)
27 return url
=~ VALID_VEOH_URL_REGEX
32 # First, figure out the video id from the URL.
33 # Then, use the video id to construct the video details URL.
34 # Get the video details page, and parse the redirect
35 # URL from it. Now, I guess we *could* retrieve the video
36 # id from the redirect, but for now we're going to rely
37 # on our HTTP library to follow the redirect for us and
39 video_id
= self.parse_video_id()
40 details_url
= "http://www.veoh.com/rest/video/#{video_id}/details"
41 details_data
= get_page_data(details_url
)
42 redirect_url
= parse_redirect_url(details_data
)
44 # We trust our HTTP library to do the right thing here.
49 def get_video_filename()
50 return (self.parse_video_id() +
'.flv')
56 video_id_regex
= /v[[:alnum:]]+$/
57 matches
= video_id_regex
.match(@url)
58 video_id
= matches
[0] if not matches
.nil?
64 # The main video page has the "video" URL buried
65 # in some javascript parameters.
66 def parse_redirect_url(page_data
)
67 redirect_url_regex
= /fullPreviewHashPath=\"(.*?)\"/
68 matches
= redirect_url_regex
.match(page_data
)
69 redirect_url
= matches
[1] if not matches
.nil? || matches
.length
< 2