diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/controllers/client.ts | 20 | ||||
-rw-r--r-- | server/models/video/video.ts | 8 |
2 files changed, 26 insertions, 2 deletions
diff --git a/server/controllers/client.ts b/server/controllers/client.ts index 39e046727..bb02f5075 100644 --- a/server/controllers/client.ts +++ b/server/controllers/client.ts | |||
@@ -84,6 +84,16 @@ function addOpenGraphAndOEmbedTags (htmlStringPage: string, video: VideoModel) { | |||
84 | } | 84 | } |
85 | ] | 85 | ] |
86 | 86 | ||
87 | const schemaTags = { | ||
88 | name: videoNameEscaped, | ||
89 | description: videoDescriptionEscaped, | ||
90 | duration: video.getActivityStreamDuration(), | ||
91 | thumbnailURL: previewUrl, | ||
92 | contentURL: videoUrl, | ||
93 | embedURL: embedUrl, | ||
94 | uploadDate: video.createdAt | ||
95 | } | ||
96 | |||
87 | let tagsString = '' | 97 | let tagsString = '' |
88 | Object.keys(openGraphMetaTags).forEach(tagName => { | 98 | Object.keys(openGraphMetaTags).forEach(tagName => { |
89 | const tagValue = openGraphMetaTags[tagName] | 99 | const tagValue = openGraphMetaTags[tagName] |
@@ -95,6 +105,16 @@ function addOpenGraphAndOEmbedTags (htmlStringPage: string, video: VideoModel) { | |||
95 | tagsString += `<link rel="alternate" type="${oembedLinkTag.type}" href="${oembedLinkTag.href}" title="${oembedLinkTag.title}" />` | 105 | tagsString += `<link rel="alternate" type="${oembedLinkTag.type}" href="${oembedLinkTag.href}" title="${oembedLinkTag.title}" />` |
96 | } | 106 | } |
97 | 107 | ||
108 | tagsString += '<div itemprop="video" itemscope itemtype="http://schema.org/VideoObject">' | ||
109 | tagsString += '<h2>Video: <span itemprop="name">' + schemaTags.name + '</span></h2>' | ||
110 | |||
111 | Object.keys(schemaTags).forEach(tagName => { | ||
112 | const tagValue = schemaTags[tagName] | ||
113 | tagsString += `<meta itemprop="${tagName}" content="${tagValue}" />` | ||
114 | }) | ||
115 | |||
116 | tagsString += '</div>' | ||
117 | |||
98 | return htmlStringPage.replace(OPENGRAPH_AND_OEMBED_COMMENT, tagsString) | 118 | return htmlStringPage.replace(OPENGRAPH_AND_OEMBED_COMMENT, tagsString) |
99 | } | 119 | } |
100 | 120 | ||
diff --git a/server/models/video/video.ts b/server/models/video/video.ts index 77c0400d8..81d8a64ff 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts | |||
@@ -990,8 +990,7 @@ export class VideoModel extends Model<VideoModel> { | |||
990 | type: 'Video' as 'Video', | 990 | type: 'Video' as 'Video', |
991 | id: this.url, | 991 | id: this.url, |
992 | name: this.name, | 992 | name: this.name, |
993 | // https://www.w3.org/TR/activitystreams-vocabulary/#dfn-duration | 993 | duration: this.getActivityStreamDuration(), |
994 | duration: 'PT' + this.duration + 'S', | ||
995 | uuid: this.uuid, | 994 | uuid: this.uuid, |
996 | tag, | 995 | tag, |
997 | category, | 996 | category, |
@@ -1161,6 +1160,11 @@ export class VideoModel extends Model<VideoModel> { | |||
1161 | return unlinkPromise(torrentPath) | 1160 | return unlinkPromise(torrentPath) |
1162 | } | 1161 | } |
1163 | 1162 | ||
1163 | getActivityStreamDuration () { | ||
1164 | // https://www.w3.org/TR/activitystreams-vocabulary/#dfn-duration | ||
1165 | return 'PT' + this.duration + 'S' | ||
1166 | } | ||
1167 | |||
1164 | private getBaseUrls () { | 1168 | private getBaseUrls () { |
1165 | let baseUrlHttp | 1169 | let baseUrlHttp |
1166 | let baseUrlWs | 1170 | let baseUrlWs |