import { expect } from 'chai'
import { createReadStream, stat } from 'fs-extra'
import got, { Response as GotResponse } from 'got'
-import { omit } from 'lodash'
import validator from 'validator'
-import { buildAbsoluteFixturePath, pick, wait } from '@shared/core-utils'
+import { buildAbsoluteFixturePath, getAllPrivacies, omit, pick, wait } from '@shared/core-utils'
import { buildUUID } from '@shared/extra-utils'
import {
HttpStatusCode,
VideoCreateResult,
VideoDetails,
VideoFileMetadata,
+ VideoInclude,
VideoPrivacy,
VideosCommonQuery,
VideoTranscodingCreate
} from '@shared/models'
+import { VideoSource } from '@shared/models/videos/video-source'
import { unwrapBody } from '../requests'
import { waitJobs } from '../server'
import { AbstractCommand, OverrideCommandOptions } from '../shared'
-import { VideoSource } from '@shared/models/videos/video-source'
export type VideoEdit = Partial<Omit<VideoCreate, 'thumbnailfile' | 'previewfile'>> & {
fixture?: string
})
}
+ listMySubscriptionVideos (options: OverrideCommandOptions & VideosCommonQuery = {}) {
+ const { sort = '-createdAt' } = options
+ const path = '/api/v1/users/me/subscriptions/videos'
+
+ return this.getRequestBody<ResultList<Video>>({
+ ...options,
+
+ path,
+ query: { sort, ...this.buildListQuery(options) },
+ implicitToken: true,
+ defaultExpectedStatus: HttpStatusCode.OK_200
+ })
+ }
+
// ---------------------------------------------------------------------------
list (options: OverrideCommandOptions & VideosCommonQuery = {}) {
})
}
+ listAllForAdmin (options: OverrideCommandOptions & VideosCommonQuery = {}) {
+ const include = VideoInclude.NOT_PUBLISHED_STATE | VideoInclude.BLACKLISTED | VideoInclude.BLOCKED_OWNER
+ const nsfw = 'both'
+ const privacyOneOf = getAllPrivacies()
+
+ return this.list({
+ ...options,
+
+ include,
+ nsfw,
+ privacyOneOf,
+
+ token: this.buildCommonRequestToken({ ...options, implicitToken: true })
+ })
+ }
+
listByAccount (options: OverrideCommandOptions & VideosCommonQuery & {
handle: string
}) {
async upload (options: OverrideCommandOptions & {
attributes?: VideoEdit
mode?: 'legacy' | 'resumable' // default legacy
+ waitTorrentGeneration?: boolean // default true
} = {}) {
- const { mode = 'legacy' } = options
+ const { mode = 'legacy', waitTorrentGeneration = true } = options
let defaultChannelId = 1
try {
// Wait torrent generation
const expectedStatus = this.buildExpectedStatus({ ...options, defaultExpectedStatus: HttpStatusCode.OK_200 })
- if (expectedStatus === HttpStatusCode.OK_200) {
+ if (expectedStatus === HttpStatusCode.OK_200 && waitTorrentGeneration) {
let video: VideoDetails
do {
},
// Fixture will be sent later
- attaches: this.buildUploadAttaches(omit(options.attributes, 'fixture')),
+ attaches: this.buildUploadAttaches(omit(options.attributes, [ 'fixture' ])),
implicitToken: true,
defaultExpectedStatus: null
// ---------------------------------------------------------------------------
- removeHLSFiles (options: OverrideCommandOptions & {
+ removeHLSPlaylist (options: OverrideCommandOptions & {
videoId: number | string
}) {
const path = '/api/v1/videos/' + options.videoId + '/hls'
})
}
- removeWebTorrentFiles (options: OverrideCommandOptions & {
+ removeHLSFile (options: OverrideCommandOptions & {
+ videoId: number | string
+ fileId: number
+ }) {
+ const path = '/api/v1/videos/' + options.videoId + '/hls/' + options.fileId
+
+ return this.deleteRequest({
+ ...options,
+
+ path,
+ implicitToken: true,
+ defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
+ })
+ }
+
+ removeAllWebTorrentFiles (options: OverrideCommandOptions & {
videoId: number | string
}) {
const path = '/api/v1/videos/' + options.videoId + '/webtorrent'
})
}
+ removeWebTorrentFile (options: OverrideCommandOptions & {
+ videoId: number | string
+ fileId: number
+ }) {
+ const path = '/api/v1/videos/' + options.videoId + '/webtorrent/' + options.fileId
+
+ return this.deleteRequest({
+ ...options,
+
+ path,
+ implicitToken: true,
+ defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
+ })
+ }
+
runTranscoding (options: OverrideCommandOptions & {
videoId: number | string
transcodingType: 'hls' | 'webtorrent'
'categoryOneOf',
'licenceOneOf',
'languageOneOf',
+ 'privacyOneOf',
'tagsOneOf',
'tagsAllOf',
'isLocal',