diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/optimize-old-videos.ts | 17 | ||||
-rwxr-xr-x | scripts/prune-storage.ts | 4 | ||||
-rwxr-xr-x | scripts/update-host.ts | 7 |
3 files changed, 15 insertions, 13 deletions
diff --git a/scripts/optimize-old-videos.ts b/scripts/optimize-old-videos.ts index eb61ec43c..107483c50 100644 --- a/scripts/optimize-old-videos.ts +++ b/scripts/optimize-old-videos.ts | |||
@@ -1,15 +1,16 @@ | |||
1 | import { registerTSPaths } from '../server/helpers/register-ts-paths' | 1 | import { registerTSPaths } from '../server/helpers/register-ts-paths' |
2 | registerTSPaths() | ||
3 | |||
4 | import { VIDEO_TRANSCODING_FPS } from '../server/initializers/constants' | 2 | import { VIDEO_TRANSCODING_FPS } from '../server/initializers/constants' |
5 | import { getDurationFromVideoFile, getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution } from '../server/helpers/ffmpeg-utils' | 3 | import { getDurationFromVideoFile, getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution } from '../server/helpers/ffmpeg-utils' |
6 | import { getMaxBitrate } from '../shared/models/videos' | 4 | import { getMaxBitrate } from '../shared/models/videos' |
7 | import { VideoModel } from '../server/models/video/video' | 5 | import { VideoModel } from '../server/models/video/video' |
8 | import { optimizeVideofile } from '../server/lib/video-transcoding' | 6 | import { optimizeOriginalVideofile } from '../server/lib/video-transcoding' |
9 | import { initDatabaseModels } from '../server/initializers' | 7 | import { initDatabaseModels } from '../server/initializers' |
10 | import { basename, dirname, join } from 'path' | 8 | import { basename, dirname } from 'path' |
11 | import { copy, move, remove } from 'fs-extra' | 9 | import { copy, move, remove } from 'fs-extra' |
12 | import { CONFIG } from '../server/initializers/config' | 10 | import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent' |
11 | import { getVideoFilePath } from '@server/lib/video-paths' | ||
12 | |||
13 | registerTSPaths() | ||
13 | 14 | ||
14 | run() | 15 | run() |
15 | .then(() => process.exit(0)) | 16 | .then(() => process.exit(0)) |
@@ -37,7 +38,7 @@ async function run () { | |||
37 | currentVideoId = video.id | 38 | currentVideoId = video.id |
38 | 39 | ||
39 | for (const file of video.VideoFiles) { | 40 | for (const file of video.VideoFiles) { |
40 | currentFile = join(CONFIG.STORAGE.VIDEOS_DIR, video.getVideoFilename(file)) | 41 | currentFile = getVideoFilePath(video, file) |
41 | 42 | ||
42 | const [ videoBitrate, fps, resolution ] = await Promise.all([ | 43 | const [ videoBitrate, fps, resolution ] = await Promise.all([ |
43 | getVideoFileBitrate(currentFile), | 44 | getVideoFileBitrate(currentFile), |
@@ -56,7 +57,7 @@ async function run () { | |||
56 | const backupFile = `${currentFile}_backup` | 57 | const backupFile = `${currentFile}_backup` |
57 | await copy(currentFile, backupFile) | 58 | await copy(currentFile, backupFile) |
58 | 59 | ||
59 | await optimizeVideofile(video, file) | 60 | await optimizeOriginalVideofile(video, file) |
60 | 61 | ||
61 | const originalDuration = await getDurationFromVideoFile(backupFile) | 62 | const originalDuration = await getDurationFromVideoFile(backupFile) |
62 | const newDuration = await getDurationFromVideoFile(currentFile) | 63 | const newDuration = await getDurationFromVideoFile(currentFile) |
@@ -69,7 +70,7 @@ async function run () { | |||
69 | 70 | ||
70 | console.log('Failed to optimize %s, restoring original', basename(currentFile)) | 71 | console.log('Failed to optimize %s, restoring original', basename(currentFile)) |
71 | await move(backupFile, currentFile, { overwrite: true }) | 72 | await move(backupFile, currentFile, { overwrite: true }) |
72 | await video.createTorrentAndSetInfoHash(file) | 73 | await createTorrentAndSetInfoHash(video, file) |
73 | await file.save() | 74 | await file.save() |
74 | } | 75 | } |
75 | } | 76 | } |
diff --git a/scripts/prune-storage.ts b/scripts/prune-storage.ts index c8968013b..fa3d81744 100755 --- a/scripts/prune-storage.ts +++ b/scripts/prune-storage.ts | |||
@@ -134,9 +134,9 @@ async function doesRedundancyExist (file: string) { | |||
134 | return true | 134 | return true |
135 | } | 135 | } |
136 | 136 | ||
137 | const videoFile = video.getFile(resolution) | 137 | const videoFile = video.getWebTorrentFile(resolution) |
138 | if (!videoFile) { | 138 | if (!videoFile) { |
139 | console.error('Cannot find file of video %s - %d', video.url, resolution) | 139 | console.error('Cannot find webtorrent file of video %s - %d', video.url, resolution) |
140 | return true | 140 | return true |
141 | } | 141 | } |
142 | 142 | ||
diff --git a/scripts/update-host.ts b/scripts/update-host.ts index a946d2e42..d9192d554 100755 --- a/scripts/update-host.ts +++ b/scripts/update-host.ts | |||
@@ -1,6 +1,4 @@ | |||
1 | import { registerTSPaths } from '../server/helpers/register-ts-paths' | 1 | import { registerTSPaths } from '../server/helpers/register-ts-paths' |
2 | registerTSPaths() | ||
3 | |||
4 | import { WEBSERVER } from '../server/initializers/constants' | 2 | import { WEBSERVER } from '../server/initializers/constants' |
5 | import { ActorFollowModel } from '../server/models/activitypub/actor-follow' | 3 | import { ActorFollowModel } from '../server/models/activitypub/actor-follow' |
6 | import { VideoModel } from '../server/models/video/video' | 4 | import { VideoModel } from '../server/models/video/video' |
@@ -19,6 +17,9 @@ import { AccountModel } from '../server/models/account/account' | |||
19 | import { VideoChannelModel } from '../server/models/video/video-channel' | 17 | import { VideoChannelModel } from '../server/models/video/video-channel' |
20 | import { VideoStreamingPlaylistModel } from '../server/models/video/video-streaming-playlist' | 18 | import { VideoStreamingPlaylistModel } from '../server/models/video/video-streaming-playlist' |
21 | import { initDatabaseModels } from '../server/initializers' | 19 | import { initDatabaseModels } from '../server/initializers' |
20 | import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent' | ||
21 | |||
22 | registerTSPaths() | ||
22 | 23 | ||
23 | run() | 24 | run() |
24 | .then(() => process.exit(0)) | 25 | .then(() => process.exit(0)) |
@@ -124,7 +125,7 @@ async function run () { | |||
124 | 125 | ||
125 | for (const file of video.VideoFiles) { | 126 | for (const file of video.VideoFiles) { |
126 | console.log('Updating torrent file %s of video %s.', file.resolution, video.uuid) | 127 | console.log('Updating torrent file %s of video %s.', file.resolution, video.uuid) |
127 | await video.createTorrentAndSetInfoHash(file) | 128 | await createTorrentAndSetInfoHash(video, file) |
128 | } | 129 | } |
129 | 130 | ||
130 | for (const playlist of video.VideoStreamingPlaylists) { | 131 | for (const playlist of video.VideoStreamingPlaylists) { |