]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - scripts/update-host.ts
Add ability to manually run transcoding job
[github/Chocobozzz/PeerTube.git] / scripts / update-host.ts
CommitLineData
da854ddd 1import { getServerActor } from '../server/helpers/utils'
91fea9fc 2import { initDatabaseModels } from '../server/initializers'
50d6de9c 3import { ActorFollowModel } from '../server/models/activitypub/actor-follow'
3fd3ab2d 4import { VideoModel } from '../server/models/video/video'
75d612ce 5
91fea9fc 6initDatabaseModels(true)
6fcd19ba 7 .then(() => {
50d6de9c 8 return getServerActor()
6fcd19ba 9 })
eb8b27c9 10 .then(serverAccount => {
50d6de9c 11 return ActorFollowModel.listAcceptedFollowingUrlsForApi([ serverAccount.id ], undefined)
eb8b27c9
C
12 })
13 .then(res => {
14 return res.total > 0
15 })
16 .then(hasFollowing => {
17 if (hasFollowing === true) {
18 console.log('Cannot update host because you follow other servers!')
75d612ce
C
19 process.exit(-1)
20 }
21
22 console.log('Updating torrent files.')
3fd3ab2d 23 return VideoModel.list()
6fcd19ba 24 })
c91de743
C
25 .then(async videos => {
26 for (const video of videos) {
27 for (const file of video.VideoFiles) {
28 await video.createTorrentAndSetInfoHash(file)
29 console.log('Updated video ' + video.uuid)
30 }
31 }
fdbda9e3
C
32 })
33 .then(() => {
6fcd19ba 34 process.exit(0)
75d612ce 35 })