aboutsummaryrefslogtreecommitdiffhomepage
path: root/packages/server-commands/src/videos/chapters-command.ts
blob: c15388c8a5c95d06c7aa094e9009eb0e31379662 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { HttpStatusCode, VideoChapter, VideoChapterUpdate } from '@peertube/peertube-models'
import { AbstractCommand, OverrideCommandOptions } from '../shared/index.js'

export class ChaptersCommand extends AbstractCommand {

  list (options: OverrideCommandOptions & {
    videoId: string | number
  }) {
    const path = '/api/v1/videos/' + options.videoId + '/chapters'

    return this.getRequestBody<{ chapters: VideoChapter[] }>({
      ...options,

      path,
      implicitToken: true,
      defaultExpectedStatus: HttpStatusCode.OK_200
    })
  }

  update (options: OverrideCommandOptions & VideoChapterUpdate & {
    videoId: number | string
  }) {
    const path = '/api/v1/videos/' + options.videoId + '/chapters'

    return this.putBodyRequest({
      ...options,

      path,
      fields: {
        chapters: options.chapters
      },
      implicitToken: true,
      defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
    })
  }
}