diff options
author | Chocobozzz <me@florianbigard.com> | 2021-07-23 11:20:00 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2021-07-26 11:29:31 +0200 |
commit | 764b1a14fc494f2cfd7ea590d2f07b01df65c7ad (patch) | |
tree | 198ca5f242c63a205a05fa4cfd6d063277c541fd /server/lib/activitypub/videos/shared/object-to-model-attributes.ts | |
parent | 83903cb65d531a6b6b91715387493ba8312b264d (diff) | |
download | PeerTube-764b1a14fc494f2cfd7ea590d2f07b01df65c7ad.tar.gz PeerTube-764b1a14fc494f2cfd7ea590d2f07b01df65c7ad.tar.zst PeerTube-764b1a14fc494f2cfd7ea590d2f07b01df65c7ad.zip |
Use random names for VOD HLS playlists
Diffstat (limited to 'server/lib/activitypub/videos/shared/object-to-model-attributes.ts')
-rw-r--r-- | server/lib/activitypub/videos/shared/object-to-model-attributes.ts | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/server/lib/activitypub/videos/shared/object-to-model-attributes.ts b/server/lib/activitypub/videos/shared/object-to-model-attributes.ts index 85548428c..1fa16295d 100644 --- a/server/lib/activitypub/videos/shared/object-to-model-attributes.ts +++ b/server/lib/activitypub/videos/shared/object-to-model-attributes.ts | |||
@@ -7,10 +7,11 @@ import { logger } from '@server/helpers/logger' | |||
7 | import { getExtFromMimetype } from '@server/helpers/video' | 7 | import { getExtFromMimetype } from '@server/helpers/video' |
8 | import { ACTIVITY_PUB, MIMETYPES, P2P_MEDIA_LOADER_PEER_VERSION, PREVIEWS_SIZE, THUMBNAILS_SIZE } from '@server/initializers/constants' | 8 | import { ACTIVITY_PUB, MIMETYPES, P2P_MEDIA_LOADER_PEER_VERSION, PREVIEWS_SIZE, THUMBNAILS_SIZE } from '@server/initializers/constants' |
9 | import { generateTorrentFileName } from '@server/lib/video-paths' | 9 | import { generateTorrentFileName } from '@server/lib/video-paths' |
10 | import { VideoCaptionModel } from '@server/models/video/video-caption' | ||
10 | import { VideoFileModel } from '@server/models/video/video-file' | 11 | import { VideoFileModel } from '@server/models/video/video-file' |
11 | import { VideoStreamingPlaylistModel } from '@server/models/video/video-streaming-playlist' | 12 | import { VideoStreamingPlaylistModel } from '@server/models/video/video-streaming-playlist' |
12 | import { FilteredModelAttributes } from '@server/types' | 13 | import { FilteredModelAttributes } from '@server/types' |
13 | import { MChannelId, MStreamingPlaylist, MStreamingPlaylistVideo, MVideo, MVideoFile, MVideoId } from '@server/types/models' | 14 | import { isStreamingPlaylist, MChannelId, MStreamingPlaylistVideo, MVideo, MVideoFile, MVideoId } from '@server/types/models' |
14 | import { | 15 | import { |
15 | ActivityHashTagObject, | 16 | ActivityHashTagObject, |
16 | ActivityMagnetUrlObject, | 17 | ActivityMagnetUrlObject, |
@@ -23,7 +24,6 @@ import { | |||
23 | VideoPrivacy, | 24 | VideoPrivacy, |
24 | VideoStreamingPlaylistType | 25 | VideoStreamingPlaylistType |
25 | } from '@shared/models' | 26 | } from '@shared/models' |
26 | import { VideoCaptionModel } from '@server/models/video/video-caption' | ||
27 | 27 | ||
28 | function getThumbnailFromIcons (videoObject: VideoObject) { | 28 | function getThumbnailFromIcons (videoObject: VideoObject) { |
29 | let validIcons = videoObject.icon.filter(i => i.width > THUMBNAILS_SIZE.minWidth) | 29 | let validIcons = videoObject.icon.filter(i => i.width > THUMBNAILS_SIZE.minWidth) |
@@ -80,8 +80,8 @@ function getFileAttributesFromUrl ( | |||
80 | 80 | ||
81 | const extname = getExtFromMimetype(MIMETYPES.VIDEO.MIMETYPE_EXT, fileUrl.mediaType) | 81 | const extname = getExtFromMimetype(MIMETYPES.VIDEO.MIMETYPE_EXT, fileUrl.mediaType) |
82 | const resolution = fileUrl.height | 82 | const resolution = fileUrl.height |
83 | const videoId = (videoOrPlaylist as MStreamingPlaylist).playlistUrl ? null : videoOrPlaylist.id | 83 | const videoId = isStreamingPlaylist(videoOrPlaylist) ? null : videoOrPlaylist.id |
84 | const videoStreamingPlaylistId = (videoOrPlaylist as MStreamingPlaylist).playlistUrl ? videoOrPlaylist.id : null | 84 | const videoStreamingPlaylistId = isStreamingPlaylist(videoOrPlaylist) ? videoOrPlaylist.id : null |
85 | 85 | ||
86 | const attribute = { | 86 | const attribute = { |
87 | extname, | 87 | extname, |
@@ -130,8 +130,13 @@ function getStreamingPlaylistAttributesFromObject (video: MVideoId, videoObject: | |||
130 | 130 | ||
131 | const attribute = { | 131 | const attribute = { |
132 | type: VideoStreamingPlaylistType.HLS, | 132 | type: VideoStreamingPlaylistType.HLS, |
133 | |||
134 | playlistFilename: basename(playlistUrlObject.href), | ||
133 | playlistUrl: playlistUrlObject.href, | 135 | playlistUrl: playlistUrlObject.href, |
136 | |||
137 | segmentsSha256Filename: basename(segmentsSha256UrlObject.href), | ||
134 | segmentsSha256Url: segmentsSha256UrlObject.href, | 138 | segmentsSha256Url: segmentsSha256UrlObject.href, |
139 | |||
135 | p2pMediaLoaderInfohashes: VideoStreamingPlaylistModel.buildP2PMediaLoaderInfoHashes(playlistUrlObject.href, files), | 140 | p2pMediaLoaderInfohashes: VideoStreamingPlaylistModel.buildP2PMediaLoaderInfoHashes(playlistUrlObject.href, files), |
136 | p2pMediaLoaderPeerVersion: P2P_MEDIA_LOADER_PEER_VERSION, | 141 | p2pMediaLoaderPeerVersion: P2P_MEDIA_LOADER_PEER_VERSION, |
137 | videoId: video.id, | 142 | videoId: video.id, |