youtube_search 0.1.9 → 0.1.10
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 +20 -8
- 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: f2e50c3aad4aa406eb53bd4264f08f39fd670100
|
4
|
+
data.tar.gz: 7c273e791ee1d5c1d7caff0932c5cea03f60a5cb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0b996485a098b434ce9328cc4879dfff152b6a94bc187e9a37b7f9d39b8f6ff0d5ebd50ff47e46b8a6d2d9b15d3de5ba2f5cf96a69237a8b6645aeeda4f5e948
|
7
|
+
data.tar.gz: abfd8b73538be534ce3cf5fb9261145a681888aae50e4fedf73a4ebf251b1315e832a4289e68fb5ed9c7438dc29db9e9b0fdfa8c04c7ecb77b0c8e2a90ff0047
|
data/lib/youtube_search.rb
CHANGED
@@ -3,6 +3,8 @@ require 'cgi'
|
|
3
3
|
require 'open-uri'
|
4
4
|
|
5
5
|
module YoutubeSearch
|
6
|
+
API_URL = 'http://gdata.youtube.com/feeds/api'
|
7
|
+
|
6
8
|
class << self
|
7
9
|
def search_page(page, query, options={})
|
8
10
|
options = options_with_per_page_and_page(options)
|
@@ -12,21 +14,21 @@ module YoutubeSearch
|
|
12
14
|
end
|
13
15
|
|
14
16
|
def search(query, options={})
|
15
|
-
search_page("
|
17
|
+
search_page("#{API_URL}/videos", query, options)
|
16
18
|
end
|
17
19
|
|
18
20
|
def search_playlists(query, options={})
|
19
|
-
search_page("
|
21
|
+
search_page("#{API_URL}/playlists/snippets", query, options.merge(:v => 2))
|
20
22
|
end
|
21
23
|
|
22
24
|
def playlist_videos(playlist_id, options={})
|
23
25
|
playlist_id = playlist_id.sub(/^PL/, "")
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
26
|
+
videos "#{API_URL}/playlists/#{playlist_id}?v=2", options[:format]
|
27
|
+
end
|
28
|
+
|
29
|
+
def user_channel_videos(channel_id, options={})
|
30
|
+
channel_id = channel_id.sub(/^UC/, "")
|
31
|
+
videos "#{API_URL}/users/#{channel_id}/uploads?v=2", options[:format]
|
30
32
|
end
|
31
33
|
|
32
34
|
def parse(xml, options={})
|
@@ -52,6 +54,16 @@ module YoutubeSearch
|
|
52
54
|
|
53
55
|
private
|
54
56
|
|
57
|
+
def videos(url, format)
|
58
|
+
url += '&alt=json' if format == :json
|
59
|
+
res = open(url).read
|
60
|
+
if format == :json
|
61
|
+
res
|
62
|
+
else
|
63
|
+
parse res
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
55
67
|
def elements_in(xml, selector)
|
56
68
|
entries = []
|
57
69
|
doc = REXML::Document.new(xml)
|
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.1.
|
4
|
+
version: 0.1.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Grosser
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-08-26 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email: michael@grosser.it
|