Skip to content

Commit ee10fc9

Browse files
authored
Merge branch 'itteco:main' into main
2 parents ae914d8 + 3ea7149 commit ee10fc9

File tree

13 files changed

+80
-132
lines changed

13 files changed

+80
-132
lines changed

config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
video_mp4: "video/mp4",
8181
video_ogg: "video/ogg",
8282
video_webm: "video/webm",
83+
video_iso: "video/iso.segment",
8384
stream_apple_mpegurl: "application/vnd.apple.mpegurl",
8485
stream_x_mpegurl: "application/x-mpegURL",
8586
audio_mp3: "audio/mp3",

lib/plugins/system/meta/HTMLMetaHandler.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ HTMLMetaHandler.prototype.onopentag = function(name, attributes) {
6868
value = value.replace(/(\r\n|\n|\r)/gm, ' ');
6969
}
7070

71-
if (/^\d+$/.test(value)) { // convert to integer
71+
if (/^\d+$/.test(value) && !/(title|description)/i.test(tagName)) { // convert to integer
7272
value = parseInt(value, 10);
7373
} else if (/^\d+\.\d+$/.test(value)) {
7474
value = parseFloat(value);

lib/plugins/system/oembed/providers.json

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -445,13 +445,6 @@
445445
],
446446
"endpoint": "https://app.widgetic.com/services/oembed/"
447447
},
448-
{
449-
"name": "Adobe Stock",
450-
"templates": [
451-
"stock.adobe.com/(?:images|stock-photo)/([a-zA-Z0-9-]+\/\\d+)"
452-
],
453-
"endpoint": "https://stock.adobe.com/oembed?url=https://stock.adobe.com/stock-photo/{1}"
454-
},
455448
{
456449
"name": "Reddit",
457450
"templates": [
@@ -1167,5 +1160,19 @@
11671160
"run.ply.io/run/*"
11681161
],
11691162
"endpoint": "https://app-server.ply.io/api/oembed"
1163+
},
1164+
{
1165+
"name": "Wakelet",
1166+
"templates": [
1167+
"wakelet.com/wake/*"
1168+
],
1169+
"endpoint": "https://wakelet.com/api/oembed"
1170+
},
1171+
{
1172+
"name": "Wolframcloud",
1173+
"templates": [
1174+
"wolframcloud.com/obj/*"
1175+
],
1176+
"endpoint": "https://www.wolframcloud.com/oembed"
11701177
}
11711178
]

lib/plugins/validators/sync/07_resizable.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55

66
prepareLink: function(url, options, link) {
77

8-
if ((link.type === CONFIG.T.text_html || link.accept && link.accept.length === 1 && link.accept.indexOf(CONFIG.T.text_html) > -1)
8+
if ((link.type === CONFIG.T.text_html || link.accept && link.accept.indexOf(CONFIG.T.text_html) > -1)
99
&& link.rel.indexOf(CONFIG.R.resizable) > -1
1010
&& link.media
1111
&& link.media.height

lib/utils.js

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,29 @@ export function parseLDSource(ld, decode, uri) {
485485
}
486486
};
487487

488+
export function findMainLdObjectWithVideo(ld) {
489+
490+
let json = ld.videoobject || ld.mediaobject;
491+
492+
/*
493+
|| (ld.newsarticle && (ld.newsarticle.video || ld.newsarticle.videoobject))
494+
|| (ld.tvepisode && (ld.tvepisode.video || ld.tvepisode.videoobject))
495+
|| (ld.movie && (ld.movie.video || ld.movie.videoobject))
496+
|| (ld.tvclip && (ld.tvclip.video || ld.tvclip.videoobject));
497+
*/
498+
if (!json) { // try to find video attached to main object
499+
var mainObjWithVideo = ld && Object.values(ld).find((obj) => obj.video || obj.videoobject);
500+
if (mainObjWithVideo) {
501+
json = mainObjWithVideo.video || mainObjWithVideo.videoobject;
502+
}
503+
}
504+
505+
if (json && Array.isArray(json) && json.length === 1) {
506+
json = json[0];
507+
}
508+
509+
return json; // if any
510+
}
488511

489512
/**
490513
* @public
@@ -798,7 +821,7 @@ export function getContentType(uriForCache, uriOriginal, options, cb) {
798821
|| error >= 500
799822
// Or ClourFront that gobbles up headers when checking CORS.
800823
|| (res.headers && !res.headers['access-control-allow-origin']
801-
&& res.headers['server'] === 'AmazonS3' && !error ))) {
824+
&& (res.headers['server'] === 'AmazonS3' || /origin/i.test(res.headers['vary'])) && !error ))) {
802825
makeCall(uriOriginal, 'GET');
803826
return;
804827
}

plugins/domains/geogebra.iframe.js

Lines changed: 0 additions & 40 deletions
This file was deleted.

plugins/domains/geogebra.org.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,23 @@ export default {
1111
"*"
1212
],
1313

14-
getData: function(urlMatch, options, cb) {
14+
getLink: function(urlMatch) {
1515
/** https://wiki.geogebra.org/en/Embedding_in_Webpages */
1616

1717
if (!/^\d+$/.test(urlMatch[1])) {
18-
cb (null, {__promoUri: {url: 'https://www.geogebra.org/material/iframe/id/' + urlMatch[1]} });
19-
} else {
20-
cb(null, null)
18+
return {
19+
href: 'https://www.geogebra.org/material/iframe/id/' + urlMatch[1],
20+
accept: CONFIG.T.text_html,
21+
rel: [CONFIG.R.app, CONFIG.R.iframely],
22+
'aspect-ratio': 800 / 600
23+
}
2124
}
2225
},
2326

2427
tests: [
2528
{noFeeds: true},
2629
{skipMethods: ['getData']},
27-
"http://www.geogebra.org/m/141300",
28-
"https://www.geogebra.org/m/wn2U6Hj6#material/ysf5TjUB",
30+
"https://www.geogebra.org/m/141300",
2931
"https://www.geogebra.org/classic/hs52mgmq",
3032
"https://www.geogebra.org/graphing/pse7krdf"
3133
]

plugins/domains/instagram.com/instagram.com.js

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export default {
9090
});
9191
}
9292

93-
if (ipOG.video) {
93+
if (ipOG.video && ipOG.video.width && ipOG.video.height) {
9494
links.push({
9595
href: ipOG.video.url,
9696
accept: CONFIG.T.text_html,
@@ -132,9 +132,9 @@ export default {
132132
type: CONFIG.T.text_html,
133133
rel: [CONFIG.R.app, CONFIG.R.ssl, CONFIG.R.inline],
134134
// sizing is from Instagram placeholder to avoid double height changes
135-
'max-width': 660,
136-
'aspect-ratio': 200/63,
137-
'padding-bottom': 200,
135+
'max-width': 660,
136+
'aspect-ratio': 100 / (2 *(19 + 12.5)), // was: oembed.thumbnail_width / oembed.thumbnail_height, but sizes for placeholder are hardcoded anyway, no need to link them to the image sizes
137+
'padding-bottom': 284,
138138
options: {
139139
showcaption: {
140140
label: 'Show author\'s text caption',
@@ -143,12 +143,6 @@ export default {
143143
}
144144
};
145145

146-
if (oembed.thumbnail_width && oembed.thumbnail_height) {
147-
// sizes for placeholder are hardcoded anyway, no need to link them to the image sizes
148-
app['aspect-ratio'] = 100 / (2 *(19 + 12.5)); // was: oembed.thumbnail_width / oembed.thumbnail_height;
149-
app['padding-bottom'] = 284;// was: 206;
150-
}
151-
152146
links.push(app);
153147
}
154148

@@ -185,7 +179,7 @@ export default {
185179
"https://www.instagram.com/reel/CtHaSoDLrWJ/",
186180
"https://www.instagram.com/nssmagazine/reel/CrVt-Wvs74O/",
187181
{
188-
skipMixins: ["oembed-title", "fb-error"],
182+
skipMixins: ["oembed-title", "fb-error", "oembed-author"],
189183
skipMethods: ['getData']
190184
}
191185
]

plugins/domains/sverigesradio.se.js

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,30 +11,7 @@ export default {
1111

1212
provides: 'sveriges',
1313

14-
mixins: [
15-
// oEmbed returns "non-starting" player too - https://sverigesradio.se/avsnitt/1966906
16-
"twitter-title",
17-
"twitter-description",
18-
"twitter-site",
19-
"twitter-image",
20-
"ld-newsarticle-logo",
21-
"ld-author",
22-
"ld-date",
23-
"canonical",
24-
"keywords",
25-
"media-detector",
26-
"theme-color",
27-
"favicon",
28-
],
29-
30-
/* Not needed
31-
getMeta: function(sverigies) {
32-
return {
33-
title: sveriges.title,
34-
description: sveriges.description
35-
}
36-
},
37-
*/
14+
mixins: ["*"],
3815

3916
getLink: function(sveriges) {
4017

@@ -93,14 +70,16 @@ export default {
9370
},
9471

9572
tests: [{skipMixins: ['keywords']},
96-
"https://sverigesradio.se/artikel/5848335",
73+
"https://sverigesradio.se/artikel/5448335",
9774
"https://sverigesradio.se/artikel/6573606",
75+
"https://sverigesradio.se/play/artikel/8936167",
9876
"https://sverigesradio.se/artikel/professorn-om-rymdbilden-det-ar-hisnande",
99-
// "https://sverigesradio.se/avsnitt/1966906",
77+
"https://www.sverigesradio.se/artikel/personal-doms-for-stold-av-smycken-varda-200-000-kronor-fran-aldreboende",
10078
"https://sverigesradio.se/embed/publication/6652202",
10179
"https://sverigesradio.se/embed/publication/8087725",
102-
// Not embeddable: "https://sverigesradio.se/embed/episode/1966906",
80+
"https://sverigesradio.se/avsnitt/2568806",
10381
"https://sverigesradio.se/avsnitt/nikola-tesla-elektricitetspionjaren-som-glomdes-bort"
10482
// Not embeddable: https://sverigesradio.se/artikel/4351444
83+
// Not embeddable: "https://sverigesradio.se/embed/episode/1966906",
10584
]
10685
};

plugins/links/embedURL/embedURL.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,19 @@ export default {
1212

1313
if ($script.length === 1) {
1414
try {
15-
var ld = utils.parseLDSource($script.html(), decode, url);
16-
15+
const ld = utils.parseLDSource($script.html(), decode, url);
1716
if (ld && __allowEmbedURL !== 'skip_ld') {
1817
return {
1918
ld: ld
2019
}
21-
} else if (ld && (ld.videoobject || ld.mediaobject)) {
22-
const videoObject = ld.videoobject || ld.mediaobject,
23-
href = videoObject.embedURL || videoObject.embedUrl || videoObject.embedurl || videoObject.contentURL || videoobject.contentUrl || videoobject.contenturl;
24-
25-
if (href) {
20+
} else if (ld) {
21+
const json = utils.findMainLdObjectWithVideo(ld);
22+
if (json) {
2623
return {
27-
schemaVideoObject: ld.videoobject || ld.mediaobject
24+
schemaVideoObject: json
2825
}
2926
} // else check microformats, ex.: cbssports
3027
}
31-
3228
} catch (ex) {
3329
// broken json, c'est la vie
3430
// let's try microformats instead

0 commit comments

Comments
 (0)