+function addVideosToFeed (feed, videos: VideoModel[]) {
+ /**
+ * Adding video items to the feed object, one at a time
+ */
+ 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 videos = formattedVideoFiles.map(videoFile => {
+ const result = {
+ type: 'video/mp4',
+ medium: 'video',
+ height: videoFile.resolution.label.replace('p', ''),
+ 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)
+ })
+ }
+
+ feed.addItem({
+ title: video.name,
+ id: video.url,
+ link: WEBSERVER.URL + video.getWatchStaticPath(),
+ description: video.getTruncatedDescription(),
+ content: video.description,
+ author: [
+ {
+ name: video.VideoChannel.Account.getDisplayName(),
+ link: video.VideoChannel.Account.Actor.url
+ }
+ ],
+ date: video.publishedAt,
+ nsfw: video.nsfw,
+ torrent: torrents,
+ videos,
+ embed: {
+ url: video.getEmbedStaticPath(),
+ allowFullscreen: true
+ },
+ player: {
+ url: video.getWatchStaticPath()
+ },
+ categories,
+ community: {
+ statistics: {
+ views: video.views
+ }
+ },
+ thumbnail: [
+ {
+ url: WEBSERVER.URL + video.getPreviewStaticPath(),
+ height: PREVIEWS_SIZE.height,
+ width: PREVIEWS_SIZE.width
+ }
+ ]
+ })
+ }
+}
+