Server: use preview image for opengraph
This commit is contained in:
parent
55723d16fd
commit
41b5da1d8c
|
@ -33,25 +33,36 @@ module.exports = router
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
function addOpenGraphTags (htmlStringPage, video) {
|
function addOpenGraphTags (htmlStringPage, video) {
|
||||||
const thumbnailUrl = constants.CONFIG.WEBSERVER.URL + video.thumbnailPath
|
|
||||||
const videoUrl = constants.CONFIG.WEBSERVER.URL + '/videos/watch/'
|
const videoUrl = constants.CONFIG.WEBSERVER.URL + '/videos/watch/'
|
||||||
|
let baseUrlHttp
|
||||||
|
|
||||||
|
if (video.isOwned()) {
|
||||||
|
baseUrlHttp = constants.CONFIG.WEBSERVER.URL
|
||||||
|
} else {
|
||||||
|
baseUrlHttp = constants.REMOTE_SCHEME.HTTP + '://' + video.podUrl
|
||||||
|
}
|
||||||
|
|
||||||
|
// We fetch the remote preview (bigger than the thumbnail)
|
||||||
|
// This should not overhead the remote server since social websites put in a cache the OpenGraph tags
|
||||||
|
// We can't use the thumbnail because these social websites want bigger images (> 200x200 for Facebook for example)
|
||||||
|
const previewUrl = baseUrlHttp + constants.STATIC_PATHS.PREVIEWS + video.getPreviewName()
|
||||||
|
|
||||||
const metaTags = {
|
const metaTags = {
|
||||||
'og:type': 'video',
|
'og:type': 'video',
|
||||||
'og:title': video.name,
|
'og:title': video.name,
|
||||||
'og:image': thumbnailUrl,
|
'og:image': previewUrl,
|
||||||
'og:url': videoUrl,
|
'og:url': videoUrl,
|
||||||
'og:description': video.description,
|
'og:description': video.description,
|
||||||
|
|
||||||
'name': video.name,
|
'name': video.name,
|
||||||
'description': video.description,
|
'description': video.description,
|
||||||
'image': thumbnailUrl,
|
'image': previewUrl,
|
||||||
|
|
||||||
'twitter:card': 'summary_large_image',
|
'twitter:card': 'summary_large_image',
|
||||||
'twitter:site': '@Chocobozzz',
|
'twitter:site': '@Chocobozzz',
|
||||||
'twitter:title': video.name,
|
'twitter:title': video.name,
|
||||||
'twitter:description': video.description,
|
'twitter:description': video.description,
|
||||||
'twitter:image': thumbnailUrl
|
'twitter:image': previewUrl
|
||||||
}
|
}
|
||||||
|
|
||||||
let tagsString = ''
|
let tagsString = ''
|
||||||
|
|
|
@ -31,7 +31,7 @@ function isEachRemoteVideosValid (requests) {
|
||||||
isVideoDateValid(video.createdDate) &&
|
isVideoDateValid(video.createdDate) &&
|
||||||
isVideoDescriptionValid(video.description) &&
|
isVideoDescriptionValid(video.description) &&
|
||||||
isVideoDurationValid(video.duration) &&
|
isVideoDurationValid(video.duration) &&
|
||||||
isVideoMagnetValid(video.magnetUri) &&
|
isVideoMagnetValid(video.magnet) &&
|
||||||
isVideoNameValid(video.name) &&
|
isVideoNameValid(video.name) &&
|
||||||
isVideoPodUrlValid(video.podUrl) &&
|
isVideoPodUrlValid(video.podUrl) &&
|
||||||
isVideoTagsValid(video.tags) &&
|
isVideoTagsValid(video.tags) &&
|
||||||
|
@ -63,7 +63,7 @@ function isVideoDurationValid (value) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function isVideoMagnetValid (value) {
|
function isVideoMagnetValid (value) {
|
||||||
return validator.isLength(value.infoHash, VIDEOS_CONSTRAINTS_FIELDS.MAGNET.XT)
|
return validator.isLength(value.infoHash, VIDEOS_CONSTRAINTS_FIELDS.MAGNET.INFO_HASH)
|
||||||
}
|
}
|
||||||
|
|
||||||
function isVideoNameValid (value) {
|
function isVideoNameValid (value) {
|
||||||
|
|
|
@ -67,7 +67,7 @@ const CONSTRAINTS_FIELDS = {
|
||||||
NAME: { min: 3, max: 50 }, // Length
|
NAME: { min: 3, max: 50 }, // Length
|
||||||
DESCRIPTION: { min: 3, max: 250 }, // Length
|
DESCRIPTION: { min: 3, max: 250 }, // Length
|
||||||
MAGNET: {
|
MAGNET: {
|
||||||
XT: { min: 10 } // Length
|
INFO_HASH: { min: 10, max: 50 } // Length
|
||||||
},
|
},
|
||||||
DURATION: { min: 1, max: 7200 }, // Number
|
DURATION: { min: 1, max: 7200 }, // Number
|
||||||
TAGS: { min: 1, max: 3 }, // Number of total tags
|
TAGS: { min: 1, max: 3 }, // Number of total tags
|
||||||
|
|
|
@ -160,7 +160,7 @@ function generateMagnetUri () {
|
||||||
baseUrlHttp = constants.CONFIG.WEBSERVER.URL
|
baseUrlHttp = constants.CONFIG.WEBSERVER.URL
|
||||||
baseUrlWs = constants.CONFIG.WEBSERVER.WS + '://' + constants.CONFIG.WEBSERVER.HOSTNAME + ':' + constants.CONFIG.WEBSERVER.PORT
|
baseUrlWs = constants.CONFIG.WEBSERVER.WS + '://' + constants.CONFIG.WEBSERVER.HOSTNAME + ':' + constants.CONFIG.WEBSERVER.PORT
|
||||||
} else {
|
} else {
|
||||||
baseUrlHttp = constants.REMOTE_SCHEME.HTTP + this.podUrl
|
baseUrlHttp = constants.REMOTE_SCHEME.HTTP + '://' + this.podUrl
|
||||||
baseUrlWs = constants.REMOTE_SCHEME.WS + this.podUrl
|
baseUrlWs = constants.REMOTE_SCHEME.WS + this.podUrl
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue