youtube_search 0.1.5 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- youtube_search (0.1.5)
4
+ youtube_search (0.1.6)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
data/Rakefile CHANGED
@@ -18,3 +18,18 @@ rule /^version:bump:.*/ do |t|
18
18
 
19
19
  sh "bundle && git add #{file} Gemfile.lock && git commit -m 'bump version to #{new_version}'"
20
20
  end
21
+
22
+ desc "Update fixtures by downloading them"
23
+ task :update_fixtures do
24
+ require 'youtube_search'
25
+
26
+ # search
27
+ query = "boat"
28
+ xml = open("http://gdata.youtube.com/feeds/api/videos?#{query}").read
29
+ File.open("spec/fixtures/search_#{query}.xml","w"){|f| f.write xml }
30
+
31
+ # playlist
32
+ id = "5F23DAF4BFE3D14C"
33
+ xml = open("http://gdata.youtube.com/feeds/api/playlists/#{id}?v=2").read
34
+ File.open("spec/fixtures/playlist_#{id}.xml","w"){|f| f.write xml }
35
+ end
@@ -1,3 +1,3 @@
1
1
  module YoutubeSearch
2
- VERSION = '0.1.5'
2
+ VERSION = '0.1.6'
3
3
  end
@@ -28,6 +28,9 @@ module YoutubeSearch
28
28
  duration = element.elements['*/yt:duration']
29
29
  entry['duration'] = duration.attributes['seconds'] if duration
30
30
 
31
+ no_embed = element.elements['yt:noembed'] || element.elements['yt:private']
32
+ entry['embeddable'] = !(no_embed)
33
+
31
34
  entry['raw'] = element
32
35
 
33
36
  entry
@@ -6,9 +6,11 @@ describe YoutubeSearch do
6
6
  end
7
7
 
8
8
  describe 'parse' do
9
+ let(:canned_xml){ File.read('spec/fixtures/search_boat.xml') }
10
+
9
11
  it "can parse xml from a search" do
10
12
  # convert to array so we get a nice diff in case of errors
11
- video = YoutubeSearch.parse(File.read('spec/fixtures/search_boat.xml')).first
13
+ video = YoutubeSearch.parse(canned_xml).first
12
14
  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
15
  video["duration"].should == "75"
14
16
  video["id"].should == "http://gdata.youtube.com/feeds/api/videos/0b2U5r7Jwkc"
@@ -19,6 +21,25 @@ describe YoutubeSearch do
19
21
  video["raw"].elements.should_not == nil
20
22
  end
21
23
 
24
+ context "embeddable" do
25
+ it "is embeddable if neither private nor noembed are set" do
26
+ video = YoutubeSearch.parse(canned_xml).last
27
+ video["embeddable"].should == true
28
+ end
29
+
30
+ it "is not embeddable if noembed is set" do
31
+ xml = canned_xml.sub('</entry>','<yt:noembed/></entry>')
32
+ video = YoutubeSearch.parse(xml).first
33
+ video["embeddable"].should == false
34
+ end
35
+
36
+ it "is not embeddable if private is set" do
37
+ xml = canned_xml.sub('</entry>','<yt:private/></entry>')
38
+ video = YoutubeSearch.parse(xml).first
39
+ video["embeddable"].should == false
40
+ end
41
+ end
42
+
22
43
  it "can parse xml from a playlist" do
23
44
  video = YoutubeSearch.parse(File.read('spec/fixtures/playlist_5F23DAF4BFE3D14C.xml'), :type => :playlist).first
24
45
  video["duration"].should == "192"
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.5
4
+ version: 0.1.6
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-20 00:00:00.000000000 Z
12
+ date: 2011-12-28 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: 870410863
46
+ hash: -208767601
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: 870410863
55
+ hash: -208767601
56
56
  requirements: []
57
57
  rubyforge_project:
58
58
  rubygems_version: 1.8.10