import { readFilePromise } from './miscs'
import { ServerInfo } from './servers'
import { getMyUserInformation } from './users'
+import { VideoPrivacy } from '../../../shared'
type VideoAttributes = {
name?: string
description?: string
tags?: string[]
channelId?: number
+ privacy?: VideoPrivacy
fixture?: string
}
return makeGetRequest(url, path)
}
-function getAllVideosListBy (url: string) {
- const path = '/api/v1/videos'
+function getVideoPrivacies (url: string) {
+ const path = '/api/v1/videos/privacies'
+
+ return makeGetRequest(url, path)
+}
+
+function getVideo (url: string, id: number | string, expectedStatus = 200) {
+ const path = '/api/v1/videos/' + id
return request(url)
.get(path)
- .query({ sort: 'createdAt' })
- .query({ start: 0 })
- .query({ count: 10000 })
.set('Accept', 'application/json')
- .expect(200)
- .expect('Content-Type', /json/)
+ .expect(expectedStatus)
}
-function getVideo (url: string, id: number | string) {
+function viewVideo (url: string, id: number | string, expectedStatus = 204) {
+ const path = '/api/v1/videos/' + id + '/views'
+
+ return request(url)
+ .post(path)
+ .set('Accept', 'application/json')
+ .expect(expectedStatus)
+}
+
+function getVideoWithToken (url: string, token: string, id: number | string, expectedStatus = 200) {
const path = '/api/v1/videos/' + id
return request(url)
- .get(path)
- .set('Accept', 'application/json')
- .expect(200)
- .expect('Content-Type', /json/)
+ .get(path)
+ .set('Authorization', 'Bearer ' + token)
+ .set('Accept', 'application/json')
+ .expect(expectedStatus)
}
function getVideoDescription (url: string, descriptionPath: string) {
.expect('Content-Type', /json/)
}
+function getMyVideos (url: string, accessToken: string, start: number, count: number, sort?: string) {
+ const path = '/api/v1/users/me/videos'
+
+ const req = request(url)
+ .get(path)
+ .query({ start: start })
+ .query({ count: count })
+
+ if (sort) req.query({ sort })
+
+ return req.set('Accept', 'application/json')
+ .set('Authorization', 'Bearer ' + accessToken)
+ .expect(200)
+ .expect('Content-Type', /json/)
+}
+
function getVideosListPagination (url: string, start: number, count: number, sort?: string) {
const path = '/api/v1/videos'
nsfw: true,
description: 'my super description',
tags: [ 'tag' ],
+ privacy: VideoPrivacy.PUBLIC,
fixture: 'video_short.webm'
}
attributes = Object.assign(attributes, videoAttributesArg)
.field('licence', attributes.licence.toString())
.field('nsfw', JSON.stringify(attributes.nsfw))
.field('description', attributes.description)
+ .field('privacy', attributes.privacy.toString())
.field('channelId', attributes.channelId)
if (attributes.language !== undefined) {
if (attributes.nsfw) body['nsfw'] = attributes.nsfw
if (attributes.description) body['description'] = attributes.description
if (attributes.tags) body['tags'] = attributes.tags
+ if (attributes.privacy) body['privacy'] = attributes.privacy
return request(url)
.put(path)
getVideoDescription,
getVideoCategories,
getVideoLicences,
+ getVideoPrivacies,
getVideoLanguages,
- getAllVideosListBy,
+ getMyVideos,
getVideo,
+ getVideoWithToken,
getVideosList,
getVideosListPagination,
getVideosListSort,
uploadVideo,
updateVideo,
rateVideo,
+ viewVideo,
parseTorrentVideo
}