video_info 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -11,7 +11,7 @@ begin
11
11
  gem.homepage = "http://github.com/guillaumegentil/video_info"
12
12
  gem.authors = ["Thibaud Guillaume-Gentil"]
13
13
  gem.add_development_dependency "rspec", ">= 1.2.9"
14
- gem.add_dependency "hpricot", ">= 0.8.1"
14
+ gem.add_dependency "hpricot", ">= 0.8.2"
15
15
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
16
16
  end
17
17
  Jeweler::GemcutterTasks.new
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.2.1
@@ -1,17 +1,20 @@
1
1
  require 'hpricot'
2
2
  require 'open-uri'
3
3
 
4
- class Vimeo < Video
4
+ class Vimeo
5
+ attr_accessor :video_id, :url, :provider, :title, :description, :keywords,
6
+ :duration, :date, :width, :height,
7
+ :thumbnail_small, :thumbnail_large
5
8
 
6
9
  def initialize(url)
7
- @id = url.gsub(/.*\.com\/([0-9]+).*$/i, '\1')
8
- get_info unless @id == url
10
+ @video_id = url.gsub(/.*\.com\/([0-9]+).*$/i, '\1')
11
+ get_info unless @video_id == url
9
12
  end
10
13
 
11
14
  private
12
15
 
13
16
  def get_info
14
- doc = Hpricot(open("http://vimeo.com/api/v2/video/#{@id}.xml"))
17
+ doc = Hpricot(open("http://vimeo.com/api/v2/video/#{@video_id}.xml"))
15
18
  @provider = "Vimeo"
16
19
  @url = doc.search("url").inner_text
17
20
  @title = doc.search("title").inner_text
@@ -1,19 +1,22 @@
1
1
  require 'hpricot'
2
2
  require 'open-uri'
3
3
 
4
- class Youtube < Video
4
+ class Youtube
5
+ attr_accessor :video_id, :url, :provider, :title, :description, :keywords,
6
+ :duration, :date, :width, :height,
7
+ :thumbnail_small, :thumbnail_large
5
8
 
6
9
  def initialize(url)
7
- @id = url.gsub(/.*v=([^&]+).*$/i, '\1')
8
- get_info unless @id == url
10
+ @video_id = url.gsub(/.*v=([^&]+).*$/i, '\1')
11
+ get_info unless @video_id == url
9
12
  end
10
13
 
11
14
  private
12
15
 
13
16
  def get_info
14
- doc = Hpricot(open("http://gdata.youtube.com/feeds/api/videos/#{@id}"))
17
+ doc = Hpricot(open("http://gdata.youtube.com/feeds/api/videos/#{@video_id}"))
15
18
  @provider = "YouTube"
16
- @url = "http://www.youtube.com/watch?v=#{@id}"
19
+ @url = "http://www.youtube.com/watch?v=#{@video_id}"
17
20
  @title = doc.search("media:title").inner_text
18
21
  @description = doc.search("media:description").inner_text
19
22
  @keywords = doc.search("media:keywords").inner_text
data/lib/video_info.rb CHANGED
@@ -1,6 +1,5 @@
1
- require 'video'
2
- require 'video/vimeo'
3
- require 'video/youtube'
1
+ require 'provider/vimeo'
2
+ require 'provider/youtube'
4
3
 
5
4
  class VideoInfo
6
5
 
@@ -14,27 +13,11 @@ class VideoInfo
14
13
  end
15
14
 
16
15
  def valid?
17
- @video && !["", nil].include?(title)
16
+ @video != nil && !["", nil].include?(title)
18
17
  end
19
18
 
20
19
  def method_missing(sym, *args, &block)
21
20
  @video.send sym, *args, &block
22
21
  end
23
22
 
24
- # def embed(options = {})
25
- # width = options[:width]
26
- # height = options[:height]
27
- #
28
- # allowfullscreen = options[:fullscreen]
29
- # fullscreen = options[:fullscreen] ? 1 : 0
30
- # show_title = options[:show_title] ? 1 : 0
31
- # show_byline = options[:show_byline] ? 1 : 0
32
- # show_portrait = options[:show_portrait] ? 1 : 0
33
- # case provider
34
- # when "Youtub"
35
- #
36
- # %{<object width="#{width}" height="#{height}"><param name="allowfullscreen" value="#{allowfullscreen}" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=#{id}&amp;server=vimeo.com&amp;show_title=#{show_title}&amp;show_byline=#{show_byline}&amp;show_portrait=#{show_portrait}&amp;color=00adef&amp;fullscreen=#{fullscreen}" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=#{vimeo_id}&amp;server=vimeo.com&amp;show_title=#{show_title}&amp;show_byline=#{show_byline}&amp;show_portrait=#{show_portrait}&amp;color=00adef&amp;fullscreen=#{fullscreen}" type="application/x-shockwave-flash" allowfullscreen="#{allowfullscreen}" allowscriptaccess="always" width="#{options[:width]}" height="#{options[:height]}"></embed></object>}
37
- # %{<object width="#{options[:width]}" height="#{options[:height]}"><param name="movie" value="http://www.youtube.com/v/#{youtube_id}"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/#{id}" type="application/x-shockwave-flash" wmode="transparent" width="#{options[:width]}" height="#{options[:height]}"></embed></object>}
38
- # end
39
-
40
23
  end
data/spec/spec_helper.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  $LOAD_PATH.unshift(File.dirname(__FILE__))
2
2
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ require 'rubygems'
3
4
  require 'video_info'
4
5
  require 'spec'
5
6
  require 'spec/autorun'
@@ -6,6 +6,7 @@ describe "VideoInfo" do
6
6
  subject { VideoInfo.new('http://www.youtube.com/watch?v=mZqGqE0D0n4') }
7
7
 
8
8
  its(:provider) { should == 'YouTube' }
9
+ its(:video_id) { should == 'mZqGqE0D0n4' }
9
10
  its(:url) { should == 'http://www.youtube.com/watch?v=mZqGqE0D0n4' }
10
11
  its(:title) { should == 'Cherry Bloom - King Of The Knife' }
11
12
  its(:description) { should == 'The first video from the upcoming album Secret Sounds, to download in-stores April 14. Checkout http://www.cherrybloom.net' }
@@ -23,6 +24,7 @@ describe "VideoInfo" do
23
24
  subject { VideoInfo.new('http://www.vimeo.com/898029') }
24
25
 
25
26
  its(:provider) { should == 'Vimeo' }
27
+ its(:video_id) { should == '898029' }
26
28
  its(:url) { should == 'http://vimeo.com/898029' }
27
29
  its(:title) { should == 'Cherry Bloom - King Of The Knife' }
28
30
  its(:description) { should == 'The first video from the upcoming album Secret Sounds, to download in-stores April 14. Checkout http://www.cherrybloom.net' }
data/video_info.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{video_info}
8
- s.version = "0.2.0"
8
+ s.version = "0.2.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Thibaud Guillaume-Gentil"]
@@ -23,9 +23,8 @@ Gem::Specification.new do |s|
23
23
  "Rakefile",
24
24
  "VERSION",
25
25
  "init.rb",
26
- "lib/video.rb",
27
- "lib/video/vimeo.rb",
28
- "lib/video/youtube.rb",
26
+ "lib/provider/vimeo.rb",
27
+ "lib/provider/youtube.rb",
29
28
  "lib/video_info.rb",
30
29
  "spec/spec.opts",
31
30
  "spec/spec_helper.rb",
@@ -48,14 +47,14 @@ Gem::Specification.new do |s|
48
47
 
49
48
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
50
49
  s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
51
- s.add_runtime_dependency(%q<hpricot>, [">= 0.8.1"])
50
+ s.add_runtime_dependency(%q<hpricot>, [">= 0.8.2"])
52
51
  else
53
52
  s.add_dependency(%q<rspec>, [">= 1.2.9"])
54
- s.add_dependency(%q<hpricot>, [">= 0.8.1"])
53
+ s.add_dependency(%q<hpricot>, [">= 0.8.2"])
55
54
  end
56
55
  else
57
56
  s.add_dependency(%q<rspec>, [">= 1.2.9"])
58
- s.add_dependency(%q<hpricot>, [">= 0.8.1"])
57
+ s.add_dependency(%q<hpricot>, [">= 0.8.2"])
59
58
  end
60
59
  end
61
60
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: video_info
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thibaud Guillaume-Gentil
@@ -30,7 +30,7 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 0.8.1
33
+ version: 0.8.2
34
34
  version:
35
35
  description: Get video info from youtube and vimeo url.
36
36
  email: thibaud@thibaud.me
@@ -48,9 +48,8 @@ files:
48
48
  - Rakefile
49
49
  - VERSION
50
50
  - init.rb
51
- - lib/video.rb
52
- - lib/video/vimeo.rb
53
- - lib/video/youtube.rb
51
+ - lib/provider/vimeo.rb
52
+ - lib/provider/youtube.rb
54
53
  - lib/video_info.rb
55
54
  - spec/spec.opts
56
55
  - spec/spec_helper.rb
data/lib/video.rb DELETED
@@ -1,5 +0,0 @@
1
- class Video
2
- attr_accessor :url, :id, :provider, :title, :description, :keywords,
3
- :duration, :date, :width, :height,
4
- :thumbnail_small, :thumbnail_large
5
- end