video_info 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +1 -1
- data/README.rdoc +4 -22
- data/lib/provider/vimeo.rb +3 -1
- data/lib/provider/youtube.rb +3 -1
- data/lib/video_info/version.rb +3 -0
- metadata +78 -37
- data/.gitignore +0 -21
- data/Rakefile +0 -46
- data/VERSION +0 -1
- data/init.rb +0 -0
- data/spec/spec.opts +0 -1
- data/spec/spec_helper.rb +0 -10
- data/spec/video_info_spec.rb +0 -69
- data/video_info.gemspec +0 -60
data/LICENSE
CHANGED
data/README.rdoc
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
= VideoInfo
|
2
2
|
|
3
3
|
Small Ruby Gem to get video info from youtube and vimeo url.
|
4
|
+
Tested on Ruby 1.8.6, 1.8.7 & 1.9.2
|
4
5
|
|
5
6
|
== Install
|
6
7
|
|
7
|
-
gem install video_info
|
8
|
+
gem install video_info
|
8
9
|
|
9
10
|
== Usage
|
10
11
|
|
@@ -38,25 +39,6 @@ Small Ruby Gem to get video info from youtube and vimeo url.
|
|
38
39
|
|
39
40
|
video.valid? => false
|
40
41
|
|
41
|
-
==
|
42
|
+
== Author
|
42
43
|
|
43
|
-
|
44
|
-
|
45
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
46
|
-
a copy of this software and associated documentation files (the
|
47
|
-
"Software"), to deal in the Software without restriction, including
|
48
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
49
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
50
|
-
permit persons to whom the Software is furnished to do so, subject to
|
51
|
-
the following conditions:
|
52
|
-
|
53
|
-
The above copyright notice and this permission notice shall be
|
54
|
-
included in all copies or substantial portions of the Software.
|
55
|
-
|
56
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
57
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
58
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
59
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
60
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
61
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
62
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
44
|
+
Thibaud Guillaume-Gentil
|
data/lib/provider/vimeo.rb
CHANGED
@@ -4,7 +4,8 @@ require 'open-uri'
|
|
4
4
|
class Vimeo
|
5
5
|
attr_accessor :video_id, :url, :provider, :title, :description, :keywords,
|
6
6
|
:duration, :date, :width, :height,
|
7
|
-
:thumbnail_small, :thumbnail_large
|
7
|
+
:thumbnail_small, :thumbnail_large,
|
8
|
+
:view_count
|
8
9
|
|
9
10
|
def initialize(url)
|
10
11
|
@video_id = url.gsub(/.*\.com\/([0-9]+).*$/i, '\1')
|
@@ -26,6 +27,7 @@ private
|
|
26
27
|
@date = Time.parse(doc.search("upload_date").inner_text, Time.now.utc)
|
27
28
|
@thumbnail_small = doc.search("thumbnail_small").inner_text
|
28
29
|
@thumbnail_large = doc.search("thumbnail_large").inner_text
|
30
|
+
@view_count = doc.search("stats_number_of_plays").inner_text.to_i
|
29
31
|
end
|
30
32
|
|
31
33
|
end
|
data/lib/provider/youtube.rb
CHANGED
@@ -4,7 +4,8 @@ require 'open-uri'
|
|
4
4
|
class Youtube
|
5
5
|
attr_accessor :video_id, :url, :provider, :title, :description, :keywords,
|
6
6
|
:duration, :date, :width, :height,
|
7
|
-
:thumbnail_small, :thumbnail_large
|
7
|
+
:thumbnail_small, :thumbnail_large,
|
8
|
+
:view_count
|
8
9
|
|
9
10
|
def initialize(url)
|
10
11
|
@video_id = url.gsub(/.*v=([^&]+).*$/i, '\1')
|
@@ -24,6 +25,7 @@ private
|
|
24
25
|
@date = Time.parse(doc.search("published").inner_text, Time.now.utc)
|
25
26
|
@thumbnail_small = doc.search("media:thumbnail").first[:url]
|
26
27
|
@thumbnail_large = doc.search("media:thumbnail").last[:url]
|
28
|
+
@view_count = doc.search("yt:statistics").first[:viewcount].to_i
|
27
29
|
end
|
28
30
|
|
29
31
|
end
|
metadata
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: video_info
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 2
|
8
|
+
- 3
|
9
|
+
version: 0.2.3
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- Thibaud Guillaume-Gentil
|
@@ -9,80 +14,116 @@ autorequire:
|
|
9
14
|
bindir: bin
|
10
15
|
cert_chain: []
|
11
16
|
|
12
|
-
date:
|
17
|
+
date: 2010-12-20 00:00:00 +01:00
|
13
18
|
default_executable:
|
14
19
|
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: bundler
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ~>
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 1
|
30
|
+
- 0
|
31
|
+
- 7
|
32
|
+
version: 1.0.7
|
33
|
+
type: :development
|
34
|
+
version_requirements: *id001
|
15
35
|
- !ruby/object:Gem::Dependency
|
16
36
|
name: rspec
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
segments:
|
44
|
+
- 2
|
45
|
+
- 3
|
46
|
+
- 0
|
47
|
+
version: 2.3.0
|
17
48
|
type: :development
|
18
|
-
|
19
|
-
|
49
|
+
version_requirements: *id002
|
50
|
+
- !ruby/object:Gem::Dependency
|
51
|
+
name: guard-rspec
|
52
|
+
prerelease: false
|
53
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
20
55
|
requirements:
|
21
|
-
- -
|
56
|
+
- - ~>
|
22
57
|
- !ruby/object:Gem::Version
|
23
|
-
|
24
|
-
|
58
|
+
segments:
|
59
|
+
- 0
|
60
|
+
- 1
|
61
|
+
- 9
|
62
|
+
version: 0.1.9
|
63
|
+
type: :development
|
64
|
+
version_requirements: *id003
|
25
65
|
- !ruby/object:Gem::Dependency
|
26
66
|
name: hpricot
|
27
|
-
|
28
|
-
|
29
|
-
|
67
|
+
prerelease: false
|
68
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
69
|
+
none: false
|
30
70
|
requirements:
|
31
|
-
- -
|
71
|
+
- - ~>
|
32
72
|
- !ruby/object:Gem::Version
|
33
|
-
|
34
|
-
|
73
|
+
segments:
|
74
|
+
- 0
|
75
|
+
- 8
|
76
|
+
- 3
|
77
|
+
version: 0.8.3
|
78
|
+
type: :runtime
|
79
|
+
version_requirements: *id004
|
35
80
|
description: Get video info from youtube and vimeo url.
|
36
|
-
email:
|
81
|
+
email:
|
82
|
+
- thibaud@thibaud.me
|
37
83
|
executables: []
|
38
84
|
|
39
85
|
extensions: []
|
40
86
|
|
41
|
-
extra_rdoc_files:
|
42
|
-
|
43
|
-
- README.rdoc
|
87
|
+
extra_rdoc_files: []
|
88
|
+
|
44
89
|
files:
|
45
|
-
- .gitignore
|
46
|
-
- LICENSE
|
47
|
-
- README.rdoc
|
48
|
-
- Rakefile
|
49
|
-
- VERSION
|
50
|
-
- init.rb
|
51
90
|
- lib/provider/vimeo.rb
|
52
91
|
- lib/provider/youtube.rb
|
92
|
+
- lib/video_info/version.rb
|
53
93
|
- lib/video_info.rb
|
54
|
-
-
|
55
|
-
-
|
56
|
-
- spec/video_info_spec.rb
|
57
|
-
- video_info.gemspec
|
94
|
+
- LICENSE
|
95
|
+
- README.rdoc
|
58
96
|
has_rdoc: true
|
59
|
-
homepage: http://
|
97
|
+
homepage: http://rubygems.org/gems/video_info
|
60
98
|
licenses: []
|
61
99
|
|
62
100
|
post_install_message:
|
63
|
-
rdoc_options:
|
64
|
-
|
101
|
+
rdoc_options: []
|
102
|
+
|
65
103
|
require_paths:
|
66
104
|
- lib
|
67
105
|
required_ruby_version: !ruby/object:Gem::Requirement
|
106
|
+
none: false
|
68
107
|
requirements:
|
69
108
|
- - ">="
|
70
109
|
- !ruby/object:Gem::Version
|
110
|
+
segments:
|
111
|
+
- 0
|
71
112
|
version: "0"
|
72
|
-
version:
|
73
113
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
114
|
+
none: false
|
74
115
|
requirements:
|
75
116
|
- - ">="
|
76
117
|
- !ruby/object:Gem::Version
|
118
|
+
segments:
|
119
|
+
- 0
|
77
120
|
version: "0"
|
78
|
-
version:
|
79
121
|
requirements: []
|
80
122
|
|
81
|
-
rubyforge_project:
|
82
|
-
rubygems_version: 1.3.
|
123
|
+
rubyforge_project: video_info
|
124
|
+
rubygems_version: 1.3.7
|
83
125
|
signing_key:
|
84
126
|
specification_version: 3
|
85
127
|
summary: Vimeo & Youtube parser
|
86
|
-
test_files:
|
87
|
-
|
88
|
-
- spec/video_info_spec.rb
|
128
|
+
test_files: []
|
129
|
+
|
data/.gitignore
DELETED
data/Rakefile
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'rake'
|
3
|
-
|
4
|
-
begin
|
5
|
-
require 'jeweler'
|
6
|
-
Jeweler::Tasks.new do |gem|
|
7
|
-
gem.name = "video_info"
|
8
|
-
gem.summary = "Vimeo & Youtube parser"
|
9
|
-
gem.description = "Get video info from youtube and vimeo url."
|
10
|
-
gem.email = "thibaud@thibaud.me"
|
11
|
-
gem.homepage = "http://github.com/guillaumegentil/video_info"
|
12
|
-
gem.authors = ["Thibaud Guillaume-Gentil"]
|
13
|
-
gem.add_development_dependency "rspec", ">= 1.2.9"
|
14
|
-
gem.add_dependency "hpricot", ">= 0.8.2"
|
15
|
-
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
16
|
-
end
|
17
|
-
Jeweler::GemcutterTasks.new
|
18
|
-
rescue LoadError
|
19
|
-
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
20
|
-
end
|
21
|
-
|
22
|
-
require 'spec/rake/spectask'
|
23
|
-
Spec::Rake::SpecTask.new(:spec) do |spec|
|
24
|
-
spec.libs << 'lib' << 'spec'
|
25
|
-
spec.spec_files = FileList['spec/**/*_spec.rb']
|
26
|
-
end
|
27
|
-
|
28
|
-
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
29
|
-
spec.libs << 'lib' << 'spec'
|
30
|
-
spec.pattern = 'spec/**/*_spec.rb'
|
31
|
-
spec.rcov = true
|
32
|
-
end
|
33
|
-
|
34
|
-
task :spec => :check_dependencies
|
35
|
-
|
36
|
-
task :default => :spec
|
37
|
-
|
38
|
-
require 'rake/rdoctask'
|
39
|
-
Rake::RDocTask.new do |rdoc|
|
40
|
-
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
41
|
-
|
42
|
-
rdoc.rdoc_dir = 'rdoc'
|
43
|
-
rdoc.title = "video_info #{version}"
|
44
|
-
rdoc.rdoc_files.include('README*')
|
45
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
46
|
-
end
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.2.2
|
data/init.rb
DELETED
File without changes
|
data/spec/spec.opts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
--color
|
data/spec/spec_helper.rb
DELETED
data/spec/video_info_spec.rb
DELETED
@@ -1,69 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
-
|
3
|
-
describe "VideoInfo" do
|
4
|
-
|
5
|
-
describe "from Youtube" do
|
6
|
-
subject { VideoInfo.new('http://www.youtube.com/watch?v=mZqGqE0D0n4') }
|
7
|
-
|
8
|
-
its(:provider) { should == 'YouTube' }
|
9
|
-
its(:video_id) { should == 'mZqGqE0D0n4' }
|
10
|
-
its(:url) { should == 'http://www.youtube.com/watch?v=mZqGqE0D0n4' }
|
11
|
-
its(:title) { should == 'Cherry Bloom - King Of The Knife' }
|
12
|
-
its(:description) { should == 'The first video from the upcoming album Secret Sounds, to download in-stores April 14. Checkout http://www.cherrybloom.net' }
|
13
|
-
its(:keywords) { should == 'cherry, bloom, king, of, the, knife, guitar, drum, clip, rock, alternative, tremplin, Paris-Forum' }
|
14
|
-
its(:duration) { should == 175 }
|
15
|
-
its(:width) { should be_nil }
|
16
|
-
its(:height) { should be_nil }
|
17
|
-
its(:date) { should == Time.parse('Sat Apr 12 22:25:35 UTC 2008') }
|
18
|
-
its(:thumbnail_small) { should == 'http://i.ytimg.com/vi/mZqGqE0D0n4/2.jpg' }
|
19
|
-
its(:thumbnail_large) { should == 'http://i.ytimg.com/vi/mZqGqE0D0n4/0.jpg' }
|
20
|
-
it { should be_valid }
|
21
|
-
end
|
22
|
-
|
23
|
-
describe "from Youtube" do
|
24
|
-
subject { VideoInfo.new('http://www.youtube.com/watch?v=JM9NgvjjVng') }
|
25
|
-
|
26
|
-
its(:provider) { should == 'YouTube' }
|
27
|
-
its(:duration) { should == 217 }
|
28
|
-
it { should be_valid }
|
29
|
-
end
|
30
|
-
|
31
|
-
describe "from Vimeo" do
|
32
|
-
subject { VideoInfo.new('http://www.vimeo.com/898029') }
|
33
|
-
|
34
|
-
its(:provider) { should == 'Vimeo' }
|
35
|
-
its(:video_id) { should == '898029' }
|
36
|
-
its(:url) { should == 'http://vimeo.com/898029' }
|
37
|
-
its(:title) { should == 'Cherry Bloom - King Of The Knife' }
|
38
|
-
its(:description) { should == 'The first video from the upcoming album Secret Sounds, to download in-stores April 14. Checkout http://www.cherrybloom.net' }
|
39
|
-
its(:keywords) { should == 'cherry bloom, secret sounds, king of the knife, rock, alternative' }
|
40
|
-
its(:duration) { should == 175 }
|
41
|
-
its(:width) { should == 640 }
|
42
|
-
its(:height) { should == 360 }
|
43
|
-
its(:date) { should == Time.parse('Mon Apr 14 13:10:39 +0200 2008') }
|
44
|
-
its(:thumbnail_small) { should == 'http://ts.vimeo.com.s3.amazonaws.com/343/731/34373130_100.jpg' }
|
45
|
-
its(:thumbnail_large) { should == 'http://ts.vimeo.com.s3.amazonaws.com/343/731/34373130_640.jpg' }
|
46
|
-
it { should be_valid }
|
47
|
-
end
|
48
|
-
|
49
|
-
it "should be invalid with misstaped url" do
|
50
|
-
video = VideoInfo.new('http://www.vimeo.com/1')
|
51
|
-
video.should_not be_valid
|
52
|
-
end
|
53
|
-
|
54
|
-
it "should be invalid with bad url" do
|
55
|
-
video = VideoInfo.new('http://www.yasda.com/asdasd')
|
56
|
-
video.should_not be_valid
|
57
|
-
end
|
58
|
-
|
59
|
-
it "should be invalid with blank url" do
|
60
|
-
video = VideoInfo.new('')
|
61
|
-
video.should_not be_valid
|
62
|
-
end
|
63
|
-
|
64
|
-
it "should be invalid with nil url" do
|
65
|
-
video = VideoInfo.new(nil)
|
66
|
-
video.should_not be_valid
|
67
|
-
end
|
68
|
-
|
69
|
-
end
|
data/video_info.gemspec
DELETED
@@ -1,60 +0,0 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
-
# -*- encoding: utf-8 -*-
|
5
|
-
|
6
|
-
Gem::Specification.new do |s|
|
7
|
-
s.name = %q{video_info}
|
8
|
-
s.version = "0.2.2"
|
9
|
-
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["Thibaud Guillaume-Gentil"]
|
12
|
-
s.date = %q{2009-12-04}
|
13
|
-
s.description = %q{Get video info from youtube and vimeo url.}
|
14
|
-
s.email = %q{thibaud@thibaud.me}
|
15
|
-
s.extra_rdoc_files = [
|
16
|
-
"LICENSE",
|
17
|
-
"README.rdoc"
|
18
|
-
]
|
19
|
-
s.files = [
|
20
|
-
".gitignore",
|
21
|
-
"LICENSE",
|
22
|
-
"README.rdoc",
|
23
|
-
"Rakefile",
|
24
|
-
"VERSION",
|
25
|
-
"init.rb",
|
26
|
-
"lib/provider/vimeo.rb",
|
27
|
-
"lib/provider/youtube.rb",
|
28
|
-
"lib/video_info.rb",
|
29
|
-
"spec/spec.opts",
|
30
|
-
"spec/spec_helper.rb",
|
31
|
-
"spec/video_info_spec.rb",
|
32
|
-
"video_info.gemspec"
|
33
|
-
]
|
34
|
-
s.homepage = %q{http://github.com/guillaumegentil/video_info}
|
35
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
36
|
-
s.require_paths = ["lib"]
|
37
|
-
s.rubygems_version = %q{1.3.5}
|
38
|
-
s.summary = %q{Vimeo & Youtube parser}
|
39
|
-
s.test_files = [
|
40
|
-
"spec/spec_helper.rb",
|
41
|
-
"spec/video_info_spec.rb"
|
42
|
-
]
|
43
|
-
|
44
|
-
if s.respond_to? :specification_version then
|
45
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
46
|
-
s.specification_version = 3
|
47
|
-
|
48
|
-
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
49
|
-
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
50
|
-
s.add_runtime_dependency(%q<hpricot>, [">= 0.8.2"])
|
51
|
-
else
|
52
|
-
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
53
|
-
s.add_dependency(%q<hpricot>, [">= 0.8.2"])
|
54
|
-
end
|
55
|
-
else
|
56
|
-
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
57
|
-
s.add_dependency(%q<hpricot>, [">= 0.8.2"])
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|