2021-07-08 16:49:51 +02:00
|
|
|
|
2021-07-16 14:27:30 +02:00
|
|
|
import { HttpStatusCode, ResultList } from '@shared/models'
|
2021-07-08 16:49:51 +02:00
|
|
|
import { VideoImport, VideoImportCreate } from '../../models/videos'
|
|
|
|
import { unwrapBody } from '../requests'
|
|
|
|
import { AbstractCommand, OverrideCommandOptions } from '../shared'
|
|
|
|
|
|
|
|
export class ImportsCommand extends AbstractCommand {
|
|
|
|
|
|
|
|
importVideo (options: OverrideCommandOptions & {
|
2023-02-24 14:48:15 +01:00
|
|
|
attributes: (VideoImportCreate | { torrentfile?: string, previewfile?: string, thumbnailfile?: string })
|
2021-07-08 16:49:51 +02:00
|
|
|
}) {
|
|
|
|
const { attributes } = options
|
|
|
|
const path = '/api/v1/videos/imports'
|
|
|
|
|
|
|
|
let attaches: any = {}
|
|
|
|
if (attributes.torrentfile) attaches = { torrentfile: attributes.torrentfile }
|
2023-02-24 14:48:15 +01:00
|
|
|
if (attributes.thumbnailfile) attaches = { thumbnailfile: attributes.thumbnailfile }
|
|
|
|
if (attributes.previewfile) attaches = { previewfile: attributes.previewfile }
|
2021-07-08 16:49:51 +02:00
|
|
|
|
|
|
|
return unwrapBody<VideoImport>(this.postUploadRequest({
|
|
|
|
...options,
|
|
|
|
|
|
|
|
path,
|
|
|
|
attaches,
|
|
|
|
fields: options.attributes,
|
|
|
|
implicitToken: true,
|
|
|
|
defaultExpectedStatus: HttpStatusCode.OK_200
|
|
|
|
}))
|
|
|
|
}
|
|
|
|
|
2022-01-19 14:23:00 +01:00
|
|
|
delete (options: OverrideCommandOptions & {
|
|
|
|
importId: number
|
|
|
|
}) {
|
|
|
|
const path = '/api/v1/videos/imports/' + options.importId
|
|
|
|
|
|
|
|
return this.deleteRequest({
|
|
|
|
...options,
|
|
|
|
|
|
|
|
path,
|
|
|
|
implicitToken: true,
|
|
|
|
defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
cancel (options: OverrideCommandOptions & {
|
|
|
|
importId: number
|
|
|
|
}) {
|
|
|
|
const path = '/api/v1/videos/imports/' + options.importId + '/cancel'
|
|
|
|
|
|
|
|
return this.postBodyRequest({
|
|
|
|
...options,
|
|
|
|
|
|
|
|
path,
|
|
|
|
implicitToken: true,
|
|
|
|
defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2021-07-08 16:49:51 +02:00
|
|
|
getMyVideoImports (options: OverrideCommandOptions & {
|
|
|
|
sort?: string
|
2022-01-19 14:58:16 +01:00
|
|
|
targetUrl?: string
|
2022-08-10 11:51:13 +02:00
|
|
|
videoChannelSyncId?: number
|
|
|
|
search?: string
|
2021-07-08 16:49:51 +02:00
|
|
|
} = {}) {
|
2022-08-10 11:51:13 +02:00
|
|
|
const { sort, targetUrl, videoChannelSyncId, search } = options
|
2021-07-08 16:49:51 +02:00
|
|
|
const path = '/api/v1/users/me/videos/imports'
|
|
|
|
|
|
|
|
return this.getRequestBody<ResultList<VideoImport>>({
|
|
|
|
...options,
|
|
|
|
|
|
|
|
path,
|
2022-08-10 11:51:13 +02:00
|
|
|
query: { sort, targetUrl, videoChannelSyncId, search },
|
2021-07-08 16:49:51 +02:00
|
|
|
implicitToken: true,
|
|
|
|
defaultExpectedStatus: HttpStatusCode.OK_200
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|