aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/optimize-old-videos.ts17
-rwxr-xr-xscripts/prune-storage.ts4
-rwxr-xr-xscripts/update-host.ts7
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 @@
1import { registerTSPaths } from '../server/helpers/register-ts-paths' 1import { registerTSPaths } from '../server/helpers/register-ts-paths'
2registerTSPaths()
3
4import { VIDEO_TRANSCODING_FPS } from '../server/initializers/constants' 2import { VIDEO_TRANSCODING_FPS } from '../server/initializers/constants'
5import { getDurationFromVideoFile, getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution } from '../server/helpers/ffmpeg-utils' 3import { getDurationFromVideoFile, getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution } from '../server/helpers/ffmpeg-utils'
6import { getMaxBitrate } from '../shared/models/videos' 4import { getMaxBitrate } from '../shared/models/videos'
7import { VideoModel } from '../server/models/video/video' 5import { VideoModel } from '../server/models/video/video'
8import { optimizeVideofile } from '../server/lib/video-transcoding' 6import { optimizeOriginalVideofile } from '../server/lib/video-transcoding'
9import { initDatabaseModels } from '../server/initializers' 7import { initDatabaseModels } from '../server/initializers'
10import { basename, dirname, join } from 'path' 8import { basename, dirname } from 'path'
11import { copy, move, remove } from 'fs-extra' 9import { copy, move, remove } from 'fs-extra'
12import { CONFIG } from '../server/initializers/config' 10import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent'
11import { getVideoFilePath } from '@server/lib/video-paths'
12
13registerTSPaths()
13 14
14run() 15run()
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 @@
1import { registerTSPaths } from '../server/helpers/register-ts-paths' 1import { registerTSPaths } from '../server/helpers/register-ts-paths'
2registerTSPaths()
3
4import { WEBSERVER } from '../server/initializers/constants' 2import { WEBSERVER } from '../server/initializers/constants'
5import { ActorFollowModel } from '../server/models/activitypub/actor-follow' 3import { ActorFollowModel } from '../server/models/activitypub/actor-follow'
6import { VideoModel } from '../server/models/video/video' 4import { VideoModel } from '../server/models/video/video'
@@ -19,6 +17,9 @@ import { AccountModel } from '../server/models/account/account'
19import { VideoChannelModel } from '../server/models/video/video-channel' 17import { VideoChannelModel } from '../server/models/video/video-channel'
20import { VideoStreamingPlaylistModel } from '../server/models/video/video-streaming-playlist' 18import { VideoStreamingPlaylistModel } from '../server/models/video/video-streaming-playlist'
21import { initDatabaseModels } from '../server/initializers' 19import { initDatabaseModels } from '../server/initializers'
20import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent'
21
22registerTSPaths()
22 23
23run() 24run()
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) {