video_info 2.0.0 → 2.0.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.
Files changed (27) hide show
  1. checksums.yaml +4 -4
  2. data/lib/video_info/provider.rb +2 -0
  3. data/lib/video_info/providers/vimeo.rb +0 -3
  4. data/lib/video_info/providers/vkontakte.rb +5 -16
  5. data/lib/video_info/providers/youtube.rb +0 -3
  6. data/lib/video_info/version.rb +1 -1
  7. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_39576223_108370515/description/.yml +41 -0
  8. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_39576223_108370515/duration/.yml +41 -0
  9. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_39576223_108370515/embed_code/.yml +41 -0
  10. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_39576223_108370515/embed_url/.yml +41 -0
  11. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_39576223_108370515/height/.yml +41 -0
  12. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_39576223_108370515/keywords/.yml +41 -0
  13. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_39576223_108370515/title/.yml +41 -0
  14. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_39576223_108370515/view_count/.yml +41 -0
  15. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_39576223_108370515/width/.yml +41 -0
  16. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_video-54799401_165822734/title/.yml +1777 -0
  17. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_video39576223_108370515/description/.yml +1165 -0
  18. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_video39576223_108370515/duration/.yml +1165 -0
  19. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_video39576223_108370515/embed_code/.yml +1165 -0
  20. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_video39576223_108370515/embed_url/.yml +1165 -0
  21. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_video39576223_108370515/height/.yml +1165 -0
  22. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_video39576223_108370515/keywords/.yml +1165 -0
  23. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_video39576223_108370515/title/.yml +1165 -0
  24. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_video39576223_108370515/view_count/.yml +1165 -0
  25. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_video39576223_108370515/width/.yml +1165 -0
  26. data/spec/lib/video_info/providers/vkontakte_spec.rb +11 -2
  27. metadata +22 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8574cb4c5ee1da037895282d4afeebaf4266f19b
4
- data.tar.gz: 65a5e6e34b10aecc9ee7e95f6ef2aa873493b7f3
3
+ metadata.gz: 408755121a9ec3c89f17e40a899758aa89066705
4
+ data.tar.gz: 19d209c4e0143e296dca691d927995b8b584db8d
5
5
  SHA512:
6
- metadata.gz: 338de9b7de8a9cac837dff5cabd23ad9643d63d50275989dc7e0fb3077b4b79bc4dc9fcc95e1bededd1371ade6bbc5d9aaed6cb570aa3cf0d984a0c43bad1f4d
7
- data.tar.gz: 91a541df1be27bfe9e2517368bb2255777e9d7cd3f9bcdd02177e8b4f21f42251b031cb192c6b4f047e1790f18c5c16db3e5a33dbcacbcd25f7d48ec1c4d1db6
6
+ metadata.gz: 6cedfd1f862e27e2cca3aa04e43614f7a0e4a4994c11d4b2cf9271f9f490e3664539ffb33c97544c43a982d6f1d328dc801f4ea367292772ad12c217a4440065
7
+ data.tar.gz: fedb5fe52034dceb7eb502e95bcd50bcab025fcce591afb466c78dddafd60225b3066fa050303fa5be1d08a821699df2f2e58b0c5e8e35925af3a215d7e3ff06
@@ -1,3 +1,5 @@
1
+ require 'open-uri'
2
+ require 'multi_json'
1
3
  require 'addressable/uri'
2
4
 
3
5
  class VideoInfo
@@ -1,6 +1,3 @@
1
- require 'open-uri'
2
- require 'multi_json'
3
-
4
1
  class VideoInfo
5
2
  module Providers
6
3
  class Vimeo < Provider
@@ -1,12 +1,5 @@
1
- # encoding: UTF-8
2
-
3
- require 'open-uri'
4
- require 'multi_json'
5
1
  require 'htmlentities'
6
-
7
- if RUBY_VERSION.to_i < 2
8
- require 'iconv'
9
- end
2
+ require 'iconv' if RUBY_VERSION.to_i < 2
10
3
 
11
4
  class VideoInfo
12
5
  module Providers
@@ -44,7 +37,7 @@ class VideoInfo
44
37
  end
45
38
 
46
39
  def view_count
47
- data[/mv_num_views\\">(\d+)/,1].to_i
40
+ data[/mv_num_views\\">.*?(\d+)/,1].to_i
48
41
  end
49
42
 
50
43
  def embed_url
@@ -58,7 +51,7 @@ class VideoInfo
58
51
  private
59
52
 
60
53
  def _set_data_from_api
61
- uri = open(_api_url, options)
54
+ uri = open(url, options)
62
55
  if RUBY_VERSION.to_i < 2
63
56
  Iconv.iconv('utf-8', 'cp1251', uri.read)[0]
64
57
  else
@@ -71,15 +64,11 @@ class VideoInfo
71
64
  end
72
65
 
73
66
  def _set_video_id_from_url
74
- url.gsub(_url_regex) { @video_owner, @video_id = ($1 || $2 || $3).split('_') }
67
+ url.gsub(_url_regex) { @video_owner, @video_id = $1.split('_') }
75
68
  end
76
69
 
77
70
  def _url_regex
78
- /(?:vkontakte\.ru\/video|vk\.com\/video)(\d+_\d+)/i
79
- end
80
-
81
- def _api_url
82
- "http://vk.com/video#{video_owner}_#{video_id}"
71
+ /(?:vkontakte\.ru\/video|vk\.com\/video)(-?\d+_\d+)/i
83
72
  end
84
73
 
85
74
  def _default_iframe_attributes
@@ -1,6 +1,3 @@
1
- require 'open-uri'
2
- require 'multi_json'
3
-
4
1
  class VideoInfo
5
2
  module Providers
6
3
  class Youtube < Provider
@@ -1,3 +1,3 @@
1
1
  class VideoInfo
2
- VERSION = '2.0.0'
2
+ VERSION = '2.0.1'
3
3
  end
@@ -1095,4 +1095,45 @@ http_interactions:
1095
1095
  c2NyaXB0Pgo8L2JvZHk+Cgo8L2h0bWw+
1096
1096
  http_version:
1097
1097
  recorded_at: Fri, 25 Oct 2013 20:34:00 GMT
1098
+ - request:
1099
+ method: get
1100
+ uri: http://vk.com/video_
1101
+ body:
1102
+ encoding: US-ASCII
1103
+ string: ''
1104
+ headers:
1105
+ User-Agent:
1106
+ - VideoInfo/2.0.0
1107
+ Accept-Encoding:
1108
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
1109
+ Accept:
1110
+ - '*/*'
1111
+ response:
1112
+ status:
1113
+ code: 404
1114
+ message: Not Found
1115
+ headers:
1116
+ Server:
1117
+ - nginx/1.2.4
1118
+ Date:
1119
+ - Sat, 26 Oct 2013 11:12:56 GMT
1120
+ Content-Type:
1121
+ - text/html
1122
+ Content-Length:
1123
+ - '397'
1124
+ Connection:
1125
+ - keep-alive
1126
+ body:
1127
+ encoding: UTF-8
1128
+ string: |
1129
+ <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
1130
+ <html><head>
1131
+ <title>404 Not Found</title>
1132
+ </head>
1133
+ <body style="background: #3f5d81 url(http://vk.me/images/error404.png) no-repeat 50% 50%; width: 100%; height: 100%; overflow: hidden;">
1134
+ <a style="position: absolute; left: 50%; top: 50%; margin: -265px -345px 0px; height: 530px; width: 690px;" href="http://vk.com/"></a>
1135
+ </body>
1136
+ </html>
1137
+ http_version:
1138
+ recorded_at: Sat, 26 Oct 2013 11:12:56 GMT
1098
1139
  recorded_with: VCR 2.6.0
@@ -1095,4 +1095,45 @@ http_interactions:
1095
1095
  c2NyaXB0Pgo8L2JvZHk+Cgo8L2h0bWw+
1096
1096
  http_version:
1097
1097
  recorded_at: Fri, 25 Oct 2013 20:34:00 GMT
1098
+ - request:
1099
+ method: get
1100
+ uri: http://vk.com/video_
1101
+ body:
1102
+ encoding: US-ASCII
1103
+ string: ''
1104
+ headers:
1105
+ User-Agent:
1106
+ - VideoInfo/2.0.0
1107
+ Accept-Encoding:
1108
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
1109
+ Accept:
1110
+ - '*/*'
1111
+ response:
1112
+ status:
1113
+ code: 404
1114
+ message: Not Found
1115
+ headers:
1116
+ Server:
1117
+ - nginx/1.2.4
1118
+ Date:
1119
+ - Sat, 26 Oct 2013 11:12:57 GMT
1120
+ Content-Type:
1121
+ - text/html
1122
+ Content-Length:
1123
+ - '397'
1124
+ Connection:
1125
+ - keep-alive
1126
+ body:
1127
+ encoding: UTF-8
1128
+ string: |
1129
+ <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
1130
+ <html><head>
1131
+ <title>404 Not Found</title>
1132
+ </head>
1133
+ <body style="background: #3f5d81 url(http://vk.me/images/error404.png) no-repeat 50% 50%; width: 100%; height: 100%; overflow: hidden;">
1134
+ <a style="position: absolute; left: 50%; top: 50%; margin: -265px -345px 0px; height: 530px; width: 690px;" href="http://vk.com/"></a>
1135
+ </body>
1136
+ </html>
1137
+ http_version:
1138
+ recorded_at: Sat, 26 Oct 2013 11:12:57 GMT
1098
1139
  recorded_with: VCR 2.6.0
@@ -1095,4 +1095,45 @@ http_interactions:
1095
1095
  L3NjcmlwdD4KPC9ib2R5PgoKPC9odG1sPg==
1096
1096
  http_version:
1097
1097
  recorded_at: Fri, 25 Oct 2013 20:33:59 GMT
1098
+ - request:
1099
+ method: get
1100
+ uri: http://vk.com/video_
1101
+ body:
1102
+ encoding: US-ASCII
1103
+ string: ''
1104
+ headers:
1105
+ User-Agent:
1106
+ - VideoInfo/2.0.0
1107
+ Accept-Encoding:
1108
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
1109
+ Accept:
1110
+ - '*/*'
1111
+ response:
1112
+ status:
1113
+ code: 404
1114
+ message: Not Found
1115
+ headers:
1116
+ Server:
1117
+ - nginx/1.2.4
1118
+ Date:
1119
+ - Sat, 26 Oct 2013 11:12:56 GMT
1120
+ Content-Type:
1121
+ - text/html
1122
+ Content-Length:
1123
+ - '397'
1124
+ Connection:
1125
+ - keep-alive
1126
+ body:
1127
+ encoding: UTF-8
1128
+ string: |
1129
+ <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
1130
+ <html><head>
1131
+ <title>404 Not Found</title>
1132
+ </head>
1133
+ <body style="background: #3f5d81 url(http://vk.me/images/error404.png) no-repeat 50% 50%; width: 100%; height: 100%; overflow: hidden;">
1134
+ <a style="position: absolute; left: 50%; top: 50%; margin: -265px -345px 0px; height: 530px; width: 690px;" href="http://vk.com/"></a>
1135
+ </body>
1136
+ </html>
1137
+ http_version:
1138
+ recorded_at: Sat, 26 Oct 2013 11:12:56 GMT
1098
1139
  recorded_with: VCR 2.6.0
@@ -1095,4 +1095,45 @@ http_interactions:
1095
1095
  L3NjcmlwdD4KPC9ib2R5PgoKPC9odG1sPg==
1096
1096
  http_version:
1097
1097
  recorded_at: Fri, 25 Oct 2013 20:33:59 GMT
1098
+ - request:
1099
+ method: get
1100
+ uri: http://vk.com/video_
1101
+ body:
1102
+ encoding: US-ASCII
1103
+ string: ''
1104
+ headers:
1105
+ User-Agent:
1106
+ - VideoInfo/2.0.0
1107
+ Accept-Encoding:
1108
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
1109
+ Accept:
1110
+ - '*/*'
1111
+ response:
1112
+ status:
1113
+ code: 404
1114
+ message: Not Found
1115
+ headers:
1116
+ Server:
1117
+ - nginx/1.2.4
1118
+ Date:
1119
+ - Sat, 26 Oct 2013 11:12:56 GMT
1120
+ Content-Type:
1121
+ - text/html
1122
+ Content-Length:
1123
+ - '397'
1124
+ Connection:
1125
+ - keep-alive
1126
+ body:
1127
+ encoding: UTF-8
1128
+ string: |
1129
+ <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
1130
+ <html><head>
1131
+ <title>404 Not Found</title>
1132
+ </head>
1133
+ <body style="background: #3f5d81 url(http://vk.me/images/error404.png) no-repeat 50% 50%; width: 100%; height: 100%; overflow: hidden;">
1134
+ <a style="position: absolute; left: 50%; top: 50%; margin: -265px -345px 0px; height: 530px; width: 690px;" href="http://vk.com/"></a>
1135
+ </body>
1136
+ </html>
1137
+ http_version:
1138
+ recorded_at: Sat, 26 Oct 2013 11:12:56 GMT
1098
1139
  recorded_with: VCR 2.6.0
@@ -1095,4 +1095,45 @@ http_interactions:
1095
1095
  c2NyaXB0Pgo8L2JvZHk+Cgo8L2h0bWw+
1096
1096
  http_version:
1097
1097
  recorded_at: Fri, 25 Oct 2013 20:34:00 GMT
1098
+ - request:
1099
+ method: get
1100
+ uri: http://vk.com/video_
1101
+ body:
1102
+ encoding: US-ASCII
1103
+ string: ''
1104
+ headers:
1105
+ User-Agent:
1106
+ - VideoInfo/2.0.0
1107
+ Accept-Encoding:
1108
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
1109
+ Accept:
1110
+ - '*/*'
1111
+ response:
1112
+ status:
1113
+ code: 404
1114
+ message: Not Found
1115
+ headers:
1116
+ Server:
1117
+ - nginx/1.2.4
1118
+ Date:
1119
+ - Sat, 26 Oct 2013 11:12:57 GMT
1120
+ Content-Type:
1121
+ - text/html
1122
+ Content-Length:
1123
+ - '397'
1124
+ Connection:
1125
+ - keep-alive
1126
+ body:
1127
+ encoding: UTF-8
1128
+ string: |
1129
+ <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
1130
+ <html><head>
1131
+ <title>404 Not Found</title>
1132
+ </head>
1133
+ <body style="background: #3f5d81 url(http://vk.me/images/error404.png) no-repeat 50% 50%; width: 100%; height: 100%; overflow: hidden;">
1134
+ <a style="position: absolute; left: 50%; top: 50%; margin: -265px -345px 0px; height: 530px; width: 690px;" href="http://vk.com/"></a>
1135
+ </body>
1136
+ </html>
1137
+ http_version:
1138
+ recorded_at: Sat, 26 Oct 2013 11:12:57 GMT
1098
1139
  recorded_with: VCR 2.6.0
@@ -1095,4 +1095,45 @@ http_interactions:
1095
1095
  c2NyaXB0Pgo8L2JvZHk+Cgo8L2h0bWw+
1096
1096
  http_version:
1097
1097
  recorded_at: Fri, 25 Oct 2013 20:34:00 GMT
1098
+ - request:
1099
+ method: get
1100
+ uri: http://vk.com/video_
1101
+ body:
1102
+ encoding: US-ASCII
1103
+ string: ''
1104
+ headers:
1105
+ User-Agent:
1106
+ - VideoInfo/2.0.0
1107
+ Accept-Encoding:
1108
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
1109
+ Accept:
1110
+ - '*/*'
1111
+ response:
1112
+ status:
1113
+ code: 404
1114
+ message: Not Found
1115
+ headers:
1116
+ Server:
1117
+ - nginx/1.2.4
1118
+ Date:
1119
+ - Sat, 26 Oct 2013 11:12:57 GMT
1120
+ Content-Type:
1121
+ - text/html
1122
+ Content-Length:
1123
+ - '397'
1124
+ Connection:
1125
+ - keep-alive
1126
+ body:
1127
+ encoding: UTF-8
1128
+ string: |
1129
+ <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
1130
+ <html><head>
1131
+ <title>404 Not Found</title>
1132
+ </head>
1133
+ <body style="background: #3f5d81 url(http://vk.me/images/error404.png) no-repeat 50% 50%; width: 100%; height: 100%; overflow: hidden;">
1134
+ <a style="position: absolute; left: 50%; top: 50%; margin: -265px -345px 0px; height: 530px; width: 690px;" href="http://vk.com/"></a>
1135
+ </body>
1136
+ </html>
1137
+ http_version:
1138
+ recorded_at: Sat, 26 Oct 2013 11:12:57 GMT
1098
1139
  recorded_with: VCR 2.6.0
@@ -1095,4 +1095,45 @@ http_interactions:
1095
1095
  L3NjcmlwdD4KPC9ib2R5PgoKPC9odG1sPg==
1096
1096
  http_version:
1097
1097
  recorded_at: Fri, 25 Oct 2013 20:33:59 GMT
1098
+ - request:
1099
+ method: get
1100
+ uri: http://vk.com/video_
1101
+ body:
1102
+ encoding: US-ASCII
1103
+ string: ''
1104
+ headers:
1105
+ User-Agent:
1106
+ - VideoInfo/2.0.0
1107
+ Accept-Encoding:
1108
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
1109
+ Accept:
1110
+ - '*/*'
1111
+ response:
1112
+ status:
1113
+ code: 404
1114
+ message: Not Found
1115
+ headers:
1116
+ Server:
1117
+ - nginx/1.2.4
1118
+ Date:
1119
+ - Sat, 26 Oct 2013 11:12:56 GMT
1120
+ Content-Type:
1121
+ - text/html
1122
+ Content-Length:
1123
+ - '397'
1124
+ Connection:
1125
+ - keep-alive
1126
+ body:
1127
+ encoding: UTF-8
1128
+ string: |
1129
+ <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
1130
+ <html><head>
1131
+ <title>404 Not Found</title>
1132
+ </head>
1133
+ <body style="background: #3f5d81 url(http://vk.me/images/error404.png) no-repeat 50% 50%; width: 100%; height: 100%; overflow: hidden;">
1134
+ <a style="position: absolute; left: 50%; top: 50%; margin: -265px -345px 0px; height: 530px; width: 690px;" href="http://vk.com/"></a>
1135
+ </body>
1136
+ </html>
1137
+ http_version:
1138
+ recorded_at: Sat, 26 Oct 2013 11:12:56 GMT
1098
1139
  recorded_with: VCR 2.6.0
@@ -1095,4 +1095,45 @@ http_interactions:
1095
1095
  c2NyaXB0Pgo8L2JvZHk+Cgo8L2h0bWw+
1096
1096
  http_version:
1097
1097
  recorded_at: Fri, 25 Oct 2013 20:34:00 GMT
1098
+ - request:
1099
+ method: get
1100
+ uri: http://vk.com/video_
1101
+ body:
1102
+ encoding: US-ASCII
1103
+ string: ''
1104
+ headers:
1105
+ User-Agent:
1106
+ - VideoInfo/2.0.0
1107
+ Accept-Encoding:
1108
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
1109
+ Accept:
1110
+ - '*/*'
1111
+ response:
1112
+ status:
1113
+ code: 404
1114
+ message: Not Found
1115
+ headers:
1116
+ Server:
1117
+ - nginx/1.2.4
1118
+ Date:
1119
+ - Sat, 26 Oct 2013 11:12:58 GMT
1120
+ Content-Type:
1121
+ - text/html
1122
+ Content-Length:
1123
+ - '397'
1124
+ Connection:
1125
+ - keep-alive
1126
+ body:
1127
+ encoding: UTF-8
1128
+ string: |
1129
+ <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
1130
+ <html><head>
1131
+ <title>404 Not Found</title>
1132
+ </head>
1133
+ <body style="background: #3f5d81 url(http://vk.me/images/error404.png) no-repeat 50% 50%; width: 100%; height: 100%; overflow: hidden;">
1134
+ <a style="position: absolute; left: 50%; top: 50%; margin: -265px -345px 0px; height: 530px; width: 690px;" href="http://vk.com/"></a>
1135
+ </body>
1136
+ </html>
1137
+ http_version:
1138
+ recorded_at: Sat, 26 Oct 2013 11:12:58 GMT
1098
1139
  recorded_with: VCR 2.6.0