From 6ba93fa6392429f22d338f3cdce50707995ced3b Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 9 Dec 2021 11:23:02 +0100 Subject: [PATCH] Fix torrent metadata update for hls --- scripts/update-host.ts | 2 +- server/controllers/api/videos/update.ts | 11 ++++++++++- server/models/video/video.ts | 15 --------------- 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 () { for (const file of (playlist?.VideoFiles || [])) { console.log('Updating fragmented torrent file %s of video %s.', file.resolution, video.uuid) - await updateTorrentMetadata(video, file) + await updateTorrentMetadata(playlist, file) await file.save() } 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 } async function updateTorrentsMetadata (video: MVideoFullLight) { - for (const file of video.getAllFiles()) { + for (const file of (video.VideoFiles || [])) { await updateTorrentMetadata(video, file) await file.save() } + + const hls = video.getHLSPlaylist() + if (!hls) return + + for (const file of (hls.VideoFiles || [])) { + await updateTorrentMetadata(hls, file) + + await file.save() + } } 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>> { return this.VideoChannel.Account.Actor.Server?.isBlocked() || this.VideoChannel.Account.isBlocked() } - getAllFiles () { - let files: MVideoFile[] = [] - - if (Array.isArray(this.VideoFiles)) { - files = files.concat(this.VideoFiles) - } - - const hls = this.getHLSPlaylist() - if (hls) { - files = files.concat(hls.VideoFiles) - } - - return files - } - getQualityFileBy (this: T, fun: (files: MVideoFile[], it: (file: MVideoFile) => number) => MVideoFile) { // We first transcode to WebTorrent format, so try this array first if (Array.isArray(this.VideoFiles) && this.VideoFiles.length !== 0) {