video_info 0.2.4 → 0.2.5

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.
@@ -6,14 +6,14 @@ class Youtube
6
6
  :duration, :date, :width, :height,
7
7
  :thumbnail_small, :thumbnail_large,
8
8
  :view_count
9
-
9
+
10
10
  def initialize(url)
11
11
  @video_id = url.gsub(/.*v=([^&]+).*$/i, '\1')
12
12
  get_info unless @video_id == url
13
13
  end
14
-
14
+
15
15
  private
16
-
16
+
17
17
  def get_info
18
18
  doc = Hpricot(open("http://gdata.youtube.com/feeds/api/videos/#{@video_id}"))
19
19
  @provider = "YouTube"
@@ -23,15 +23,15 @@ private
23
23
  @keywords = doc.search("media:keywords").inner_text
24
24
  @duration = doc.search("yt:duration").first[:seconds].to_i
25
25
  @date = Time.parse(doc.search("published").inner_text, Time.now.utc)
26
- @thumbnail_small = doc.search("media:thumbnail").first[:url]
27
- @thumbnail_large = doc.search("media:thumbnail").last[:url]
26
+ @thumbnail_small = doc.search("media:thumbnail").min { |a,b| a[:height].to_i * a[:width].to_i <=> b[:height].to_i * b[:width].to_i }[:url]
27
+ @thumbnail_large = doc.search("media:thumbnail").max { |a,b| a[:height].to_i * a[:width].to_i <=> b[:height].to_i * b[:width].to_i }[:url]
28
28
  # when your video still has no view, yt:statistics is not returned by Youtube
29
29
  # see: https://github.com/thibaudgg/video_info/issues#issue/2
30
30
  if doc.search("yt:statistics").first
31
31
  @view_count = doc.search("yt:statistics").first[:viewcount].to_i
32
32
  else
33
- @view_count = 0
33
+ @view_count = 0
34
34
  end
35
35
  end
36
-
36
+
37
37
  end
@@ -1,3 +1,3 @@
1
1
  module VideoInfoVersion
2
- VERSION = "0.2.4"
2
+ VERSION = "0.2.5"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: video_info
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 29
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 4
10
- version: 0.2.4
9
+ - 5
10
+ version: 0.2.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Thibaud Guillaume-Gentil
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-01-13 00:00:00 +01:00
18
+ date: 2011-04-17 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -24,14 +24,12 @@ dependencies:
24
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
25
  none: false
26
26
  requirements:
27
- - - ~>
27
+ - - ">="
28
28
  - !ruby/object:Gem::Version
29
- hash: 25
29
+ hash: 3
30
30
  segments:
31
- - 1
32
31
  - 0
33
- - 7
34
- version: 1.0.7
32
+ version: "0"
35
33
  type: :development
36
34
  version_requirements: *id001
37
35
  - !ruby/object:Gem::Dependency
@@ -40,7 +38,7 @@ dependencies:
40
38
  requirement: &id002 !ruby/object:Gem::Requirement
41
39
  none: false
42
40
  requirements:
43
- - - ~>
41
+ - - ">="
44
42
  - !ruby/object:Gem::Version
45
43
  hash: 31
46
44
  segments:
@@ -56,46 +54,40 @@ dependencies:
56
54
  requirement: &id003 !ruby/object:Gem::Requirement
57
55
  none: false
58
56
  requirements:
59
- - - ~>
57
+ - - ">="
60
58
  - !ruby/object:Gem::Version
61
- hash: 9
59
+ hash: 3
62
60
  segments:
63
61
  - 0
64
- - 1
65
- - 9
66
- version: 0.1.9
62
+ version: "0"
67
63
  type: :development
68
64
  version_requirements: *id003
69
65
  - !ruby/object:Gem::Dependency
70
- name: vcr
66
+ name: webmock
71
67
  prerelease: false
72
68
  requirement: &id004 !ruby/object:Gem::Requirement
73
69
  none: false
74
70
  requirements:
75
- - - ~>
71
+ - - ">="
76
72
  - !ruby/object:Gem::Version
77
73
  hash: 3
78
74
  segments:
79
- - 1
80
- - 5
81
75
  - 0
82
- version: 1.5.0
76
+ version: "0"
83
77
  type: :development
84
78
  version_requirements: *id004
85
79
  - !ruby/object:Gem::Dependency
86
- name: webmock
80
+ name: vcr
87
81
  prerelease: false
88
82
  requirement: &id005 !ruby/object:Gem::Requirement
89
83
  none: false
90
84
  requirements:
91
- - - ~>
85
+ - - ">="
92
86
  - !ruby/object:Gem::Version
93
- hash: 11
87
+ hash: 3
94
88
  segments:
95
- - 1
96
- - 6
97
- - 2
98
- version: 1.6.2
89
+ - 0
90
+ version: "0"
99
91
  type: :development
100
92
  version_requirements: *id005
101
93
  - !ruby/object:Gem::Dependency
@@ -106,12 +98,12 @@ dependencies:
106
98
  requirements:
107
99
  - - ~>
108
100
  - !ruby/object:Gem::Version
109
- hash: 57
101
+ hash: 55
110
102
  segments:
111
103
  - 0
112
104
  - 8
113
- - 3
114
- version: 0.8.3
105
+ - 4
106
+ version: 0.8.4
115
107
  type: :runtime
116
108
  version_requirements: *id006
117
109
  description: Get video info from youtube and vimeo url.