Use cards.odysee.com (#56)

This commit is contained in:
Thomas Zarebczan 2021-10-12 19:16:39 -04:00 committed by GitHub
parent 7c518aa712
commit 2b5d32c313
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 24 deletions

View file

@ -16,6 +16,7 @@ COMMENT_SERVER_NAME=Odysee
SEARCH_SERVER_API=https://lighthouse.odysee.com/search SEARCH_SERVER_API=https://lighthouse.odysee.com/search
SOCKETY_SERVER_API=wss://sockety.odysee.com/ws SOCKETY_SERVER_API=wss://sockety.odysee.com/ws
THUMBNAIL_CDN_URL=https://thumbnails.odysee.com/optimize/ THUMBNAIL_CDN_URL=https://thumbnails.odysee.com/optimize/
THUMBNAIL_CARDS_CDN_URL=https://cards.odysee.com/
THUMBNAIL_HEIGHT=220 THUMBNAIL_HEIGHT=220
THUMBNAIL_WIDTH=390 THUMBNAIL_WIDTH=390
THUMBNAIL_QUALITY=85 THUMBNAIL_QUALITY=85

View file

@ -10,8 +10,7 @@ const {
SITE_NAME, SITE_NAME,
FAVICON, FAVICON,
LBRY_WEB_API, LBRY_WEB_API,
THUMBNAIL_CDN_URL, THUMBNAIL_CARDS_CDN_URL,
THUMBNAIL_QUALITY,
} = require('../../config.js'); } = require('../../config.js');
const { Lbry } = require('lbry-redux'); const { Lbry } = require('lbry-redux');
@ -30,27 +29,11 @@ const PROXY_URL = `${SDK_API_PATH}/proxy`;
Lbry.setDaemonConnectionString(PROXY_URL); Lbry.setDaemonConnectionString(PROXY_URL);
function getThumbnailCdnUrl(url) { function getThumbnailCdnUrl(url) {
if (!THUMBNAIL_CDN_URL || !url) { if (!THUMBNAIL_CARDS_CDN_URL || !url) {
return url; return url;
} }
const width = 630;
const height = 1200;
if (url && url.includes('https://twitter-card')) {
return url;
}
if (url && url.includes('https://spee.ch') && !url.includes('?quality=')) {
return `${url}?quality=${THUMBNAIL_QUALITY}&height=${height}&width=${width}`;
}
if (url && url.includes('https://spee.ch')) {
return url;
}
if (url) { if (url) {
return url; return `${THUMBNAIL_CARDS_CDN_URL}${btoa(url)}.jpg`;
} }
} }
@ -110,14 +93,18 @@ function buildOgMetadata(overrideOptions = {}) {
`<meta property="og:title" content="${title || OG_HOMEPAGE_TITLE || SITE_TITLE}" />\n` + `<meta property="og:title" content="${title || OG_HOMEPAGE_TITLE || SITE_TITLE}" />\n` +
`<meta property="og:site_name" content="${SITE_NAME || SITE_TITLE}"/>\n` + `<meta property="og:site_name" content="${SITE_NAME || SITE_TITLE}"/>\n` +
`<meta property="og:description" content="${cleanDescription}" />\n` + `<meta property="og:description" content="${cleanDescription}" />\n` +
`<meta property="og:image" content="${image || OG_IMAGE_URL || `${URL}/public/v2-og.png`}" />\n` + `<meta property="og:image" content="${
getThumbnailCdnUrl(image) || getThumbnailCdnUrl(OG_IMAGE_URL) || `${URL}/public/v2-og.png`
}" />\n` +
`<meta property="og:type" content="website"/>\n` + `<meta property="og:type" content="website"/>\n` +
'<meta name="twitter:card" content="summary_large_image"/>\n' + '<meta name="twitter:card" content="summary_large_image"/>\n' +
`<meta name="twitter:title" content="${ `<meta name="twitter:title" content="${
(title && title + ' ' + OG_TITLE_SUFFIX) || OG_HOMEPAGE_TITLE || SITE_TITLE (title && title + ' ' + OG_TITLE_SUFFIX) || OG_HOMEPAGE_TITLE || SITE_TITLE
}" />\n` + }" />\n` +
`<meta name="twitter:description" content="${cleanDescription}" />\n` + `<meta name="twitter:description" content="${cleanDescription}" />\n` +
`<meta name="twitter:image" content="${image || OG_IMAGE_URL || `${URL}/public/v2-og.png`}"/>\n` + `<meta name="twitter:image" content="${
getThumbnailCdnUrl(image) || getThumbnailCdnUrl(OG_IMAGE_URL) || `${URL}/public/v2-og.png`
}"/>\n` +
'<meta property="fb:app_id" content="1673146449633983" />\n' + '<meta property="fb:app_id" content="1673146449633983" />\n' +
`<link rel="canonical" content="${SITE_CANONICAL_URL || URL}"/>` + `<link rel="canonical" content="${SITE_CANONICAL_URL || URL}"/>` +
`<link rel="search" type="application/opensearchdescription+xml" title="${ `<link rel="search" type="application/opensearchdescription+xml" title="${
@ -190,7 +177,11 @@ function buildClaimOgMetadata(uri, claim, overrideOptions = {}) {
imageThumbnail = generateStreamUrl(claim.name, claim.claim_id); imageThumbnail = generateStreamUrl(claim.name, claim.claim_id);
} }
const claimThumbnail = escapeHtmlProperty(thumbnail) || imageThumbnail || OG_IMAGE_URL || `${URL}/public/v2-og.png`; const claimThumbnail =
escapeHtmlProperty(thumbnail) ||
getThumbnailCdnUrl(imageThumbnail) ||
getThumbnailCdnUrl(OG_IMAGE_URL) ||
`${URL}/public/v2-og.png`;
// Allow for ovverriding default claim based og metadata // Allow for ovverriding default claim based og metadata
const title = overrideOptions.title || claimTitle; const title = overrideOptions.title || claimTitle;
@ -272,7 +263,7 @@ function buildGoogleVideoMetadata(uri, claim) {
return ''; return '';
} }
const claimThumbnail = escapeHtmlProperty(thumbnail) || OG_IMAGE_URL || `${URL}/public/v2-og.png`; const claimThumbnail = escapeHtmlProperty(thumbnail) || getThumbnailCdnUrl(OG_IMAGE_URL) || `${URL}/public/v2-og.png`;
// https://developers.google.com/search/docs/data-types/video // https://developers.google.com/search/docs/data-types/video
const googleVideoMetadata = { const googleVideoMetadata = {