aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-12-09 11:23:02 +0100
committerChocobozzz <me@florianbigard.com>2021-12-09 11:23:02 +0100
commit6ba93fa6392429f22d338f3cdce50707995ced3b (patch)
tree58b7ad9976109464d8a70e53c061168747ef5930
parent2acb622cb8f6b273ba9a03d5e37630d19a3d3e30 (diff)
downloadPeerTube-6ba93fa6392429f22d338f3cdce50707995ced3b.tar.gz
PeerTube-6ba93fa6392429f22d338f3cdce50707995ced3b.tar.zst
PeerTube-6ba93fa6392429f22d338f3cdce50707995ced3b.zip
Fix torrent metadata update for hls
-rwxr-xr-xscripts/update-host.ts2
-rw-r--r--server/controllers/api/videos/update.ts11
-rw-r--r--server/models/video/video.ts15
3 files changed, 11 insertions, 17 deletions
diff --git a/scripts/update-host.ts b/scripts/update-host.ts
index f752082fd..66c0137d9 100755
--- a/scripts/update-host.ts
+++ b/scripts/update-host.ts
@@ -135,7 +135,7 @@ async function run () {
135 for (const file of (playlist?.VideoFiles || [])) { 135 for (const file of (playlist?.VideoFiles || [])) {
136 console.log('Updating fragmented torrent file %s of video %s.', file.resolution, video.uuid) 136 console.log('Updating fragmented torrent file %s of video %s.', file.resolution, video.uuid)
137 137
138 await updateTorrentMetadata(video, file) 138 await updateTorrentMetadata(playlist, file)
139 139
140 await file.save() 140 await file.save()
141 } 141 }
diff --git a/server/controllers/api/videos/update.ts b/server/controllers/api/videos/update.ts
index c0eb4ebee..e397127f3 100644
--- a/server/controllers/api/videos/update.ts
+++ b/server/controllers/api/videos/update.ts
@@ -202,9 +202,18 @@ function updateSchedule (videoInstance: MVideoFullLight, videoInfoToUpdate: Vide
202} 202}
203 203
204async function updateTorrentsMetadata (video: MVideoFullLight) { 204async function updateTorrentsMetadata (video: MVideoFullLight) {
205 for (const file of video.getAllFiles()) { 205 for (const file of (video.VideoFiles || [])) {
206 await updateTorrentMetadata(video, file) 206 await updateTorrentMetadata(video, file)
207 207
208 await file.save() 208 await file.save()
209 } 209 }
210
211 const hls = video.getHLSPlaylist()
212 if (!hls) return
213
214 for (const file of (hls.VideoFiles || [])) {
215 await updateTorrentMetadata(hls, file)
216
217 await file.save()
218 }
210} 219}
diff --git a/server/models/video/video.ts b/server/models/video/video.ts
index 801e23f55..1050463d2 100644
--- a/server/models/video/video.ts
+++ b/server/models/video/video.ts
@@ -1539,21 +1539,6 @@ export class VideoModel extends Model<Partial<AttributesOnly<VideoModel>>> {
1539 return this.VideoChannel.Account.Actor.Server?.isBlocked() || this.VideoChannel.Account.isBlocked() 1539 return this.VideoChannel.Account.Actor.Server?.isBlocked() || this.VideoChannel.Account.isBlocked()
1540 } 1540 }
1541 1541
1542 getAllFiles () {
1543 let files: MVideoFile[] = []
1544
1545 if (Array.isArray(this.VideoFiles)) {
1546 files = files.concat(this.VideoFiles)
1547 }
1548
1549 const hls = this.getHLSPlaylist()
1550 if (hls) {
1551 files = files.concat(hls.VideoFiles)
1552 }
1553
1554 return files
1555 }
1556
1557 getQualityFileBy<T extends MVideoWithFile> (this: T, fun: (files: MVideoFile[], it: (file: MVideoFile) => number) => MVideoFile) { 1542 getQualityFileBy<T extends MVideoWithFile> (this: T, fun: (files: MVideoFile[], it: (file: MVideoFile) => number) => MVideoFile) {
1558 // We first transcode to WebTorrent format, so try this array first 1543 // We first transcode to WebTorrent format, so try this array first
1559 if (Array.isArray(this.VideoFiles) && this.VideoFiles.length !== 0) { 1544 if (Array.isArray(this.VideoFiles) && this.VideoFiles.length !== 0) {