Skip to content

Commit

Permalink
ld: try to find all videos attached to a main object
Browse files Browse the repository at this point in the history
  • Loading branch information
iparamonau committed Oct 4, 2024
1 parent 6917ca3 commit 1d9662f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
13 changes: 7 additions & 6 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1293,12 +1293,13 @@ function getWhitelistLogData(meta, oembed, uri) {

var ld = meta.ld;
if (ld) {
var json = ld.videoobject
|| ld.mediaobject
|| (ld.newsarticle && (ld.newsarticle.video || ld.newsarticle.videoobject))
|| (ld.tvepisode && (ld.tvepisode.video || ld.tvepisode.videoobject))
|| (ld.movie && (ld.movie.video || ld.movie.videoobject))
|| (ld.tvclip && (ld.tvclip.video || ld.tvclip.videoobject));
var json = ld.videoobject || ld.mediaobject;
if (!json) { // try to find video attached to main object
var mainObjWithVideo = ld && Object.values(ld).find((obj) => obj.video || obj.videoobject);
if (mainObjWithVideo) {
json = mainObjWithVideo.video || mainObjWithVideo.videoobject;
}
}

if (json) {
var embedURL = json.embedurl || json.embedUrl || json.embedURL || json.contenturl || json.contentUrl || json.contentURL;
Expand Down
20 changes: 14 additions & 6 deletions plugins/links/embedURL/ld-video.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,20 @@ export default {

getData: function(ld, whitelistRecord, url) {

var json = ld.videoobject
|| ld.mediaobject
|| (ld.newsarticle && (ld.newsarticle.video || ld.newsarticle.videoobject))
|| (ld.tvepisode && (ld.tvepisode.video || ld.tvepisode.videoobject))
|| (ld.movie && (ld.movie.video || ld.movie.videoobject))
|| (ld.tvclip && (ld.tvclip.video || ld.tvclip.videoobject));
var json = ld.videoobject || ld.mediaobject;

/*
|| (ld.newsarticle && (ld.newsarticle.video || ld.newsarticle.videoobject))
|| (ld.tvepisode && (ld.tvepisode.video || ld.tvepisode.videoobject))
|| (ld.movie && (ld.movie.video || ld.movie.videoobject))
|| (ld.tvclip && (ld.tvclip.video || ld.tvclip.videoobject));
*/
if (!json) { // try to find video attached to main object
var mainObjWithVideo = ld && Object.values(ld).find((obj) => obj.video || obj.videoobject);
if (mainObjWithVideo) {
json = mainObjWithVideo.video || mainObjWithVideo.videoobject;
}
}

if (json) {

Expand Down

0 comments on commit 1d9662f

Please sign in to comment.