heywatch 0.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/heywatch +135 -0
- data/lib/heywatch.rb +133 -81
- metadata +83 -68
- data/Manifest.txt +0 -18
- data/README.txt +0 -163
- data/Rakefile +0 -74
- data/lib/heywatch/account.rb +0 -32
- data/lib/heywatch/auth.rb +0 -83
- data/lib/heywatch/base.rb +0 -269
- data/lib/heywatch/browser.rb +0 -98
- data/lib/heywatch/discover.rb +0 -39
- data/lib/heywatch/download.rb +0 -30
- data/lib/heywatch/encoded_video.rb +0 -49
- data/lib/heywatch/ext.rb +0 -118
- data/lib/heywatch/job.rb +0 -32
- data/lib/heywatch/version.rb +0 -9
- data/lib/heywatch/video.rb +0 -25
- data/setup.rb +0 -1585
- data/test/test_helper.rb +0 -8
- data/test/test_heywatch.rb +0 -149
data/test/test_helper.rb
DELETED
@@ -1,8 +0,0 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
require File.dirname(__FILE__) + '/../lib/heywatch'
|
3
|
-
|
4
|
-
VIDEO_URL = 'http://www.youtube.com/watch?v=eBYLyt9Ptrs'
|
5
|
-
|
6
|
-
def discover_and_download_video(url)
|
7
|
-
Discover.create(:url => url, :download => true, :automatic_encode => false) {|percent, total, received| puts "#{percent}%" }
|
8
|
-
end
|
data/test/test_heywatch.rb
DELETED
@@ -1,149 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
-
require File.dirname(__FILE__) + '/../lib/heywatch'
|
3
|
-
include HeyWatch
|
4
|
-
|
5
|
-
|
6
|
-
class TestHeywatch < Test::Unit::TestCase
|
7
|
-
def setup
|
8
|
-
Base::establish_connection! :login => '', :password => ''
|
9
|
-
end
|
10
|
-
|
11
|
-
# Authentification
|
12
|
-
|
13
|
-
def test_should_be_authorized
|
14
|
-
assert_kind_of Account, Account.find
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_should_raise_if_not_authorized
|
18
|
-
assert_raise(NotAuthorized) { Auth::create 'fakelogin', 'fakepasswd' }
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_should_raise_if_not_logged_in
|
22
|
-
Base::disconnect!
|
23
|
-
assert_raise(NotAuthorized) { Format.find(:first) }
|
24
|
-
end
|
25
|
-
|
26
|
-
# Finding
|
27
|
-
|
28
|
-
def test_should_return_the_first_format
|
29
|
-
assert_kind_of Format, Format.find(:first)
|
30
|
-
end
|
31
|
-
|
32
|
-
def test_should_return_format_with_id
|
33
|
-
id = Format.find(:first).id
|
34
|
-
assert_kind_of Format, Format.find(id)
|
35
|
-
end
|
36
|
-
|
37
|
-
def test_should_return_all_formats
|
38
|
-
formats = Format.find(:all)
|
39
|
-
assert_kind_of Array, formats
|
40
|
-
assert formats.size > 0
|
41
|
-
end
|
42
|
-
|
43
|
-
def test_should_return_just_three_formats
|
44
|
-
formats = Format.find(:all, :limit => 3)
|
45
|
-
assert formats.size == 3
|
46
|
-
end
|
47
|
-
|
48
|
-
def test_should_return_all_ipod_formats
|
49
|
-
formats = Format.find(:all, :conditions => {:name => /ipod/i})
|
50
|
-
formats.each do |f|
|
51
|
-
assert f.name =~ /ipod/i
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
def test_should_return_all_formats_using_xvid_codec
|
56
|
-
formats = Format.find(:all, :conditions => {:video_codec => 'xvid'})
|
57
|
-
formats.each do |f|
|
58
|
-
assert f.video_codec == 'xvid'
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
def test_should_return_all_formats_having_width_less_than_176
|
63
|
-
formats = Format.find(:all, :conditions => {:width => '< 176'})
|
64
|
-
formats.each do |f|
|
65
|
-
assert f.width < 176
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
def test_should_find_by_name
|
70
|
-
assert_equal 'Mobile 3GP', Format.find_by_name('Mobile 3GP').name
|
71
|
-
end
|
72
|
-
|
73
|
-
def test_should_find_all_by_video_codec
|
74
|
-
formats = Format.find_all_by_video_codec('xvid')
|
75
|
-
assert_kind_of Array, formats
|
76
|
-
formats.each do |f|
|
77
|
-
assert f.video_codec =='xvid'
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
def test_should_raise_if_not_found
|
82
|
-
assert_raise(ResourceNotFound) { Format.find(99999999) }
|
83
|
-
end
|
84
|
-
|
85
|
-
# Discover
|
86
|
-
|
87
|
-
def test_should_create_discover
|
88
|
-
discover = Discover.create :url => VIDEO_URL
|
89
|
-
assert_kind_of Discover, discover
|
90
|
-
end
|
91
|
-
|
92
|
-
def test_should_create_discover_and_go_until_raw_video
|
93
|
-
raw_video = discover_and_download_video VIDEO_URL
|
94
|
-
assert_kind_of Video, raw_video
|
95
|
-
end
|
96
|
-
|
97
|
-
def test_should_raise_because_invalid_url
|
98
|
-
assert_raise(RequestError) { Discover.create :url => 'invalid_url' }
|
99
|
-
end
|
100
|
-
|
101
|
-
def test_should_raise_because_no_video_found
|
102
|
-
assert_raise(VideoNotFound) { discover_and_download_video 'http://google.com' }
|
103
|
-
end
|
104
|
-
|
105
|
-
# Job
|
106
|
-
|
107
|
-
# Each of these tests consume 1 credit.
|
108
|
-
|
109
|
-
#def test_should_create_job
|
110
|
-
# raw_video = discover_and_download_video VIDEO_URL
|
111
|
-
# job = Job.create :video_id => raw_video.id, :format_id => Format.find_by_name('Mobile 3GP').id
|
112
|
-
# assert_kind_of Job, job
|
113
|
-
#end
|
114
|
-
|
115
|
-
#def test_should_create_job_and_go_until_encoded_video
|
116
|
-
# raw_video = discover_and_download_video VIDEO_URL
|
117
|
-
# encoded_video = Job.create(:video_id => raw_video.id, :format_id => Format.find_by_name('Mobile 3GP').id) do |percent|
|
118
|
-
# puts "#{percent}%"
|
119
|
-
# end
|
120
|
-
# assert_kind_of EncodedVideo, encoded_video
|
121
|
-
#end
|
122
|
-
|
123
|
-
def test_should_raise_if_format_doesnt_exist
|
124
|
-
raw_video = discover_and_download_video VIDEO_URL
|
125
|
-
assert_raise(RequestError) { Job.create :video_id => raw_video.id, :format_id => 80000 }
|
126
|
-
end
|
127
|
-
|
128
|
-
def test_should_raise_if_video_doesnt_exist
|
129
|
-
assert_raise(RequestError) { Job.create :video_id => 150, :format_id => 2 }
|
130
|
-
end
|
131
|
-
|
132
|
-
# Update and Delete
|
133
|
-
|
134
|
-
def test_should_update_the_title
|
135
|
-
raw_video = discover_and_download_video VIDEO_URL
|
136
|
-
raw_video.update_attributes :title => 'mytitle'
|
137
|
-
assert_equal 'mytitle', Video.find(raw_video.id).title
|
138
|
-
end
|
139
|
-
|
140
|
-
def test_should_delete_the_video
|
141
|
-
raw_video = discover_and_download_video VIDEO_URL
|
142
|
-
assert raw_video.destroy
|
143
|
-
end
|
144
|
-
|
145
|
-
def test_should_raise_if_video_doesnt_exist
|
146
|
-
assert_raise(ResourceNotFound) { Video.destroy(99999999999) }
|
147
|
-
assert_raise(ResourceNotFound) { Video.update(99999999999, :title => 'mytitle') }
|
148
|
-
end
|
149
|
-
end
|