GoogleVideoSearch: fix blank description; invalid thumbnails

## Issue
Closes 5923 video metadata issues

## Notes
For thumbnails, future claims should have correct thumbnails after `5925 Fix thumbnail-checking and block 'data:image'`. For existing claims, we'll just skip the metadata to avoid the crawler error. Users can easily update their thumbnails.

For the `OlivOliv` thumbnail url case, I wasn't sure whether to go all out to fetch and verify each thumbnail. I ended up just checking whether it starts with `http(s)`
This commit is contained in:
infinite-persistence 2021-04-21 14:12:09 +08:00 committed by Sean Yesmunt
parent cb2c33a35f
commit 8493b1e3df

View file

@ -191,11 +191,19 @@ function buildGoogleVideoMetadata(claimUri, claim) {
thumbnailUrl: `${claimThumbnail}`, thumbnailUrl: `${claimThumbnail}`,
uploadDate: `${new Date(releaseTime * 1000).toISOString()}`, uploadDate: `${new Date(releaseTime * 1000).toISOString()}`,
// --- Recommended --- // --- Recommended ---
duration: moment.duration(claim.duration * 1000).toISOString(), duration: claim.duration ? moment.duration(claim.duration * 1000).toISOString() : undefined,
contentUrl: generateDirectUrl(claim.name, claim.claim_id), contentUrl: generateDirectUrl(claim.name, claim.claim_id),
embedUrl: generateEmbedUrl(claim.name, claim.claim_id), embedUrl: generateEmbedUrl(claim.name, claim.claim_id),
}; };
if (
!googleVideoMetadata.description.replace(/\s/g, '').length ||
googleVideoMetadata.thumbnailUrl.startsWith('data:image') ||
!googleVideoMetadata.thumbnailUrl.startsWith('http')
) {
return '';
}
return ( return (
'<script type="application/ld+json">\n' + JSON.stringify(googleVideoMetadata, null, ' ') + '\n' + '</script>\n' '<script type="application/ld+json">\n' + JSON.stringify(googleVideoMetadata, null, ' ') + '\n' + '</script>\n'
); );