ニジカ投稿局 https://tv.nizika.tv
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

simulate-many-viewers-worker.ts 550 B

1234567891011121314151617
  1. import Bluebird from 'bluebird'
  2. import { PeerTubeServer } from '@peertube/peertube-server-commands'
  3. module.exports = async function sendViews (options: {
  4. url: string
  5. videoId: number
  6. viewers: { xForwardedFor: string }[]
  7. }) {
  8. const { url, videoId, viewers } = options
  9. const server = new PeerTubeServer({ url })
  10. await Bluebird.map(viewers, viewer => {
  11. return server.views.simulateView({ id: videoId, xForwardedFor: viewer.xForwardedFor })
  12. .catch(err => console.error('Cannot simulate viewer', err))
  13. }, { concurrency: 500 })
  14. }