onebox 1.5.35 → 1.5.36

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a2536f8a819505d60d5c3af20abdac0bdad30a66
4
- data.tar.gz: 868fac1b2221457e904c53b02b4a8bdb5dfaa270
3
+ metadata.gz: cb07f9ec00a95d8a8247d010c04a22fceb4b242d
4
+ data.tar.gz: 2cb0aedd6352c878611604c063c87563ef007240
5
5
  SHA512:
6
- metadata.gz: 2ff16c0bebe5aee99c4d8f6233ec6df20d09cf1a94046116ac4a7abb29b74c2a5bef4d38bbff5d604b83cf651a4c8035e2d72efed3c49eebbc1ea1587ad6b88e
7
- data.tar.gz: e3e8cd1d52dd1b2cae80fecac4c1771ce729eb587f49afb41efb9db343a460f7e54c203a2827873c70924338f340072bf950c510dd5bb82119f912d89c23b2f1
6
+ metadata.gz: 6cd4b8c587b4f6dece85cbdc518c4ecab43d71ca9eaf7059f0761fd76e5f163d09b620b1dfb56cb6b20648ff12cdd2c5dcc809601e251a9bf1d0223f842cfd84
7
+ data.tar.gz: 9515d8b35ab81a113e1ac8f409639fee03b5eef23b06052bc37a236ae2c2cf417e4f78bd83a755b5da2dfe8018210429ecf1dbc6157f4b493a68d11dbf1a0de7
@@ -30,15 +30,18 @@ module Onebox
30
30
  end
31
31
 
32
32
  def image
33
- case
34
- when raw.css("#main-image").any?
35
- ::JSON.parse(
36
- raw.css("#main-image").first
37
- .attributes["data-a-dynamic-image"]
38
- .value
39
- ).keys.first
40
- when raw.css("#landingImage").any?
41
- raw.css("#landingImage").first["src"]
33
+ if (main_image = raw.css("#main-image")) && main_image.any?
34
+ attributes = main_image.first.attributes
35
+
36
+ return attributes["data-a-hires"] if attributes["data-a-hires"]
37
+
38
+ if attributes["data-a-dynamic-image"]
39
+ return ::JSON.parse(attributes["data-a-dynamic-image"].value).keys.first
40
+ end
41
+ end
42
+
43
+ if (landing_image = raw.css("#landingImage")) && landing_image.any?
44
+ landing_image.first["src"]
42
45
  end
43
46
  end
44
47
 
@@ -51,11 +54,14 @@ module Onebox
51
54
  result[:by_info] = Onebox::Helpers.clean(result[:by_info].inner_html) if result[:by_info]
52
55
 
53
56
  # get item price (Amazon markup is inconsistent, deal with it)
54
- if raw.css("#priceblock_ourprice .restOfPrice")[0] && raw.css("#priceblock_ourprice .restOfPrice")[0].inner_text
55
- result[:price] = "#{raw.css("#priceblock_ourprice .restOfPrice")[0].inner_text}#{raw.css("#priceblock_ourprice .buyingPrice")[0].inner_text}.#{raw.css("#priceblock_ourprice .restOfPrice")[1].inner_text}"
56
- else
57
- result[:price] = raw.css("#priceblock_ourprice").inner_text
58
- end
57
+ result[:price] =
58
+ if raw.css("#priceblock_ourprice .restOfPrice")[0] && raw.css("#priceblock_ourprice .restOfPrice")[0].inner_text
59
+ "#{raw.css("#priceblock_ourprice .restOfPrice")[0].inner_text}#{raw.css("#priceblock_ourprice .buyingPrice")[0].inner_text}.#{raw.css("#priceblock_ourprice .restOfPrice")[1].inner_text}"
60
+ elsif raw.css("#priceblock_dealprice") && (dealprice = raw.css("#priceblock_dealprice span")[0])
61
+ dealprice.inner_text
62
+ else
63
+ raw.css("#priceblock_ourprice").inner_text
64
+ end
59
65
 
60
66
  summary = raw.at("#productDescription")
61
67
  result[:description] = summary.inner_text if summary
@@ -19,7 +19,6 @@ module Onebox
19
19
  end
20
20
 
21
21
  # Some oembed providers (like meetup.com) don't provide links to themselves
22
- add_oembed_provider /www\.flickr\.com\//, 'http://www.flickr.com/services/oembed.json'
23
22
  add_oembed_provider /(.*\.)?gfycat\.com\//, 'http://gfycat.com/cajax/oembed'
24
23
  add_oembed_provider /www\.kickstarter\.com\//, 'https://www.kickstarter.com/services/oembed'
25
24
  add_oembed_provider /www\.meetup\.com\//, 'http://api.meetup.com/oembed'
@@ -27,7 +26,7 @@ module Onebox
27
26
  add_oembed_provider /(.*\.)?vimeo\.com\//, 'http://vimeo.com/api/oembed.json'
28
27
 
29
28
  # Sites that work better with OpenGraph
30
- # add_opengraph_provider /gfycat\.com\//
29
+ add_opengraph_provider /nytimes\.com\//
31
30
 
32
31
  def always_https?
33
32
  WhitelistedGenericOnebox.host_matches(uri, WhitelistedGenericOnebox.https_hosts)
@@ -8,8 +8,9 @@ module Onebox
8
8
 
9
9
  # Try to get the video ID. Works for URLs of the form:
10
10
  # * http://v.youku.com/v_show/id_XNjM3MzAxNzc2.html
11
+ # * http://v.youku.com/v_show/id_XMTQ5MjgyMjMyOA==.html?from=y1.3-tech-index3-232-10183.89969-89963.3-1
11
12
  def video_id
12
- match = uri.path.match(/\/v_show\/id_([a-zA-Z0-9]*)(\.html)*/)
13
+ match = uri.path.match(/\/v_show\/id_([a-zA-Z0-9_=\-]+)(\.html)?.*/)
13
14
  return match[1] if match && match[1]
14
15
 
15
16
  nil
@@ -18,7 +19,7 @@ module Onebox
18
19
  end
19
20
 
20
21
  def to_html
21
- "<iframe width='480' height='270' src='http://player.youku.com/embed/#{video_id}' frameborder='0' allowfullscreen></iframe>"
22
+ "<embed width='570' height='360' src='https://players.youku.com/player.php/sid/#{video_id}/v.swf' wmode='transparent' allowFullScreen='true' quality='high' align='middle' allowScriptAccess='always' type='application/x-shockwave-flash'></embed>"
22
23
  end
23
24
 
24
25
  def placeholder_html
@@ -27,7 +28,7 @@ module Onebox
27
28
 
28
29
  private
29
30
 
30
- # Note: May throw! Make sure to recue.
31
+ # Note: May throw! Make sure to rescue.
31
32
  def uri
32
33
  @_uri ||= URI(@url)
33
34
  end
@@ -1,3 +1,3 @@
1
1
  module Onebox
2
- VERSION = "1.5.35"
2
+ VERSION = "1.5.36"
3
3
  end
@@ -6,8 +6,8 @@ describe Onebox::Engine::YoukuOnebox do
6
6
  FakeWeb.register_uri(:get, 'http://v.youku.com/player/getPlayList/VideoIDS/XNjM3MzAxNzc2', body: response('youku-meta'), content_type: 'text/html')
7
7
  end
8
8
 
9
- it 'returns iframe as the placeholder' do
9
+ it 'returns embed as the placeholder' do
10
10
  expect(Onebox.preview('http://v.youku.com/v_show/id_XNjM3MzAxNzc2.html')
11
- .placeholder_html).to match(/iframe/)
11
+ .placeholder_html).to match(/embed/)
12
12
  end
13
13
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: onebox
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.35
4
+ version: 1.5.36
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joanna Zeta
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2016-02-22 00:00:00.000000000 Z
13
+ date: 2016-03-28 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: multi_json
@@ -495,3 +495,4 @@ test_files:
495
495
  - spec/lib/onebox_spec.rb
496
496
  - spec/spec_helper.rb
497
497
  - spec/support/html_spec_helper.rb
498
+ has_rdoc: