mikedamage-ruby_tube 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/ruby_tube_no_auth.rb +30 -26
- data/ruby_tube.gemspec +5 -4
- data/test/rt_no_auth_test.rb +27 -0
- metadata +4 -3
- data/.document +0 -5
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.4
|
data/lib/ruby_tube_no_auth.rb
CHANGED
@@ -14,22 +14,22 @@ class RubyTubeNoAuth
|
|
14
14
|
xml = Hpricot.XML(res.body)
|
15
15
|
entry = xml.at("entry")
|
16
16
|
vid = YTVideo.new({
|
17
|
-
:id => (
|
18
|
-
:title => (
|
19
|
-
:description => (
|
20
|
-
:keywords => (
|
21
|
-
:duration => (
|
22
|
-
:player_uri => (
|
23
|
-
:ratings_uri => (
|
24
|
-
:comments_uri => (
|
25
|
-
:comment_count => (
|
26
|
-
:published_at => Time.parse((
|
27
|
-
:updated_at => Time.parse((
|
28
|
-
:view_count => (
|
29
|
-
:favorite_count => (
|
30
|
-
:comments => comments((
|
31
|
-
:ratings => ratings(
|
32
|
-
:status => status,
|
17
|
+
:id => entry.at("yt:videoid").inner_text,
|
18
|
+
:title => entry.at("media:title").inner_text,
|
19
|
+
:description => entry.at("media:description").inner_text,
|
20
|
+
:keywords => entry.at("media:keywords").inner_text,
|
21
|
+
:duration => entry.at("yt:duration")["seconds"].to_i,
|
22
|
+
:player_uri => entry.at("link[@rel='alternate']")["href"],
|
23
|
+
:ratings_uri => entry.at("link[@rel$='ratings']")["href"],
|
24
|
+
:comments_uri => entry.at("gd:comments").at("gd:feedLink")["href"],
|
25
|
+
:comment_count => entry.at("gd:comments").at("gd:feedLink")["countHint"].to_i,
|
26
|
+
:published_at => Time.parse(entry.at("published").inner_text),
|
27
|
+
:updated_at => Time.parse(entry.at("updated").inner_text),
|
28
|
+
:view_count => entry.at("yt:statistics").nil? ? 0 : entry.at("yt:statistics")["viewCount"].to_i,
|
29
|
+
:favorite_count => entry.at("yt:statistics").nil? ? 0 : entry.at("yt:statistics")["favoriteCount"].to_i,
|
30
|
+
:comments => comments(entry.at("yt:videoid").inner_text),
|
31
|
+
:ratings => ratings(entry),
|
32
|
+
:status => status(entry),
|
33
33
|
:thumbnails => process_thumbnail_urls(entry)
|
34
34
|
})
|
35
35
|
vid
|
@@ -54,19 +54,23 @@ class RubyTubeNoAuth
|
|
54
54
|
comments
|
55
55
|
end
|
56
56
|
|
57
|
-
def ratings(id)
|
58
|
-
response = Hpricot.XML(@client.get("http://gdata.youtube.com/feeds/api/videos/#{id}").body)
|
59
|
-
ratings = (response/"gd:rating")
|
60
|
-
if ratings.nitems > 0
|
61
|
-
return ratings
|
62
|
-
else
|
63
|
-
return nil
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
57
|
private
|
68
58
|
def process_thumbnail_urls(hpricot)
|
69
59
|
thumbs = (hpricot/"media:thumbnail")
|
70
60
|
{:big => thumbs.last["url"], :small => thumbs.first["url"]}
|
71
61
|
end
|
62
|
+
|
63
|
+
def ratings(hpricot)
|
64
|
+
rating_info = hpricot.at("gd:rating")
|
65
|
+
{
|
66
|
+
:max => rating_info['max'].to_i,
|
67
|
+
:min => rating_info['min'].to_i,
|
68
|
+
:average => rating_info['average'].to_f,
|
69
|
+
:num_raters => rating_info['numRaters'].to_i
|
70
|
+
}
|
71
|
+
end
|
72
|
+
|
73
|
+
def status(hpricot)
|
74
|
+
hpricot.at("yt:duration").nil? ? "processing" : "live"
|
75
|
+
end
|
72
76
|
end
|
data/ruby_tube.gemspec
CHANGED
@@ -5,18 +5,17 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{ruby_tube}
|
8
|
-
s.version = "0.3.
|
8
|
+
s.version = "0.3.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Mike Green"]
|
12
|
-
s.date = %q{2009-09-
|
12
|
+
s.date = %q{2009-09-20}
|
13
13
|
s.email = %q{mike.is.green@gmail.com}
|
14
14
|
s.extra_rdoc_files = [
|
15
15
|
"LICENSE",
|
16
16
|
"README.rdoc"
|
17
17
|
]
|
18
18
|
s.files = [
|
19
|
-
".document",
|
20
19
|
".gitignore",
|
21
20
|
"LICENSE",
|
22
21
|
"README.rdoc",
|
@@ -31,6 +30,7 @@ Gem::Specification.new do |s|
|
|
31
30
|
"ruby_tube.gemspec",
|
32
31
|
"test/josh_walking.mp4",
|
33
32
|
"test/maddie.mp4",
|
33
|
+
"test/rt_no_auth_test.rb",
|
34
34
|
"test/ruby_tube_test.rb",
|
35
35
|
"test/test_helper.rb",
|
36
36
|
"test/yt_client_test.rb"
|
@@ -41,7 +41,8 @@ Gem::Specification.new do |s|
|
|
41
41
|
s.rubygems_version = %q{1.3.5}
|
42
42
|
s.summary = %q{Simple Ruby library for uploading and finding YouTube videos.}
|
43
43
|
s.test_files = [
|
44
|
-
"test/
|
44
|
+
"test/rt_no_auth_test.rb",
|
45
|
+
"test/ruby_tube_test.rb",
|
45
46
|
"test/test_helper.rb",
|
46
47
|
"test/yt_client_test.rb"
|
47
48
|
]
|
@@ -0,0 +1,27 @@
|
|
1
|
+
class RTNoAuthTest < Test::Unit::TestCase
|
2
|
+
context "A RubyTubeNoAuth instance" do
|
3
|
+
setup do
|
4
|
+
@dev_key = "AI39si6AUy_AzaCEU5TSUFeV7m2RozUtYW-0SEUR2DHh9hltQpZ2LrUYyNwF3R8eyl3VucUxJNCth4s4P2H8X24hyr2Els8uJg"
|
5
|
+
@test_vid_id = "5YNOZksBoDc"
|
6
|
+
@ruby_tube = RubyTubeNoAuth.new(DEV_KEY)
|
7
|
+
end
|
8
|
+
|
9
|
+
should "return a new instance of RubyTubeNoAuth" do
|
10
|
+
assert not_nil(@ruby_tube) && @ruby_tube.is_a?(RubyTubeNoAuth)
|
11
|
+
end
|
12
|
+
|
13
|
+
should "return an instance of YTVideo on calling #find(id)" do
|
14
|
+
vid = @ruby_tube.find(@test_vid_id)
|
15
|
+
assert vid.is_a?(YTVideo)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
def not_nil(obj)
|
21
|
+
!obj.nil?
|
22
|
+
end
|
23
|
+
|
24
|
+
def not_empty(obj)
|
25
|
+
!obj.empty?
|
26
|
+
end
|
27
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mikedamage-ruby_tube
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Green
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-09-
|
12
|
+
date: 2009-09-20 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -52,7 +52,6 @@ extra_rdoc_files:
|
|
52
52
|
- LICENSE
|
53
53
|
- README.rdoc
|
54
54
|
files:
|
55
|
-
- .document
|
56
55
|
- .gitignore
|
57
56
|
- LICENSE
|
58
57
|
- README.rdoc
|
@@ -67,6 +66,7 @@ files:
|
|
67
66
|
- ruby_tube.gemspec
|
68
67
|
- test/josh_walking.mp4
|
69
68
|
- test/maddie.mp4
|
69
|
+
- test/rt_no_auth_test.rb
|
70
70
|
- test/ruby_tube_test.rb
|
71
71
|
- test/test_helper.rb
|
72
72
|
- test/yt_client_test.rb
|
@@ -98,6 +98,7 @@ signing_key:
|
|
98
98
|
specification_version: 3
|
99
99
|
summary: Simple Ruby library for uploading and finding YouTube videos.
|
100
100
|
test_files:
|
101
|
+
- test/rt_no_auth_test.rb
|
101
102
|
- test/ruby_tube_test.rb
|
102
103
|
- test/test_helper.rb
|
103
104
|
- test/yt_client_test.rb
|