youtube_search 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/Readme.md +3 -1
- data/lib/youtube_search.rb +4 -1
- data/lib/youtube_search/version.rb +1 -1
- data/spec/youtube_search_spec.rb +18 -34
- metadata +4 -4
data/Gemfile.lock
CHANGED
data/Readme.md
CHANGED
@@ -21,6 +21,7 @@ Usage
|
|
21
21
|
"video_id"=>"0b2U5r7Jwkc",
|
22
22
|
"content"=>"Top YouTube Videos on ...",
|
23
23
|
"updated"=>"2011-10-13T20:20:54.000Z",
|
24
|
+
"raw" => <REXML::Element ... >,
|
24
25
|
...
|
25
26
|
}
|
26
27
|
|
@@ -44,7 +45,7 @@ and [standard youtube options](http://code.google.com/apis/youtube/2.0/developer
|
|
44
45
|
|
45
46
|
TODO
|
46
47
|
====
|
47
|
-
- more detailed xml parsing (
|
48
|
+
- more detailed xml parsing (you can fetch everything via 'raw', but more defaults would be nice)
|
48
49
|
- parse dates into ruby objects
|
49
50
|
|
50
51
|
|
@@ -53,6 +54,7 @@ Author
|
|
53
54
|
|
54
55
|
### [Contributors](http://github.com/grosser/youtube_search/contributors)
|
55
56
|
- [David Gil](https://qoolife.com)
|
57
|
+
- [Jim Jones](https://github.com/aantix)
|
56
58
|
|
57
59
|
[Michael Grosser](http://grosser.it)<br/>
|
58
60
|
michael@grosser.it<br/>
|
data/lib/youtube_search.rb
CHANGED
@@ -25,7 +25,10 @@ module YoutubeSearch
|
|
25
25
|
entry['id'].split('/').last
|
26
26
|
end
|
27
27
|
|
28
|
-
|
28
|
+
duration = element.elements['*/yt:duration']
|
29
|
+
entry['duration'] = duration.attributes['seconds'] if duration
|
30
|
+
|
31
|
+
entry['raw'] = element
|
29
32
|
|
30
33
|
entry
|
31
34
|
end
|
data/spec/youtube_search_spec.rb
CHANGED
@@ -8,43 +8,27 @@ describe YoutubeSearch do
|
|
8
8
|
describe 'parse' do
|
9
9
|
it "can parse xml from a search" do
|
10
10
|
# convert to array so we get a nice diff in case of errors
|
11
|
-
YoutubeSearch.parse(File.read('spec/fixtures/search_boat.xml')).first
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
["published","2011-09-29T15:30:43.000Z"],
|
21
|
-
["rating", nil],
|
22
|
-
["statistics",nil],
|
23
|
-
["title","Killer Whale Imitates Boat Motor"],
|
24
|
-
["updated","2011-10-14T07:40:00.000Z"],
|
25
|
-
["video_id", "0b2U5r7Jwkc"],
|
26
|
-
]
|
11
|
+
video = YoutubeSearch.parse(File.read('spec/fixtures/search_boat.xml')).first
|
12
|
+
video["content"].should == "Top YouTube Videos on tubecrunch.blogspot.com A killer whale swims right up to a boat and shows off his best sounding motor impression."
|
13
|
+
video["duration"].should == "75"
|
14
|
+
video["id"].should == "http://gdata.youtube.com/feeds/api/videos/0b2U5r7Jwkc"
|
15
|
+
video["published"].should == "2011-09-29T15:30:43.000Z"
|
16
|
+
video["title"].should == "Killer Whale Imitates Boat Motor"
|
17
|
+
video["updated"].should == "2011-10-14T07:40:00.000Z"
|
18
|
+
video["video_id"].should == "0b2U5r7Jwkc"
|
19
|
+
video["raw"].elements.should_not == nil
|
27
20
|
end
|
28
21
|
|
29
22
|
it "can parse xml from a playlist" do
|
30
|
-
YoutubeSearch.parse(File.read('spec/fixtures/playlist_5F23DAF4BFE3D14C.xml'), :type => :playlist).first
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
["position","1"],
|
40
|
-
["rating", nil],
|
41
|
-
["recorded", "2010-01-08"],
|
42
|
-
["statistics",nil],
|
43
|
-
["title","Osteopatia y terapias manuales"],
|
44
|
-
["updated","2011-12-07T01:46:21.650Z"],
|
45
|
-
["video_id", "5wU-yHnq7Hs"],
|
46
|
-
["where", nil]
|
47
|
-
]
|
23
|
+
video = YoutubeSearch.parse(File.read('spec/fixtures/playlist_5F23DAF4BFE3D14C.xml'), :type => :playlist).first
|
24
|
+
video["duration"].should == "192"
|
25
|
+
video["id"].should == "tag:youtube.com,2008:playlist:5F23DAF4BFE3D14C:kRk0fUfl9UJvHjGFHgPSakUFmztBgGKG"
|
26
|
+
video["position"].should == "1"
|
27
|
+
video["recorded"].should == "2010-01-08"
|
28
|
+
video["title"].should == "Osteopatia y terapias manuales"
|
29
|
+
video["updated"].should == "2011-12-07T01:46:21.650Z"
|
30
|
+
video["video_id"].should == "5wU-yHnq7Hs"
|
31
|
+
video["raw"].elements.should_not == nil
|
48
32
|
end
|
49
33
|
end
|
50
34
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: youtube_search
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-12-
|
12
|
+
date: 2011-12-20 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description:
|
15
15
|
email: michael@grosser.it
|
@@ -43,7 +43,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
43
43
|
version: '0'
|
44
44
|
segments:
|
45
45
|
- 0
|
46
|
-
hash:
|
46
|
+
hash: 870410863
|
47
47
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
48
48
|
none: false
|
49
49
|
requirements:
|
@@ -52,7 +52,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
52
52
|
version: '0'
|
53
53
|
segments:
|
54
54
|
- 0
|
55
|
-
hash:
|
55
|
+
hash: 870410863
|
56
56
|
requirements: []
|
57
57
|
rubyforge_project:
|
58
58
|
rubygems_version: 1.8.10
|