mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2024-09-11 21:47:09 +03:00
18 lines
550 B
TypeScript
18 lines
550 B
TypeScript
import Bluebird from 'bluebird'
|
|
import { PeerTubeServer } from '@peertube/peertube-server-commands'
|
|
|
|
module.exports = async function sendViews (options: {
|
|
url: string
|
|
videoId: number
|
|
viewers: { xForwardedFor: string }[]
|
|
}) {
|
|
const { url, videoId, viewers } = options
|
|
|
|
const server = new PeerTubeServer({ url })
|
|
|
|
await Bluebird.map(viewers, viewer => {
|
|
return server.views.simulateView({ id: videoId, xForwardedFor: viewer.xForwardedFor })
|
|
.catch(err => console.error('Cannot simulate viewer', err))
|
|
}, { concurrency: 500 })
|
|
}
|