]> gitweb.michael.orlitzky.com - dead/whatever-dl.git/blob - test/bliptv_test.rb
Added support for blip.tv.
[dead/whatever-dl.git] / test / bliptv_test.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 'test/unit'
20 require 'src/websites/bliptv'
21
22 class BliptvTest < Test::Unit::TestCase
23
24 def test_owns_bliptv_urls
25
26 assert(Bliptv.owns_url?('http://www.blip.tv/file/2664572?utm_source=featured_ep&utm_medium=featured_ep'))
27 assert(Bliptv.owns_url?('www.blip.tv/file/2664572?utm_source=featured_ep&utm_medium=featured_ep'))
28 assert(Bliptv.owns_url?('http://www.blip.tv/file/2664626'))
29 assert(Bliptv.owns_url?('http://www.blip.tv/file/2664626?utm_source=featured_ep&utm_medium=featured_ep'))
30 assert(Bliptv.owns_url?('http://urbansustainableliv.blip.tv/file/1189454/'))
31 assert(Bliptv.owns_url?('http://rosa-menkman.blip.tv/file/1947851/'))
32 assert(Bliptv.owns_url?('rosa-menkman.blip.tv/file/1947851/'))
33 assert(Bliptv.owns_url?('rosa-menkman.blip.tv/file/1947851/?utm_source=featured_ep&utm_medium=featured_ep'))
34 assert(Bliptv.owns_url?('rosa-menkman.blip.tv/file/1947851?utm_source=featured_ep&utm_medium=featured_ep'))
35 assert(Bliptv.owns_url?('http://www.blip.tv/file/2664626'))
36 end
37
38
39 def test_doesnt_own_redtube_urls
40 assert(!Bliptv.owns_url?('http://www.redtube.com/6807'))
41 assert(!Bliptv.owns_url?('www.redtube.com/6807'))
42 assert(!Bliptv.owns_url?('http://redtube.com/6807'))
43 assert(!Bliptv.owns_url?('redtube.com/6807'))
44 end
45
46
47 def test_doesnt_own_howcast_urls
48 assert(!Bliptv.owns_url?('http://www.howcast.com/videos/6807-2twr'))
49 assert(!Bliptv.owns_url?('www.howcast.com/videos/6807-2dgfdg'))
50 assert(!Bliptv.owns_url?('http://howcast.com/videos/6807-cse'))
51 assert(!Bliptv.owns_url?('howcast.com/videos/6807-asdgasd'))
52 end
53
54
55 def test_doesnt_own_misc_urls
56 assert(!Bliptv.owns_url?('http://www.bliptv.com/123456'))
57 end
58
59
60 def test_parse_flv_video_url
61 # Here we're trying to parse the video URL out of some standard
62 # blip.tv pages, where the video playing is in FLV format. In both
63 # of these cases, though, we want to parse the source (MOV/WMV)
64 # video URL.
65 btv = Bliptv.new(nil)
66
67 page_data = nil
68
69 File.open('test/fixtures/bliptv/1752651.htm') do |f|
70 page_data = f.read
71 end
72
73 test_result = btv.send('parse_video_url', page_data)
74 assert_equal('http://blip.tv/file/get/Esequeira82-AdventuresInEgypt567.wmv', test_result)
75
76
77 # Second Fixture
78
79 File.open('test/fixtures/bliptv/923819.htm') do |f|
80 page_data = f.read
81 end
82
83 test_result = btv.send('parse_video_url', page_data)
84 assert_equal('http://blip.tv/file/get/Kantel-SadSong186.mov', test_result)
85 end
86
87
88
89 def test_parse_mov_video_url
90 # These fixtures are saved from pages where the high-quality MOV
91 # format was already selected.
92 btv = Bliptv.new(nil)
93
94 page_data = nil
95
96 File.open('test/fixtures/bliptv/923682-mov.htm') do |f|
97 page_data = f.read
98 end
99
100 test_result = btv.send('parse_video_url', page_data)
101 assert_equal('http://blip.tv/file/get/Kantel-UbiUndPythonDemo816.mov', test_result)
102
103
104 # Second Fixture
105
106 File.open('test/fixtures/bliptv/923819-mov.htm') do |f|
107 page_data = f.read
108 end
109
110 test_result = btv.send('parse_video_url', page_data)
111 assert_equal('http://blip.tv/file/get/Kantel-SadSong186.mov', test_result)
112 end
113
114
115
116 def test_parse_mp4_video_url
117 # And why not check one of the MP4 pages, too?
118
119 btv = Bliptv.new(nil)
120
121 page_data = nil
122
123 File.open('test/fixtures/bliptv/923682-mp4.htm') do |f|
124 page_data = f.read
125 end
126
127 test_result = btv.send('parse_video_url', page_data)
128 assert_equal('http://blip.tv/file/get/Kantel-UbiUndPythonDemo816.mov', test_result)
129 end
130
131
132 def test_parse_mp4_video_url
133 # And why not check one of the MP4 pages, too?
134
135 btv = Bliptv.new(nil)
136
137 page_data = nil
138
139 File.open('test/fixtures/bliptv/923682-no_alternatives.htm') do |f|
140 page_data = f.read
141 end
142
143 test_result = btv.send('parse_video_url', page_data)
144 assert_equal('http://blip.tv/file/get/Kantel-UbiUndPythonDemo816.flv', test_result)
145 end
146
147 end