youtube_search 0.1.10 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/youtube_search.rb +10 -3
- data/lib/youtube_search/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 266669dd4650672bbde5a8cc03beef88cb468ee2
|
4
|
+
data.tar.gz: 3e0ce800af3f97981994c602f9338aa9bf9c3c56
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 751f99e2daee0117bad2c7ace0e66602cc2c2b466e565bf0308edb5220e74a2e986088d5a19531ce6cbe1df3fffa8abca128389b87d49bfae5194c66449762c3
|
7
|
+
data.tar.gz: b455f974f01dc23d0d0f1324c089fcb35f3310e94267f0aff257f3c08ead4da308af691bfdec4db2f488acd73f7fb0fdb5d5afdf4acfa535521f584b90463e1b
|
data/lib/youtube_search.rb
CHANGED
@@ -31,8 +31,15 @@ module YoutubeSearch
|
|
31
31
|
videos "#{API_URL}/users/#{channel_id}/uploads?v=2", options[:format]
|
32
32
|
end
|
33
33
|
|
34
|
+
def single(video_id, options={})
|
35
|
+
options = options.merge(:key => 'entry')
|
36
|
+
videos "#{API_URL}/videos/#{video_id}", :xml, options
|
37
|
+
end
|
38
|
+
|
34
39
|
def parse(xml, options={})
|
35
|
-
|
40
|
+
key = options[:key] || 'feed/entry'
|
41
|
+
|
42
|
+
elements_in(xml, key).map do |element|
|
36
43
|
entry = xml_to_hash(element)
|
37
44
|
entry['video_id'] = if options[:type] == :playlist
|
38
45
|
element.elements['*/yt:videoid'].text
|
@@ -54,13 +61,13 @@ module YoutubeSearch
|
|
54
61
|
|
55
62
|
private
|
56
63
|
|
57
|
-
def videos(url, format)
|
64
|
+
def videos(url, format, options = {})
|
58
65
|
url += '&alt=json' if format == :json
|
59
66
|
res = open(url).read
|
60
67
|
if format == :json
|
61
68
|
res
|
62
69
|
else
|
63
|
-
parse res
|
70
|
+
parse res, options
|
64
71
|
end
|
65
72
|
end
|
66
73
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: youtube_search
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Grosser
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-12 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email: michael@grosser.it
|