video_info 0.2.0 → 0.2.1
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/Rakefile +1 -1
- data/VERSION +1 -1
- data/lib/{video → provider}/vimeo.rb +7 -4
- data/lib/{video → provider}/youtube.rb +8 -5
- data/lib/video_info.rb +3 -20
- data/spec/spec_helper.rb +1 -0
- data/spec/video_info_spec.rb +2 -0
- data/video_info.gemspec +6 -7
- metadata +4 -5
- data/lib/video.rb +0 -5
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.
|
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.
|
1
|
+
0.2.1
|
@@ -1,17 +1,20 @@
|
|
1
1
|
require 'hpricot'
|
2
2
|
require 'open-uri'
|
3
3
|
|
4
|
-
class Vimeo
|
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
|
-
@
|
8
|
-
get_info unless @
|
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/#{@
|
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
|
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
|
-
@
|
8
|
-
get_info unless @
|
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/#{@
|
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=#{@
|
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 '
|
2
|
-
require '
|
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}&server=vimeo.com&show_title=#{show_title}&show_byline=#{show_byline}&show_portrait=#{show_portrait}&color=00adef&fullscreen=#{fullscreen}" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=#{vimeo_id}&server=vimeo.com&show_title=#{show_title}&show_byline=#{show_byline}&show_portrait=#{show_portrait}&color=00adef&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
data/spec/video_info_spec.rb
CHANGED
@@ -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.
|
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/
|
27
|
-
"lib/
|
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.
|
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.
|
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.
|
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.
|
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.
|
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/
|
52
|
-
- lib/
|
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
|