aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/create-generate-storyboard-job.ts85
-rw-r--r--scripts/create-move-video-storage-job.ts8
-rwxr-xr-xscripts/i18n/create-custom-files.ts8
-rw-r--r--scripts/migrations/peertube-4.2.ts6
-rwxr-xr-xscripts/prune-storage.ts10
-rwxr-xr-xscripts/release-embed-api.sh2
-rwxr-xr-xscripts/upgrade.sh3
7 files changed, 109 insertions, 13 deletions
diff --git a/scripts/create-generate-storyboard-job.ts b/scripts/create-generate-storyboard-job.ts
new file mode 100644
index 000000000..47c08edac
--- /dev/null
+++ b/scripts/create-generate-storyboard-job.ts
@@ -0,0 +1,85 @@
1import { program } from 'commander'
2import { toCompleteUUID } from '@server/helpers/custom-validators/misc'
3import { initDatabaseModels } from '@server/initializers/database'
4import { JobQueue } from '@server/lib/job-queue'
5import { VideoModel } from '@server/models/video/video'
6import { StoryboardModel } from '@server/models/video/storyboard'
7
8program
9 .description('Generate videos storyboard')
10 .option('-v, --video [videoUUID]', 'Generate the storyboard of a specific video')
11 .option('-a, --all-videos', 'Generate missing storyboards of local videos')
12 .parse(process.argv)
13
14const options = program.opts()
15
16if (!options['video'] && !options['allVideos']) {
17 console.error('You need to choose videos for storyboard generation.')
18 process.exit(-1)
19}
20
21run()
22 .then(() => process.exit(0))
23 .catch(err => {
24 console.error(err)
25 process.exit(-1)
26 })
27
28async function run () {
29 await initDatabaseModels(true)
30
31 JobQueue.Instance.init()
32
33 let ids: number[] = []
34
35 if (options['video']) {
36 const video = await VideoModel.load(toCompleteUUID(options['video']))
37
38 if (!video) {
39 console.error('Unknown video ' + options['video'])
40 process.exit(-1)
41 }
42
43 if (video.remote === true) {
44 console.error('Cannot process a remote video')
45 process.exit(-1)
46 }
47
48 if (video.isLive) {
49 console.error('Cannot process live video')
50 process.exit(-1)
51 }
52
53 ids.push(video.id)
54 } else {
55 ids = await listLocalMissingStoryboards()
56 }
57
58 for (const id of ids) {
59 const videoFull = await VideoModel.load(id)
60
61 if (videoFull.isLive) continue
62
63 await JobQueue.Instance.createJob({
64 type: 'generate-video-storyboard',
65 payload: {
66 videoUUID: videoFull.uuid,
67 federate: true
68 }
69 })
70
71 console.log(`Created generate-storyboard job for ${videoFull.name}.`)
72 }
73}
74
75async function listLocalMissingStoryboards () {
76 const ids = await VideoModel.listLocalIds()
77 const results: number[] = []
78
79 for (const id of ids) {
80 const storyboard = await StoryboardModel.loadByVideo(id)
81 if (!storyboard) results.push(id)
82 }
83
84 return results
85}
diff --git a/scripts/create-move-video-storage-job.ts b/scripts/create-move-video-storage-job.ts
index c402115f0..8537114eb 100644
--- a/scripts/create-move-video-storage-job.ts
+++ b/scripts/create-move-video-storage-job.ts
@@ -1,4 +1,5 @@
1import { program } from 'commander' 1import { program } from 'commander'
2import { toCompleteUUID } from '@server/helpers/custom-validators/misc'
2import { CONFIG } from '@server/initializers/config' 3import { CONFIG } from '@server/initializers/config'
3import { initDatabaseModels } from '@server/initializers/database' 4import { initDatabaseModels } from '@server/initializers/database'
4import { JobQueue } from '@server/lib/job-queue' 5import { JobQueue } from '@server/lib/job-queue'
@@ -32,7 +33,10 @@ if (options['toObjectStorage'] && !CONFIG.OBJECT_STORAGE.ENABLED) {
32 33
33run() 34run()
34 .then(() => process.exit(0)) 35 .then(() => process.exit(0))
35 .catch(err => console.error(err)) 36 .catch(err => {
37 console.error(err)
38 process.exit(-1)
39 })
36 40
37async function run () { 41async function run () {
38 await initDatabaseModels(true) 42 await initDatabaseModels(true)
@@ -42,7 +46,7 @@ async function run () {
42 let ids: number[] = [] 46 let ids: number[] = []
43 47
44 if (options['video']) { 48 if (options['video']) {
45 const video = await VideoModel.load(options['video']) 49 const video = await VideoModel.load(toCompleteUUID(options['video']))
46 50
47 if (!video) { 51 if (!video) {
48 console.error('Unknown video ' + options['video']) 52 console.error('Unknown video ' + options['video'])
diff --git a/scripts/i18n/create-custom-files.ts b/scripts/i18n/create-custom-files.ts
index 72136614c..696a097b1 100755
--- a/scripts/i18n/create-custom-files.ts
+++ b/scripts/i18n/create-custom-files.ts
@@ -69,7 +69,13 @@ const playerKeys = {
69 '{1} from servers · {2} from peers': '{1} from servers · {2} from peers', 69 '{1} from servers · {2} from peers': '{1} from servers · {2} from peers',
70 'Previous video': 'Previous video', 70 'Previous video': 'Previous video',
71 'Video page (new window)': 'Video page (new window)', 71 'Video page (new window)': 'Video page (new window)',
72 'Next video': 'Next video' 72 'Next video': 'Next video',
73 'This video is password protected': 'This video is password protected',
74 'You need a password to watch this video.': 'You need a password to watch this video.',
75 'Incorrect password, please enter a correct password': 'Incorrect password, please enter a correct password',
76 'Cancel': 'Cancel',
77 'Up Next': 'Up Next',
78 'Autoplay is suspended': 'Autoplay is suspended'
73} 79}
74Object.assign(playerKeys, videojs) 80Object.assign(playerKeys, videojs)
75 81
diff --git a/scripts/migrations/peertube-4.2.ts b/scripts/migrations/peertube-4.2.ts
index 513c629ef..d8929692b 100644
--- a/scripts/migrations/peertube-4.2.ts
+++ b/scripts/migrations/peertube-4.2.ts
@@ -78,7 +78,7 @@ async function fillAvatarSizeIfNeeded (accountOrChannel: MAccountDefault | MChan
78 78
79 console.log('Filling size of avatars of %s.', accountOrChannel.name) 79 console.log('Filling size of avatars of %s.', accountOrChannel.name)
80 80
81 const { width, height } = await getImageSize(join(CONFIG.STORAGE.ACTOR_IMAGES, avatar.filename)) 81 const { width, height } = await getImageSize(join(CONFIG.STORAGE.ACTOR_IMAGES_DIR, avatar.filename))
82 avatar.width = width 82 avatar.width = width
83 avatar.height = height 83 avatar.height = height
84 84
@@ -107,8 +107,8 @@ async function generateSmallerAvatar (actor: MActorDefault) {
107 const sourceFilename = bigAvatar.filename 107 const sourceFilename = bigAvatar.filename
108 108
109 const newImageName = buildUUID() + getLowercaseExtension(sourceFilename) 109 const newImageName = buildUUID() + getLowercaseExtension(sourceFilename)
110 const source = join(CONFIG.STORAGE.ACTOR_IMAGES, sourceFilename) 110 const source = join(CONFIG.STORAGE.ACTOR_IMAGES_DIR, sourceFilename)
111 const destination = join(CONFIG.STORAGE.ACTOR_IMAGES, newImageName) 111 const destination = join(CONFIG.STORAGE.ACTOR_IMAGES_DIR, newImageName)
112 112
113 await processImage({ path: source, destination, newSize: imageSize, keepOriginal: true }) 113 await processImage({ path: source, destination, newSize: imageSize, keepOriginal: true })
114 114
diff --git a/scripts/prune-storage.ts b/scripts/prune-storage.ts
index d19594a60..9a73a8600 100755
--- a/scripts/prune-storage.ts
+++ b/scripts/prune-storage.ts
@@ -37,8 +37,8 @@ async function run () {
37 console.log('Detecting files to remove, it could take a while...') 37 console.log('Detecting files to remove, it could take a while...')
38 38
39 toDelete = toDelete.concat( 39 toDelete = toDelete.concat(
40 await pruneDirectory(DIRECTORIES.VIDEOS.PUBLIC, doesWebTorrentFileExist()), 40 await pruneDirectory(DIRECTORIES.VIDEOS.PUBLIC, doesWebVideoFileExist()),
41 await pruneDirectory(DIRECTORIES.VIDEOS.PRIVATE, doesWebTorrentFileExist()), 41 await pruneDirectory(DIRECTORIES.VIDEOS.PRIVATE, doesWebVideoFileExist()),
42 42
43 await pruneDirectory(DIRECTORIES.HLS_STREAMING_PLAYLIST.PRIVATE, doesHLSPlaylistExist()), 43 await pruneDirectory(DIRECTORIES.HLS_STREAMING_PLAYLIST.PRIVATE, doesHLSPlaylistExist()),
44 await pruneDirectory(DIRECTORIES.HLS_STREAMING_PLAYLIST.PUBLIC, doesHLSPlaylistExist()), 44 await pruneDirectory(DIRECTORIES.HLS_STREAMING_PLAYLIST.PUBLIC, doesHLSPlaylistExist()),
@@ -50,7 +50,7 @@ async function run () {
50 await pruneDirectory(CONFIG.STORAGE.PREVIEWS_DIR, doesThumbnailExist(true, ThumbnailType.PREVIEW)), 50 await pruneDirectory(CONFIG.STORAGE.PREVIEWS_DIR, doesThumbnailExist(true, ThumbnailType.PREVIEW)),
51 await pruneDirectory(CONFIG.STORAGE.THUMBNAILS_DIR, doesThumbnailExist(false, ThumbnailType.MINIATURE)), 51 await pruneDirectory(CONFIG.STORAGE.THUMBNAILS_DIR, doesThumbnailExist(false, ThumbnailType.MINIATURE)),
52 52
53 await pruneDirectory(CONFIG.STORAGE.ACTOR_IMAGES, doesActorImageExist) 53 await pruneDirectory(CONFIG.STORAGE.ACTOR_IMAGES_DIR, doesActorImageExist)
54 ) 54 )
55 55
56 const tmpFiles = await readdir(CONFIG.STORAGE.TMP_DIR) 56 const tmpFiles = await readdir(CONFIG.STORAGE.TMP_DIR)
@@ -93,12 +93,12 @@ async function pruneDirectory (directory: string, existFun: ExistFun) {
93 return toDelete 93 return toDelete
94} 94}
95 95
96function doesWebTorrentFileExist () { 96function doesWebVideoFileExist () {
97 return (filePath: string) => { 97 return (filePath: string) => {
98 // Don't delete private directory 98 // Don't delete private directory
99 if (filePath === DIRECTORIES.VIDEOS.PRIVATE) return true 99 if (filePath === DIRECTORIES.VIDEOS.PRIVATE) return true
100 100
101 return VideoFileModel.doesOwnedWebTorrentVideoFileExist(basename(filePath)) 101 return VideoFileModel.doesOwnedWebVideoFileExist(basename(filePath))
102 } 102 }
103} 103}
104 104
diff --git a/scripts/release-embed-api.sh b/scripts/release-embed-api.sh
index ae76a65f5..41c84ed38 100755
--- a/scripts/release-embed-api.sh
+++ b/scripts/release-embed-api.sh
@@ -2,7 +2,7 @@
2 2
3set -eu 3set -eu
4 4
5cd client/src/standalone/player 5cd client/src/standalone/embed-player-api
6 6
7rm -rf dist build && tsc -p . && ../../../node_modules/.bin/webpack --config ./webpack.config.js 7rm -rf dist build && tsc -p . && ../../../node_modules/.bin/webpack --config ./webpack.config.js
8 8
diff --git a/scripts/upgrade.sh b/scripts/upgrade.sh
index 86135fcc9..64c7e1581 100755
--- a/scripts/upgrade.sh
+++ b/scripts/upgrade.sh
@@ -43,10 +43,11 @@ if [ -x "$(command -v pg_dump)" ]; then
43 DB_USER=$(node -e "console.log(require('js-yaml').load(fs.readFileSync('$PEERTUBE_PATH/config/production.yaml', 'utf8'))['database']['username'])") 43 DB_USER=$(node -e "console.log(require('js-yaml').load(fs.readFileSync('$PEERTUBE_PATH/config/production.yaml', 'utf8'))['database']['username'])")
44 DB_PASS=$(node -e "console.log(require('js-yaml').load(fs.readFileSync('$PEERTUBE_PATH/config/production.yaml', 'utf8'))['database']['password'])") 44 DB_PASS=$(node -e "console.log(require('js-yaml').load(fs.readFileSync('$PEERTUBE_PATH/config/production.yaml', 'utf8'))['database']['password'])")
45 DB_HOST=$(node -e "console.log(require('js-yaml').load(fs.readFileSync('$PEERTUBE_PATH/config/production.yaml', 'utf8'))['database']['hostname'])") 45 DB_HOST=$(node -e "console.log(require('js-yaml').load(fs.readFileSync('$PEERTUBE_PATH/config/production.yaml', 'utf8'))['database']['hostname'])")
46 DB_PORT=$(node -e "console.log(require('js-yaml').load(fs.readFileSync('$PEERTUBE_PATH/config/production.yaml', 'utf8'))['database']['port'])")
46 DB_SUFFIX=$(node -e "console.log(require('js-yaml').load(fs.readFileSync('$PEERTUBE_PATH/config/production.yaml', 'utf8'))['database']['suffix'])") 47 DB_SUFFIX=$(node -e "console.log(require('js-yaml').load(fs.readFileSync('$PEERTUBE_PATH/config/production.yaml', 'utf8'))['database']['suffix'])")
47 DB_NAME=$(node -e "console.log(require('js-yaml').load(fs.readFileSync('$PEERTUBE_PATH/config/production.yaml', 'utf8'))['database']['name'] || '')") 48 DB_NAME=$(node -e "console.log(require('js-yaml').load(fs.readFileSync('$PEERTUBE_PATH/config/production.yaml', 'utf8'))['database']['name'] || '')")
48 49
49 PGPASSWORD=$DB_PASS pg_dump -U $DB_USER -h $DB_HOST -F c "${DB_NAME:-peertube${DB_SUFFIX}}" -f "$SQL_BACKUP_PATH" 50 PGPASSWORD=$DB_PASS pg_dump -U $DB_USER -p $DB_PORT -h $DB_HOST -F c "${DB_NAME:-peertube${DB_SUFFIX}}" -f "$SQL_BACKUP_PATH"
50else 51else
51 echo "pg_dump not found. Cannot make a SQL backup!" 52 echo "pg_dump not found. Cannot make a SQL backup!"
52fi 53fi