]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - shared/extra-utils/videos/videos.ts
Introduce history command
[github/Chocobozzz/PeerTube.git] / shared / extra-utils / videos / videos.ts
index a3a276188f89e7a6e8970cfa12800fe3190ec5f9..920c930727e949dbdfd54c1a3af4bd49f6e22575 100644 (file)
@@ -6,11 +6,11 @@ import got, { Response as GotResponse } from 'got/dist/source'
 import * as parseTorrent from 'parse-torrent'
 import { join } from 'path'
 import * as request from 'supertest'
-import { v4 as uuidv4 } from 'uuid'
 import validator from 'validator'
 import { getLowercaseExtension } from '@server/helpers/core-utils'
+import { buildUUID } from '@server/helpers/uuid'
 import { HttpStatusCode } from '@shared/core-utils'
-import { VideosCommonQuery } from '@shared/models'
+import { BooleanBothQuery, VideosCommonQuery } from '@shared/models'
 import { loadLanguages, VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES, VIDEO_PRIVACIES } from '../../../server/initializers/constants'
 import { VideoDetails, VideoPrivacy } from '../../models/videos'
 import {
@@ -159,7 +159,7 @@ function getVideosList (url: string) {
           .expect('Content-Type', /json/)
 }
 
-function getVideosListWithToken (url: string, token: string, query: { nsfw?: boolean } = {}) {
+function getVideosListWithToken (url: string, token: string, query: { nsfw?: BooleanBothQuery } = {}) {
   const path = '/api/v1/videos'
 
   return request(url)
@@ -219,7 +219,7 @@ function getAccountVideos (
   count: number,
   sort?: string,
   query: {
-    nsfw?: boolean
+    nsfw?: BooleanBothQuery
     search?: string
   } = {}
 ) {
@@ -245,7 +245,7 @@ function getVideoChannelVideos (
   start: number,
   count: number,
   sort?: string,
-  query: { nsfw?: boolean } = {}
+  query: { nsfw?: BooleanBothQuery } = {}
 ) {
   const path = '/api/v1/video-channels/' + videoChannelName + '/videos'
 
@@ -262,28 +262,6 @@ function getVideoChannelVideos (
   })
 }
 
-function getPlaylistVideos (
-  url: string,
-  accessToken: string,
-  playlistId: number | string,
-  start: number,
-  count: number,
-  query: { nsfw?: boolean } = {}
-) {
-  const path = '/api/v1/video-playlists/' + playlistId + '/videos'
-
-  return makeGetRequest({
-    url,
-    path,
-    query: immutableAssign(query, {
-      start,
-      count
-    }),
-    token: accessToken,
-    statusCodeExpected: HttpStatusCode.OK_200
-  })
-}
-
 function getVideosListPagination (url: string, start: number, count: number, sort?: string, skipCount?: boolean) {
   const path = '/api/v1/videos'
 
@@ -806,7 +784,7 @@ async function uploadVideoAndGetId (options: {
 
   const res = await uploadVideo(options.server.url, options.token || options.server.accessToken, videoAttrs)
 
-  return { id: res.body.video.id, uuid: res.body.video.uuid }
+  return res.body.video as { id: number, uuid: string, shortUUID: string }
 }
 
 async function getLocalIdByUUID (url: string, uuid: string) {
@@ -827,7 +805,7 @@ async function uploadRandomVideoOnServers (servers: ServerInfo[], serverNumber:
 
 async function uploadRandomVideo (server: ServerInfo, wait = true, additionalParams: any = {}) {
   const prefixName = additionalParams.prefixName || ''
-  const name = prefixName + uuidv4()
+  const name = prefixName + buildUUID()
 
   const data = Object.assign({ name }, additionalParams)
   const res = await uploadVideo(server.url, server.accessToken, data)
@@ -871,7 +849,6 @@ export {
   getLocalVideos,
   completeVideoCheck,
   checkVideoFilesWereRemoved,
-  getPlaylistVideos,
   getMyVideosWithFilter,
   uploadVideoAndGetId,
   getLocalIdByUUID,