onebox 1.5.35 → 1.5.36
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.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cb07f9ec00a95d8a8247d010c04a22fceb4b242d
|
4
|
+
data.tar.gz: 2cb0aedd6352c878611604c063c87563ef007240
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
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
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
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
|
-
|
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-
|
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
|
-
"<
|
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
|
31
|
+
# Note: May throw! Make sure to rescue.
|
31
32
|
def uri
|
32
33
|
@_uri ||= URI(@url)
|
33
34
|
end
|
data/lib/onebox/version.rb
CHANGED
@@ -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
|
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(/
|
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.
|
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-
|
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:
|