1 import { getServerActor } from '../server/helpers/utils'
2 import { initDatabaseModels } from '../server/initializers'
3 import { ActorFollowModel } from '../server/models/activitypub/actor-follow'
4 import { VideoModel } from '../server/models/video/video'
6 initDatabaseModels(true)
8 return getServerActor()
10 .then(serverAccount => {
11 return ActorFollowModel.listAcceptedFollowingUrlsForApi([ serverAccount.id ], undefined)
16 .then(hasFollowing => {
17 if (hasFollowing === true) {
18 console.log('Cannot update host because you follow other servers!')
22 console.log('Updating torrent files.')
23 return VideoModel.list()
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)