From 77b70702d2193d78bf6fbd07f0fc7335e34957f8 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 28 Aug 2023 10:55:04 +0200 Subject: Add video chapters support --- packages/server-commands/src/server/server.ts | 3 ++ .../server-commands/src/videos/chapters-command.ts | 38 ++++++++++++++++++++++ packages/server-commands/src/videos/index.ts | 1 + 3 files changed, 42 insertions(+) create mode 100644 packages/server-commands/src/videos/chapters-command.ts (limited to 'packages/server-commands') diff --git a/packages/server-commands/src/server/server.ts b/packages/server-commands/src/server/server.ts index 57a897c17..3911a6fad 100644 --- a/packages/server-commands/src/server/server.ts +++ b/packages/server-commands/src/server/server.ts @@ -30,6 +30,7 @@ import { ChangeOwnershipCommand, ChannelsCommand, ChannelSyncsCommand, + ChaptersCommand, CommentsCommand, HistoryCommand, ImportsCommand, @@ -152,6 +153,7 @@ export class PeerTubeServer { videoPasswords?: VideoPasswordsCommand storyboard?: StoryboardCommand + chapters?: ChaptersCommand runners?: RunnersCommand runnerRegistrationTokens?: RunnerRegistrationTokensCommand @@ -442,6 +444,7 @@ export class PeerTubeServer { this.registrations = new RegistrationsCommand(this) this.storyboard = new StoryboardCommand(this) + this.chapters = new ChaptersCommand(this) this.runners = new RunnersCommand(this) this.runnerRegistrationTokens = new RunnerRegistrationTokensCommand(this) diff --git a/packages/server-commands/src/videos/chapters-command.ts b/packages/server-commands/src/videos/chapters-command.ts new file mode 100644 index 000000000..8a75c7fae --- /dev/null +++ b/packages/server-commands/src/videos/chapters-command.ts @@ -0,0 +1,38 @@ +import { + HttpStatusCode, VideoChapterUpdate, VideoChapters +} 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({ + ...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 + }) + } +} diff --git a/packages/server-commands/src/videos/index.ts b/packages/server-commands/src/videos/index.ts index 970026d51..8d193e24c 100644 --- a/packages/server-commands/src/videos/index.ts +++ b/packages/server-commands/src/videos/index.ts @@ -3,6 +3,7 @@ export * from './captions-command.js' export * from './change-ownership-command.js' export * from './channels.js' export * from './channels-command.js' +export * from './chapters-command.js' export * from './channel-syncs-command.js' export * from './comments-command.js' export * from './history-command.js' -- cgit v1.2.3