diff options
Diffstat (limited to 'shared/extra-utils/videos/videos.ts')
-rw-r--r-- | shared/extra-utils/videos/videos.ts | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/shared/extra-utils/videos/videos.ts b/shared/extra-utils/videos/videos.ts index 7a77a03ad..39a06b0d7 100644 --- a/shared/extra-utils/videos/videos.ts +++ b/shared/extra-utils/videos/videos.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | /* tslint:disable:no-unused-expression */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/no-floating-promises */ |
2 | 2 | ||
3 | import { expect } from 'chai' | 3 | import { expect } from 'chai' |
4 | import { pathExists, readdir, readFile } from 'fs-extra' | 4 | import { pathExists, readdir, readFile } from 'fs-extra' |
@@ -488,7 +488,7 @@ async function completeVideoCheck ( | |||
488 | description: string | 488 | description: string |
489 | publishedAt?: string | 489 | publishedAt?: string |
490 | support: string | 490 | support: string |
491 | originallyPublishedAt?: string, | 491 | originallyPublishedAt?: string |
492 | account: { | 492 | account: { |
493 | name: string | 493 | name: string |
494 | host: string | 494 | host: string |
@@ -509,7 +509,7 @@ async function completeVideoCheck ( | |||
509 | files: { | 509 | files: { |
510 | resolution: number | 510 | resolution: number |
511 | size: number | 511 | size: number |
512 | }[], | 512 | }[] |
513 | thumbnailfile?: string | 513 | thumbnailfile?: string |
514 | previewfile?: string | 514 | previewfile?: string |
515 | } | 515 | } |
@@ -583,9 +583,10 @@ async function completeVideoCheck ( | |||
583 | 583 | ||
584 | const minSize = attributeFile.size - ((10 * attributeFile.size) / 100) | 584 | const minSize = attributeFile.size - ((10 * attributeFile.size) / 100) |
585 | const maxSize = attributeFile.size + ((10 * attributeFile.size) / 100) | 585 | const maxSize = attributeFile.size + ((10 * attributeFile.size) / 100) |
586 | expect(file.size, | 586 | expect( |
587 | 'File size for resolution ' + file.resolution.label + ' outside confidence interval (' + minSize + '> size <' + maxSize + ')') | 587 | file.size, |
588 | .to.be.above(minSize).and.below(maxSize) | 588 | 'File size for resolution ' + file.resolution.label + ' outside confidence interval (' + minSize + '> size <' + maxSize + ')' |
589 | ).to.be.above(minSize).and.below(maxSize) | ||
589 | 590 | ||
590 | const torrent = await webtorrentAdd(file.magnetUri, true) | 591 | const torrent = await webtorrentAdd(file.magnetUri, true) |
591 | expect(torrent.files).to.be.an('array') | 592 | expect(torrent.files).to.be.an('array') |
@@ -607,15 +608,28 @@ async function videoUUIDToId (url: string, id: number | string) { | |||
607 | return res.body.id | 608 | return res.body.id |
608 | } | 609 | } |
609 | 610 | ||
610 | async function uploadVideoAndGetId (options: { server: ServerInfo, videoName: string, nsfw?: boolean, token?: string }) { | 611 | async function uploadVideoAndGetId (options: { |
612 | server: ServerInfo | ||
613 | videoName: string | ||
614 | nsfw?: boolean | ||
615 | privacy?: VideoPrivacy | ||
616 | token?: string | ||
617 | }) { | ||
611 | const videoAttrs: any = { name: options.videoName } | 618 | const videoAttrs: any = { name: options.videoName } |
612 | if (options.nsfw) videoAttrs.nsfw = options.nsfw | 619 | if (options.nsfw) videoAttrs.nsfw = options.nsfw |
620 | if (options.privacy) videoAttrs.privacy = options.privacy | ||
613 | 621 | ||
614 | const res = await uploadVideo(options.server.url, options.token || options.server.accessToken, videoAttrs) | 622 | const res = await uploadVideo(options.server.url, options.token || options.server.accessToken, videoAttrs) |
615 | 623 | ||
616 | return { id: res.body.video.id, uuid: res.body.video.uuid } | 624 | return { id: res.body.video.id, uuid: res.body.video.uuid } |
617 | } | 625 | } |
618 | 626 | ||
627 | async function getLocalIdByUUID (url: string, uuid: string) { | ||
628 | const res = await getVideo(url, uuid) | ||
629 | |||
630 | return res.body.id | ||
631 | } | ||
632 | |||
619 | // --------------------------------------------------------------------------- | 633 | // --------------------------------------------------------------------------- |
620 | 634 | ||
621 | export { | 635 | export { |
@@ -645,5 +659,6 @@ export { | |||
645 | completeVideoCheck, | 659 | completeVideoCheck, |
646 | checkVideoFilesWereRemoved, | 660 | checkVideoFilesWereRemoved, |
647 | getPlaylistVideos, | 661 | getPlaylistVideos, |
648 | uploadVideoAndGetId | 662 | uploadVideoAndGetId, |
663 | getLocalIdByUUID | ||
649 | } | 664 | } |