Add schema.org tags to videos
This commit is contained in:
parent
63c4b44961
commit
093237cf79
2 changed files with 26 additions and 2 deletions
|
@ -84,6 +84,16 @@ function addOpenGraphAndOEmbedTags (htmlStringPage: string, video: VideoModel) {
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
const schemaTags = {
|
||||||
|
name: videoNameEscaped,
|
||||||
|
description: videoDescriptionEscaped,
|
||||||
|
duration: video.getActivityStreamDuration(),
|
||||||
|
thumbnailURL: previewUrl,
|
||||||
|
contentURL: videoUrl,
|
||||||
|
embedURL: embedUrl,
|
||||||
|
uploadDate: video.createdAt
|
||||||
|
}
|
||||||
|
|
||||||
let tagsString = ''
|
let tagsString = ''
|
||||||
Object.keys(openGraphMetaTags).forEach(tagName => {
|
Object.keys(openGraphMetaTags).forEach(tagName => {
|
||||||
const tagValue = openGraphMetaTags[tagName]
|
const tagValue = openGraphMetaTags[tagName]
|
||||||
|
@ -95,6 +105,16 @@ function addOpenGraphAndOEmbedTags (htmlStringPage: string, video: VideoModel) {
|
||||||
tagsString += `<link rel="alternate" type="${oembedLinkTag.type}" href="${oembedLinkTag.href}" title="${oembedLinkTag.title}" />`
|
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>'
|
||||||
|
|
||||||
return htmlStringPage.replace(OPENGRAPH_AND_OEMBED_COMMENT, tagsString)
|
return htmlStringPage.replace(OPENGRAPH_AND_OEMBED_COMMENT, tagsString)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -990,8 +990,7 @@ export class VideoModel extends Model<VideoModel> {
|
||||||
type: 'Video' as 'Video',
|
type: 'Video' as 'Video',
|
||||||
id: this.url,
|
id: this.url,
|
||||||
name: this.name,
|
name: this.name,
|
||||||
// https://www.w3.org/TR/activitystreams-vocabulary/#dfn-duration
|
duration: this.getActivityStreamDuration(),
|
||||||
duration: 'PT' + this.duration + 'S',
|
|
||||||
uuid: this.uuid,
|
uuid: this.uuid,
|
||||||
tag,
|
tag,
|
||||||
category,
|
category,
|
||||||
|
@ -1161,6 +1160,11 @@ export class VideoModel extends Model<VideoModel> {
|
||||||
return unlinkPromise(torrentPath)
|
return unlinkPromise(torrentPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getActivityStreamDuration () {
|
||||||
|
// https://www.w3.org/TR/activitystreams-vocabulary/#dfn-duration
|
||||||
|
return 'PT' + this.duration + 'S'
|
||||||
|
}
|
||||||
|
|
||||||
private getBaseUrls () {
|
private getBaseUrls () {
|
||||||
let baseUrlHttp
|
let baseUrlHttp
|
||||||
let baseUrlWs
|
let baseUrlWs
|
||||||
|
|
Loading…
Reference in a new issue