diff options
Diffstat (limited to 'scripts/update-host.ts')
-rwxr-xr-x | scripts/update-host.ts | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/scripts/update-host.ts b/scripts/update-host.ts index 422a3c9a7..57919b998 100755 --- a/scripts/update-host.ts +++ b/scripts/update-host.ts | |||
@@ -1,11 +1,12 @@ | |||
1 | import { CONFIG, initDatabaseModels } from '../server/initializers' | 1 | import { WEBSERVER } from '../server/initializers/constants' |
2 | import { ActorFollowModel } from '../server/models/activitypub/actor-follow' | 2 | import { ActorFollowModel } from '../server/models/activitypub/actor-follow' |
3 | import { VideoModel } from '../server/models/video/video' | 3 | import { VideoModel } from '../server/models/video/video' |
4 | import { ActorModel } from '../server/models/activitypub/actor' | 4 | import { ActorModel } from '../server/models/activitypub/actor' |
5 | import { | 5 | import { |
6 | getAccountActivityPubUrl, | 6 | getAccountActivityPubUrl, |
7 | getVideoActivityPubUrl, | ||
7 | getVideoAnnounceActivityPubUrl, | 8 | getVideoAnnounceActivityPubUrl, |
8 | getVideoActivityPubUrl, getVideoChannelActivityPubUrl, | 9 | getVideoChannelActivityPubUrl, |
9 | getVideoCommentActivityPubUrl | 10 | getVideoCommentActivityPubUrl |
10 | } from '../server/lib/activitypub' | 11 | } from '../server/lib/activitypub' |
11 | import { VideoShareModel } from '../server/models/video/video-share' | 12 | import { VideoShareModel } from '../server/models/video/video-share' |
@@ -13,6 +14,8 @@ import { VideoCommentModel } from '../server/models/video/video-comment' | |||
13 | import { getServerActor } from '../server/helpers/utils' | 14 | import { getServerActor } from '../server/helpers/utils' |
14 | import { AccountModel } from '../server/models/account/account' | 15 | import { AccountModel } from '../server/models/account/account' |
15 | import { VideoChannelModel } from '../server/models/video/video-channel' | 16 | import { VideoChannelModel } from '../server/models/video/video-channel' |
17 | import { VideoStreamingPlaylistModel } from '../server/models/video/video-streaming-playlist' | ||
18 | import { initDatabaseModels } from '../server/initializers' | ||
16 | 19 | ||
17 | run() | 20 | run() |
18 | .then(() => process.exit(0)) | 21 | .then(() => process.exit(0)) |
@@ -61,7 +64,7 @@ async function run () { | |||
61 | actor.url = newUrl | 64 | actor.url = newUrl |
62 | actor.inboxUrl = newUrl + '/inbox' | 65 | actor.inboxUrl = newUrl + '/inbox' |
63 | actor.outboxUrl = newUrl + '/outbox' | 66 | actor.outboxUrl = newUrl + '/outbox' |
64 | actor.sharedInboxUrl = CONFIG.WEBSERVER.URL + '/inbox' | 67 | actor.sharedInboxUrl = WEBSERVER.URL + '/inbox' |
65 | actor.followersUrl = newUrl + '/followers' | 68 | actor.followersUrl = newUrl + '/followers' |
66 | actor.followingUrl = newUrl + '/following' | 69 | actor.followingUrl = newUrl + '/following' |
67 | 70 | ||
@@ -109,11 +112,9 @@ async function run () { | |||
109 | 112 | ||
110 | console.log('Updating video and torrent files.') | 113 | console.log('Updating video and torrent files.') |
111 | 114 | ||
112 | const videos = await VideoModel.list() | 115 | const videos = await VideoModel.listLocal() |
113 | for (const video of videos) { | 116 | for (const video of videos) { |
114 | if (video.isOwned() === false) continue | 117 | console.log('Updating video ' + video.uuid) |
115 | |||
116 | console.log('Updated video ' + video.uuid) | ||
117 | 118 | ||
118 | video.url = getVideoActivityPubUrl(video) | 119 | video.url = getVideoActivityPubUrl(video) |
119 | await video.save() | 120 | await video.save() |
@@ -122,5 +123,12 @@ async function run () { | |||
122 | console.log('Updating torrent file %s of video %s.', file.resolution, video.uuid) | 123 | console.log('Updating torrent file %s of video %s.', file.resolution, video.uuid) |
123 | await video.createTorrentAndSetInfoHash(file) | 124 | await video.createTorrentAndSetInfoHash(file) |
124 | } | 125 | } |
126 | |||
127 | for (const playlist of video.VideoStreamingPlaylists) { | ||
128 | playlist.playlistUrl = WEBSERVER.URL + VideoStreamingPlaylistModel.getHlsMasterPlaylistStaticPath(video.uuid) | ||
129 | playlist.segmentsSha256Url = WEBSERVER.URL + VideoStreamingPlaylistModel.getHlsSha256SegmentsStaticPath(video.uuid) | ||
130 | |||
131 | await playlist.save() | ||
132 | } | ||
125 | } | 133 | } |
126 | } | 134 | } |