+function addVideosToFeed (feed: Feed, videos: VideoModel[]) {
+ for (const video of videos) {
+ const formattedVideoFiles = video.getFormattedVideoFilesJSON(false)
+
+ const torrents = formattedVideoFiles.map(videoFile => ({
+ title: video.name,
+ url: videoFile.torrentUrl,
+ size_in_bytes: videoFile.size
+ }))
+
+ const videoFiles = formattedVideoFiles.map(videoFile => {
+ const result = {
+ type: MIMETYPES.VIDEO.EXT_MIMETYPE[extname(videoFile.fileUrl)],
+ medium: 'video',
+ height: videoFile.resolution.id,
+ fileSize: videoFile.size,
+ url: videoFile.fileUrl,
+ framerate: videoFile.fps,
+ duration: video.duration
+ }
+
+ if (video.language) Object.assign(result, { lang: video.language })
+
+ return result
+ })
+
+ const categories: { value: number, label: string }[] = []
+ if (video.category) {
+ categories.push({
+ value: video.category,
+ label: getCategoryLabel(video.category)
+ })
+ }
+
+ const localLink = WEBSERVER.URL + video.getWatchStaticPath()
+
+ feed.addItem({
+ title: video.name,
+ id: localLink,
+ link: localLink,
+ description: mdToOneLinePlainText(video.getTruncatedDescription()),
+ content: toSafeHtml(video.description),
+ author: [
+ {
+ name: video.VideoChannel.Account.getDisplayName(),
+ link: video.VideoChannel.Account.Actor.url
+ }
+ ],
+ date: video.publishedAt,
+ nsfw: video.nsfw,
+ torrents,
+
+ // Enclosure
+ video: videoFiles.length !== 0
+ ? {
+ url: videoFiles[0].url,
+ length: videoFiles[0].fileSize,
+ type: videoFiles[0].type
+ }
+ : undefined,
+
+ // Media RSS
+ videos: videoFiles,
+
+ embed: {
+ url: WEBSERVER.URL + video.getEmbedStaticPath(),
+ allowFullscreen: true
+ },
+ player: {
+ url: WEBSERVER.URL + video.getWatchStaticPath()
+ },
+ categories,
+ community: {
+ statistics: {
+ views: video.views
+ }
+ },
+ thumbnails: [
+ {
+ url: WEBSERVER.URL + video.getPreviewStaticPath(),
+ height: PREVIEWS_SIZE.height,
+ width: PREVIEWS_SIZE.width
+ }
+ ]
+ })
+ }
+}
+
+function sendFeed (feed: Feed, req: express.Request, res: express.Response) {