ActivityPub-federated video streaming platform using P2P directly in your web browser
Also update playlist URLs
Chocobozzz04a0ed13b40c
diff --git a/packages/server-commands/src/videos/playlists-command.ts b/packages/server-commands/src/videos/playlists-command.tsindex 2e483f318f..99f3e3c0d2 100644--- a/packages/server-commands/src/videos/playlists-command.ts+++ b/packages/server-commands/src/videos/playlists-command.ts@@ -25,7 +25,7 @@ export class PlaylistsCommand extends AbstractCommand {count?: numbersort?: stringplaylistType?: VideoPlaylistType_Type- }) {+ } = {}) {const path = '/api/v1/video-playlists'const query = pick(options, [ 'start', 'count', 'sort', 'playlistType' ])diff --git a/packages/tests/src/cli/update-host.ts b/packages/tests/src/cli/update-host.tsindex e5f165e5e9..38b160d2c4 100644--- a/packages/tests/src/cli/update-host.ts+++ b/packages/tests/src/cli/update-host.ts@@ -9,9 +9,11 @@ import {makeActivityPubGetRequest,PeerTubeServer,setAccessTokensToServers,+ setDefaultVideoChannel,waitJobs} from '@peertube/peertube-server-commands'import { parseTorrentVideo } from '@tests/shared/webtorrent.js'+import { VideoPlaylistPrivacy } from '@peertube/peertube-models'describe('Test update host scripts', function () {let server: PeerTubeServer@@ -27,6 +29,7 @@ describe('Test update host scripts', function () {// Run server 2 to have transcoding enabledserver = await createSingleServer(2, overrideConfig)await setAccessTokensToServers([ server ])+ await setDefaultVideoChannel([ server ])// Upload two videos for our needsconst { uuid: video1UUID } = await server.videos.upload()@@ -47,6 +50,13 @@ describe('Test update host scripts', function () {const text = 'my super first comment'await server.comments.createThread({ videoId: video1UUID, text })+ // Playlist+ {+ const attributes = { displayName: 'playlist', privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: server.store.channel.id }+ const playlist = await server.playlists.create({ attributes })+ await server.playlists.addElement({ playlistId: playlist.id, attributes: { videoId: video1UUID } })+ }+await waitJobs(server)})@@ -100,6 +110,23 @@ describe('Test update host scripts', function () {}})+ it('Should have updated playlist url', async function () {+ const body = await server.playlists.list()+ expect(body.total).to.equal(1)++ for (const playlist of body.data) {+ const { body } = await makeActivityPubGetRequest(server.url, '/video-playlists/' + playlist.uuid)+ expect(body.id).to.equal('http://127.0.0.1:9002/video-playlists/' + playlist.uuid)++ const { data: elements } = await server.playlists.listVideos({ playlistId: playlist.id })++ for (const element of elements) {+ const { body } = await makeActivityPubGetRequest(server.url, `/video-playlists/${playlist.uuid}/videos/${element.id}`)+ expect(body.id).to.equal(`http://127.0.0.1:9002/video-playlists/${playlist.uuid}/videos/${element.id}`)+ }+ }+ })+it('Should have updated torrent hosts', async function () {this.timeout(30000)diff --git a/server/scripts/update-host.ts b/server/scripts/update-host.tsindex d5c378e680..47b3362d3b 100755--- a/server/scripts/update-host.ts+++ b/server/scripts/update-host.ts@@ -7,7 +7,9 @@ import {getLocalVideoActivityPubUrl,getLocalVideoAnnounceActivityPubUrl,getLocalVideoChannelActivityPubUrl,- getLocalVideoCommentActivityPubUrl+ getLocalVideoCommentActivityPubUrl,+ getLocalVideoPlaylistActivityPubUrl,+ getLocalVideoPlaylistElementActivityPubUrl} from '@server/lib/activitypub/url.js'import { AccountModel } from '@server/models/account/account.js'import { ActorFollowModel } from '@server/models/actor/actor-follow.js'@@ -17,6 +19,8 @@ import { VideoCommentModel } from '@server/models/video/video-comment.js'import { VideoShareModel } from '@server/models/video/video-share.js'import { VideoModel } from '@server/models/video/video.js'import { MActorAccount } from '@server/types/models/index.js'+import { VideoPlaylistModel } from '@server/models/video/video-playlist.js'+import { VideoPlaylistElementModel } from '@server/models/video/video-playlist-element.js'run().then(() => process.exit(0))@@ -122,6 +126,44 @@ async function run () {await comment.save()}+ console.log('Updating video playlists.')+ const videoPlaylists: VideoPlaylistModel[] = await VideoPlaylistModel.findAll({+ include: [+ {+ model: AccountModel.unscoped(),+ required: true,+ include: [+ {+ model: ActorModel.unscoped(),+ where: {+ serverId: null+ },+ required: true+ }+ ]+ }+ ]+ })+ for (const playlist of videoPlaylists) {+ console.log('Updating video playlist ' + playlist.url)++ playlist.url = getLocalVideoPlaylistActivityPubUrl(playlist)+ await playlist.save()++ const elements: VideoPlaylistElementModel[] = await VideoPlaylistElementModel.findAll({+ where: {+ videoPlaylistId: playlist.id+ }+ })++ for (const element of elements) {+ console.log('Updating video playlist element ' + element.url)++ element.url = getLocalVideoPlaylistElementActivityPubUrl(playlist, element)+ await element.save()+ }+ }+console.log('Updating video and torrent files.')const ids = await VideoModel.listLocalIds()