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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 13970df8635a7e9a1522a5a86f0cc785d7249682
4
- data.tar.gz: 3f0b0c46cb56d424ffe607cec8846b4f1deda5a2
3
+ metadata.gz: f2e50c3aad4aa406eb53bd4264f08f39fd670100
4
+ data.tar.gz: 7c273e791ee1d5c1d7caff0932c5cea03f60a5cb
5
5
  SHA512:
6
- metadata.gz: 61d81a396d5ebc47d01a0e99e75b59ca23fde105464361fd8f6dfc0b7c61ef84464e47b13785d3ab7da91a1e6391fd82d0f6d037cead2930242d6d09498c1b64
7
- data.tar.gz: 2e40369c6c6a8355ba9bad23c511b12e6826d80feefbe89c7c8601d36a3e2ec2ff11593cbee744e26126f6392edb1c76431d1467e3289afa380370e78c8e573c
6
+ metadata.gz: 0b996485a098b434ce9328cc4879dfff152b6a94bc187e9a37b7f9d39b8f6ff0d5ebd50ff47e46b8a6d2d9b15d3de5ba2f5cf96a69237a8b6645aeeda4f5e948
7
+ data.tar.gz: abfd8b73538be534ce3cf5fb9261145a681888aae50e4fedf73a4ebf251b1315e832a4289e68fb5ed9c7438dc29db9e9b0fdfa8c04c7ecb77b0c8e2a90ff0047
@@ -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("http://gdata.youtube.com/feeds/api/videos", query, options)
17
+ search_page("#{API_URL}/videos", query, options)
16
18
  end
17
19
 
18
20
  def search_playlists(query, options={})
19
- search_page("https://gdata.youtube.com/feeds/api/playlists/snippets", query, options.merge(:v => 2))
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
- res = open("http://gdata.youtube.com/feeds/api/playlists/#{playlist_id}?v=2#{'&alt=json' if options[:format] == :json}").read
25
- if options[:format] == :json
26
- res
27
- else
28
- parse(res, :type => :playlist)
29
- end
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)
@@ -1,3 +1,3 @@
1
1
  module YoutubeSearch
2
- VERSION = '0.1.9'
2
+ VERSION = '0.1.10'
3
3
  end
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.9
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-06-20 00:00:00.000000000 Z
11
+ date: 2014-08-26 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: michael@grosser.it