-function addOpenGraphAndOEmbedTags (htmlStringPage: string, video: VideoModel) {
- const previewUrl = CONFIG.WEBSERVER.URL + STATIC_PATHS.PREVIEWS + video.getPreviewName()
- const videoUrl = CONFIG.WEBSERVER.URL + '/videos/watch/' + video.uuid
-
- const videoNameEscaped = escapeHTML(video.name)
- const videoDescriptionEscaped = escapeHTML(video.description)
- const embedUrl = CONFIG.WEBSERVER.URL + video.getEmbedPath()
-
- const openGraphMetaTags = {
- 'og:type': 'video',
- 'og:title': videoNameEscaped,
- 'og:image': previewUrl,
- 'og:url': videoUrl,
- 'og:description': videoDescriptionEscaped,
-
- 'og:video:url': embedUrl,
- 'og:video:secure_url': embedUrl,
- 'og:video:type': 'text/html',
- 'og:video:width': EMBED_SIZE.width,
- 'og:video:height': EMBED_SIZE.height,
-
- 'name': videoNameEscaped,
- 'description': videoDescriptionEscaped,
- 'image': previewUrl,
-
- 'twitter:card': 'summary_large_image',
- 'twitter:site': '@Chocobozzz',
- 'twitter:title': videoNameEscaped,
- 'twitter:description': videoDescriptionEscaped,
- 'twitter:image': previewUrl,
- 'twitter:player': embedUrl,
- 'twitter:player:width': EMBED_SIZE.width,
- 'twitter:player:height': EMBED_SIZE.height
- }
-
- const oembedLinkTags = [
- {
- type: 'application/json+oembed',
- href: CONFIG.WEBSERVER.URL + '/services/oembed?url=' + encodeURIComponent(videoUrl),
- title: videoNameEscaped
- }
- ]
-
- const schemaTags = {
- name: videoNameEscaped,
- description: videoDescriptionEscaped,
- duration: video.getActivityStreamDuration(),
- thumbnailURL: previewUrl,
- contentURL: videoUrl,
- embedURL: embedUrl,
- uploadDate: video.createdAt
- }
-
- let tagsString = ''
- Object.keys(openGraphMetaTags).forEach(tagName => {
- const tagValue = openGraphMetaTags[tagName]
-
- tagsString += `<meta property="${tagName}" content="${tagValue}" />`
- })
-
- for (const oembedLinkTag of oembedLinkTags) {
- tagsString += `<link rel="alternate" type="${oembedLinkTag.type}" href="${oembedLinkTag.href}" title="${oembedLinkTag.title}" />`
- }
-
- tagsString += '<div itemprop="video" itemscope itemtype="http://schema.org/VideoObject">'
- tagsString += '<h2>Video: <span itemprop="name">' + schemaTags.name + '</span></h2>'
-
- Object.keys(schemaTags).forEach(tagName => {
- const tagValue = schemaTags[tagName]
- tagsString += `<meta itemprop="${tagName}" content="${tagValue}" />`
- })
-
- tagsString += '</div>'