Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -632,17 +632,23 @@ export function findMainLdObjectWithVideo(ld) {

let 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) {
// Let's find videos in objects with "@type" arrays: ["CreativeWork", "VideoObject"]
// or other embeddable entities
// or entiites attached to main object
json = Object.values(ld).find((obj) => {
const type = obj['@type'];
return Array.isArray(type)
&& (type.indexOf('VideoObject') > -1 || type.indexOf('videoobject') > -1)
|| obj.embedUrl
|| obj.video || obj.videoObject;
});
}

// ex.: https://nypost.com/2025/12/16/us-news/obamas-planned-to-meet-with-rob-reiner-and-wife-the-night-couple-was-killed/
// https://nypost.com/video/artist-jailed-for-letting-people-touch-her-privates-in-public/
if (json && (json.video || json.videoObject)) {
json = json.video || json.videoObject;
}

if (json && Array.isArray(json) && json.length === 1) {
Expand Down
Loading