]> gitweb.michael.orlitzky.com - dead/whatever-dl.git/blob - lib/whatever-dl/websites/yikers.rb
Move all of the 'src' code under the more-standard 'lib'.
[dead/whatever-dl.git] / lib / whatever-dl / websites / yikers.rb
1 #
2 # Copyright Michael Orlitzky
3 #
4 # http://michael.orlitzky.com/
5 #
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.
10 #
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.
15 #
16 # http://www.fsf.org/licensing/licenses/gpl.html
17 #
18
19 require 'src/website'
20
21
22 class Yikers < Website
23
24 VALID_YIKERS_URL_REGEX = /^(http:\/\/)?(www\.)?yikers\.com\/([[:alnum:]_]+)\.html$/
25
26 def self.owns_url?(url)
27 return url =~ VALID_YIKERS_URL_REGEX
28 end
29
30
31 def get_video_url()
32 # The video URL is usually just a fixed location, with the file
33 # name from the page URL slightly modified. For example,
34 #
35 # http://www.yikers.com/video_the_best_rapper_in_the_world.html
36 #
37 # gets mapped to,
38 #
39 # http://cdn.yikers.com/flv/flash8/yikers_the_best_rapper_in_the_world.flv
40 #
41 file_name = get_video_filename().sub('video_', 'yikers_')
42
43 video_url = "http://cdn.yikers.com/flv/flash8/#{file_name}"
44
45 return video_url
46 end
47
48
49 def get_video_filename()
50 # Default to whatever comes after the final frontslash
51 # in the main URL.
52 filename = @url.split('/').pop()
53
54 # These page URLs are actually descriptive, so we can use
55 # the file name of the HTML page as our video file name.
56 filename_regex = /\/([[:alnum:]_]+)\.html$/
57 matches = filename_regex.match(@url)
58
59 # Overwrite the default if our regex worked.
60 filename = matches[1] if not matches.nil? || matches.length < 1
61
62 return (filename + '.flv')
63 end
64
65 end