diff options
author | Chocobozzz <me@florianbigard.com> | 2021-07-21 15:51:30 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-07-21 15:51:30 +0200 |
commit | a24bd1ed41b43790bab6ba789580bb4e85f07d85 (patch) | |
tree | a54b0f6c921ba83a6e909cd0ced325b2d4b8863c /shared/extra-utils/videos/video-captions.ts | |
parent | 5f26f13b3c16ac5ae0a3b0a7142d84a9528cf565 (diff) | |
parent | c63830f15403ac4e750829f27d8bbbdc9a59282c (diff) | |
download | PeerTube-a24bd1ed41b43790bab6ba789580bb4e85f07d85.tar.gz PeerTube-a24bd1ed41b43790bab6ba789580bb4e85f07d85.tar.zst PeerTube-a24bd1ed41b43790bab6ba789580bb4e85f07d85.zip |
Merge branch 'next' into develop
Diffstat (limited to 'shared/extra-utils/videos/video-captions.ts')
-rw-r--r-- | shared/extra-utils/videos/video-captions.ts | 72 |
1 files changed, 0 insertions, 72 deletions
diff --git a/shared/extra-utils/videos/video-captions.ts b/shared/extra-utils/videos/video-captions.ts deleted file mode 100644 index 62eec7b90..000000000 --- a/shared/extra-utils/videos/video-captions.ts +++ /dev/null | |||
@@ -1,72 +0,0 @@ | |||
1 | import { makeDeleteRequest, makeGetRequest, makeUploadRequest } from '../requests/requests' | ||
2 | import * as request from 'supertest' | ||
3 | import * as chai from 'chai' | ||
4 | import { buildAbsoluteFixturePath } from '../miscs/miscs' | ||
5 | import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' | ||
6 | |||
7 | const expect = chai.expect | ||
8 | |||
9 | function createVideoCaption (args: { | ||
10 | url: string | ||
11 | accessToken: string | ||
12 | videoId: string | number | ||
13 | language: string | ||
14 | fixture: string | ||
15 | mimeType?: string | ||
16 | statusCodeExpected?: number | ||
17 | }) { | ||
18 | const path = '/api/v1/videos/' + args.videoId + '/captions/' + args.language | ||
19 | |||
20 | const captionfile = buildAbsoluteFixturePath(args.fixture) | ||
21 | const captionfileAttach = args.mimeType ? [ captionfile, { contentType: args.mimeType } ] : captionfile | ||
22 | |||
23 | return makeUploadRequest({ | ||
24 | method: 'PUT', | ||
25 | url: args.url, | ||
26 | path, | ||
27 | token: args.accessToken, | ||
28 | fields: {}, | ||
29 | attaches: { | ||
30 | captionfile: captionfileAttach | ||
31 | }, | ||
32 | statusCodeExpected: args.statusCodeExpected || HttpStatusCode.NO_CONTENT_204 | ||
33 | }) | ||
34 | } | ||
35 | |||
36 | function listVideoCaptions (url: string, videoId: string | number) { | ||
37 | const path = '/api/v1/videos/' + videoId + '/captions' | ||
38 | |||
39 | return makeGetRequest({ | ||
40 | url, | ||
41 | path, | ||
42 | statusCodeExpected: HttpStatusCode.OK_200 | ||
43 | }) | ||
44 | } | ||
45 | |||
46 | function deleteVideoCaption (url: string, token: string, videoId: string | number, language: string) { | ||
47 | const path = '/api/v1/videos/' + videoId + '/captions/' + language | ||
48 | |||
49 | return makeDeleteRequest({ | ||
50 | url, | ||
51 | token, | ||
52 | path, | ||
53 | statusCodeExpected: HttpStatusCode.NO_CONTENT_204 | ||
54 | }) | ||
55 | } | ||
56 | |||
57 | async function testCaptionFile (url: string, captionPath: string, containsString: string) { | ||
58 | const res = await request(url) | ||
59 | .get(captionPath) | ||
60 | .expect(HttpStatusCode.OK_200) | ||
61 | |||
62 | expect(res.text).to.contain(containsString) | ||
63 | } | ||
64 | |||
65 | // --------------------------------------------------------------------------- | ||
66 | |||
67 | export { | ||
68 | createVideoCaption, | ||
69 | listVideoCaptions, | ||
70 | testCaptionFile, | ||
71 | deleteVideoCaption | ||
72 | } | ||