video_info 0.2.6 → 0.2.7

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/README.md ADDED
@@ -0,0 +1,52 @@
1
+ VideoInfo [![Build Status](https://secure.travis-ci.org/thibaudgg/video_info.png?branch=master)](http://travis-ci.org/thibaudgg/video_info)
2
+ =========
3
+
4
+ Small Ruby Gem to get video info from youtube and vimeo url.
5
+ Tested against Ruby 1.8.7, 1.9.2, REE and the latest versions of JRuby & Rubinius.
6
+
7
+ Install
8
+ --------
9
+
10
+ ``` bash
11
+ gem install video_info
12
+ ```
13
+
14
+ Usage
15
+ -----
16
+
17
+ ``` ruby
18
+ video = VideoInfo.new("http://www.youtube.com/watch?v=mZqGqE0D0n4")
19
+
20
+ # video.video_id => "mZqGqE0D0n4"
21
+ # video.provider => "YouTube"
22
+ # video.title => "Cherry Bloom - King Of The Knife"
23
+ # video.description => "The first video from the upcoming album Secret Sounds, to download in-stores April 14. Checkout http://www.cherrybloom.net"
24
+ # video.keywords => "alternative, bloom, cherry, clip, drum, guitar, king, knife, of, Paris-Forum, rock, the, tremplin"
25
+ # video.duration => 175 (in seconds)
26
+ # video.date => Sat Apr 12 22:25:35 UTC 2008
27
+ # video.thumbnail_small => "http://i.ytimg.com/vi/mZqGqE0D0n4/2.jpg"
28
+ # video.thumbnail_large => "http://i.ytimg.com/vi/mZqGqE0D0n4/0.jpg"
29
+
30
+ video = VideoInfo.new("http://vimeo.com/898029")
31
+
32
+ # video.video_id => "898029"
33
+ # video.provider => "Vimeo"
34
+ # video.title => "Cherry Bloom - King Of The Knife"
35
+ # video.description => "The first video from the upcoming album Secret Sounds, to download in-stores April 14. Checkout http://www.cherrybloom.net"
36
+ # video.keywords => "alternative, bloom, cherry, clip, drum, guitar, king, knife, of, Paris-Forum, rock, the, tremplin"
37
+ # video.duration => 175 (in seconds)
38
+ # video.date => Mon Apr 14 13:10:39 +0200 2008
39
+ # video.width => 640
40
+ # video.height => 360
41
+ # video.thumbnail_small => "http://ts.vimeo.com.s3.amazonaws.com/343/731/34373130_100.jpg"
42
+ # video.thumbnail_large => "http://ts.vimeo.com.s3.amazonaws.com/343/731/34373130_640.jpg"
43
+
44
+ video = VideoInfo.new("http://badurl.com/898029")
45
+
46
+ # video.valid? => false
47
+ ```
48
+
49
+ Author
50
+ ------
51
+
52
+ [Thibaud Guillaume-Gentil](https://github.com/thibaudgg) ([@thibaudgg](http://twitter.com/thibaudgg))
@@ -1,33 +1,33 @@
1
- require 'hpricot'
2
- require 'open-uri'
3
-
4
- class Vimeo
5
- attr_accessor :video_id, :url, :provider, :title, :description, :keywords,
6
- :duration, :date, :width, :height,
7
- :thumbnail_small, :thumbnail_large,
8
- :view_count
9
-
10
- def initialize(url)
11
- @video_id = url.gsub(/.*\.com\/([0-9]+).*$/i, '\1')
12
- get_info unless @video_id == url
13
- end
14
-
15
- private
16
-
17
- def get_info
18
- doc = Hpricot(open("http://vimeo.com/api/v2/video/#{@video_id}.xml"))
19
- @provider = "Vimeo"
20
- @url = doc.search("url").inner_text
21
- @title = doc.search("title").inner_text
22
- @description = doc.search("description").inner_text
23
- @keywords = doc.search("tags").inner_text
24
- @duration = doc.search("duration").inner_text.to_i # seconds
25
- @width = doc.search("width").inner_text.to_i
26
- @height = doc.search("height").inner_text.to_i
27
- @date = Time.parse(doc.search("upload_date").inner_text, Time.now.utc)
28
- @thumbnail_small = doc.search("thumbnail_small").inner_text
29
- @thumbnail_large = doc.search("thumbnail_large").inner_text
30
- @view_count = doc.search("stats_number_of_plays").inner_text.to_i
31
- end
32
-
1
+ require 'hpricot'
2
+ require 'open-uri'
3
+
4
+ class Vimeo
5
+ attr_accessor :video_id, :url, :provider, :title, :description, :keywords,
6
+ :duration, :date, :width, :height,
7
+ :thumbnail_small, :thumbnail_large,
8
+ :view_count
9
+
10
+ def initialize(url)
11
+ @video_id = url.gsub(/.*\.com\/(?:groups\/[^\/]+\/videos\/)?([0-9]+).*$/i, '\1')
12
+ get_info unless @video_id == url
13
+ end
14
+
15
+ private
16
+
17
+ def get_info
18
+ doc = Hpricot(open("http://vimeo.com/api/v2/video/#{@video_id}.xml"))
19
+ @provider = "Vimeo"
20
+ @url = doc.search("url").inner_text
21
+ @title = doc.search("title").inner_text
22
+ @description = doc.search("description").inner_text
23
+ @keywords = doc.search("tags").inner_text
24
+ @duration = doc.search("duration").inner_text.to_i # seconds
25
+ @width = doc.search("width").inner_text.to_i
26
+ @height = doc.search("height").inner_text.to_i
27
+ @date = Time.parse(doc.search("upload_date").inner_text, Time.now.utc).utc
28
+ @thumbnail_small = doc.search("thumbnail_small").inner_text
29
+ @thumbnail_large = doc.search("thumbnail_large").inner_text
30
+ @view_count = doc.search("stats_number_of_plays").inner_text.to_i
31
+ end
32
+
33
33
  end
@@ -1,3 +1,3 @@
1
1
  module VideoInfoVersion
2
- VERSION = "0.2.6"
2
+ VERSION = "0.2.7"
3
3
  end
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.6
4
+ version: 0.2.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-10-25 00:00:00.000000000Z
12
+ date: 2011-11-13 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: hpricot
16
- requirement: &70127803224080 !ruby/object:Gem::Requirement
16
+ requirement: &70190131499240 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 0.8.4
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70127803224080
24
+ version_requirements: *70190131499240
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: bundler
27
- requirement: &70127803223600 !ruby/object:Gem::Requirement
27
+ requirement: &70190131497380 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70127803223600
35
+ version_requirements: *70190131497380
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &70127803222800 !ruby/object:Gem::Requirement
38
+ requirement: &70190131491960 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 2.7.0
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70127803222800
46
+ version_requirements: *70190131491960
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: guard-rspec
49
- requirement: &70127803222080 !ruby/object:Gem::Requirement
49
+ requirement: &70190131490300 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70127803222080
57
+ version_requirements: *70190131490300
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: webmock
60
- requirement: &70127803220980 !ruby/object:Gem::Requirement
60
+ requirement: &70190131482420 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70127803220980
68
+ version_requirements: *70190131482420
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: vcr
71
- requirement: &70127803208580 !ruby/object:Gem::Requirement
71
+ requirement: &70190131475840 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,7 +76,7 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70127803208580
79
+ version_requirements: *70190131475840
80
80
  description: Get video info from youtube and vimeo url.
81
81
  email:
82
82
  - thibaud@thibaud.me
@@ -89,7 +89,7 @@ files:
89
89
  - lib/video_info/version.rb
90
90
  - lib/video_info.rb
91
91
  - LICENSE
92
- - README.rdoc
92
+ - README.md
93
93
  homepage: http://rubygems.org/gems/video_info
94
94
  licenses: []
95
95
  post_install_message:
@@ -102,12 +102,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
102
102
  - - ! '>='
103
103
  - !ruby/object:Gem::Version
104
104
  version: '0'
105
+ segments:
106
+ - 0
107
+ hash: -4408431295325630864
105
108
  required_rubygems_version: !ruby/object:Gem::Requirement
106
109
  none: false
107
110
  requirements:
108
111
  - - ! '>='
109
112
  - !ruby/object:Gem::Version
110
113
  version: '0'
114
+ segments:
115
+ - 0
116
+ hash: -4408431295325630864
111
117
  requirements: []
112
118
  rubyforge_project: video_info
113
119
  rubygems_version: 1.8.9
@@ -115,4 +121,3 @@ signing_key:
115
121
  specification_version: 3
116
122
  summary: Vimeo & Youtube parser
117
123
  test_files: []
118
- has_rdoc:
data/README.rdoc DELETED
@@ -1,44 +0,0 @@
1
- = VideoInfo
2
-
3
- Small Ruby Gem to get video info from youtube and vimeo url.
4
- Tested against Ruby 1.8.7, 1.9.2, REE and the latest versions of JRuby & Rubinius.
5
-
6
- == Install
7
-
8
- gem install video_info
9
-
10
- == Usage
11
-
12
- video = VideoInfo.new("http://www.youtube.com/watch?v=mZqGqE0D0n4")
13
-
14
- video.video_id => "mZqGqE0D0n4"
15
- video.provider => "YouTube"
16
- video.title => "Cherry Bloom - King Of The Knife"
17
- video.description => "The first video from the upcoming album Secret Sounds, to download in-stores April 14. Checkout http://www.cherrybloom.net"
18
- video.keywords => "alternative, bloom, cherry, clip, drum, guitar, king, knife, of, Paris-Forum, rock, the, tremplin"
19
- video.duration => 175 (in seconds)
20
- video.date => Sat Apr 12 22:25:35 UTC 2008
21
- video.thumbnail_small => "http://i.ytimg.com/vi/mZqGqE0D0n4/2.jpg"
22
- video.thumbnail_large => "http://i.ytimg.com/vi/mZqGqE0D0n4/0.jpg"
23
-
24
- video = VideoInfo.new("http://vimeo.com/898029")
25
-
26
- video.video_id => "898029"
27
- video.provider => "Vimeo"
28
- video.title => "Cherry Bloom - King Of The Knife"
29
- video.description => "The first video from the upcoming album Secret Sounds, to download in-stores April 14. Checkout http://www.cherrybloom.net"
30
- video.keywords => "alternative, bloom, cherry, clip, drum, guitar, king, knife, of, Paris-Forum, rock, the, tremplin"
31
- video.duration => 175 (in seconds)
32
- video.date => Mon Apr 14 13:10:39 +0200 2008
33
- video.width => 640
34
- video.height => 360
35
- video.thumbnail_small => "http://ts.vimeo.com.s3.amazonaws.com/343/731/34373130_100.jpg"
36
- video.thumbnail_large => "http://ts.vimeo.com.s3.amazonaws.com/343/731/34373130_640.jpg"
37
-
38
- video = VideoInfo.new("http://badurl.com/898029")
39
-
40
- video.valid? => false
41
-
42
- == Author
43
-
44
- Thibaud Guillaume-Gentil