Take 3 og for livestream
This commit is contained in:
parent
7dd7aac8d2
commit
b5184078b8
1 changed files with 12 additions and 10 deletions
|
@ -143,6 +143,9 @@ function buildClaimOgMetadata(uri, claim, overrideOptions = {}, referrerQuery) {
|
|||
const mediaDuration = media && media.duration;
|
||||
const claimTitle = escapeHtmlProperty((value && value.title) || claimName);
|
||||
const releaseTime = (value && value.release_time) || (meta && meta.creation_timestamp) || 0;
|
||||
const liveStream = !source;
|
||||
const mediaHeight = (media && media.height) || '720';
|
||||
const mediaWidth = (media && media.width) || '1280';
|
||||
|
||||
const claimDescription =
|
||||
value && value.description && value.description.length > 0
|
||||
|
@ -164,7 +167,8 @@ function buildClaimOgMetadata(uri, claim, overrideOptions = {}, referrerQuery) {
|
|||
getThumbnailCdnUrl(OG_IMAGE_URL) ||
|
||||
`${URL}/public/v2-og.png`;
|
||||
|
||||
const getOgType = (streamType) => {
|
||||
const getOgType = (streamType, liveStream) => {
|
||||
if (liveStream) return 'video.other';
|
||||
switch (streamType) {
|
||||
// https://ogp.me/?fbclid=IwAR0Dr3Rb3tw1W5wjFtuRMZfwewM2vlrSnNp-_ZKlvCzo5nKuX2TuTqt0kU8#types
|
||||
case 'video':
|
||||
|
@ -201,7 +205,7 @@ function buildClaimOgMetadata(uri, claim, overrideOptions = {}, referrerQuery) {
|
|||
head += `<meta property="og:image:secure_url" content="${claimThumbnail}"/>`;
|
||||
head += `<meta property="og:locale" content="${claimLanguage}"/>`;
|
||||
head += `<meta property="og:site_name" content="${SITE_NAME}"/>`;
|
||||
head += `<meta property="og:type" content="${getOgType(value?.stream_type)}"/>`;
|
||||
head += `<meta property="og:type" content="${getOgType(value?.stream_type, liveStream)}"/>`;
|
||||
head += `<meta property="og:title" content="${title}"/>`;
|
||||
head += `<meta name="twitter:title" content="${title}"/>`;
|
||||
head += `<meta property="og:url" content="${claimPath}"/>`;
|
||||
|
@ -215,7 +219,7 @@ function buildClaimOgMetadata(uri, claim, overrideOptions = {}, referrerQuery) {
|
|||
claimPath
|
||||
)}&format=xml${referrerQuery ? `&r=${encodeURIComponent(referrerQuery)}` : ''}" title="${title}" />`;
|
||||
|
||||
if ((mediaType && (mediaType.startsWith('video/') || mediaType.startsWith('audio/'))) || !mediaType) {
|
||||
if ((mediaType && (mediaType.startsWith('video/') || mediaType.startsWith('audio/'))) || liveStream) {
|
||||
const videoUrl = generateEmbedUrl(claim.name, claim.claim_id);
|
||||
head += `<meta property="og:video" content="${videoUrl}" />`;
|
||||
head += `<meta property="og:video:secure_url" content="${videoUrl}" />`;
|
||||
|
@ -231,14 +235,12 @@ function buildClaimOgMetadata(uri, claim, overrideOptions = {}, referrerQuery) {
|
|||
head += `<meta property="og:video:release_date" content="${release}"/>`;
|
||||
}
|
||||
if (mediaDuration) {
|
||||
head += `<meta property="og:video:duration" content="${mediaDuration || '0'}"/>`;
|
||||
}
|
||||
if (media && media.width && media.height) {
|
||||
head += `<meta property="og:video:width" content="${media.width || '1280'}"/>`;
|
||||
head += `<meta property="og:video:height" content="${media.height || '720'}"/>`;
|
||||
head += `<meta name="twitter:player:width" content="${media.width || '1280'}">`;
|
||||
head += `<meta name="twitter:player:height" content="${media.height || '720'}">`;
|
||||
head += `<meta property="og:video:duration" content="${mediaDuration}"/>`;
|
||||
}
|
||||
head += `<meta property="og:video:width" content="${mediaWidth}"/>`;
|
||||
head += `<meta property="og:video:height" content="${mediaHeight}"/>`;
|
||||
head += `<meta name="twitter:player:width" content="${mediaWidth}">`;
|
||||
head += `<meta name="twitter:player:height" content="${mediaWidth}">`;
|
||||
} else {
|
||||
head += `<meta name="twitter:card" content="summary_large_image"/>`;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue